Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
controller
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TFS
controller
Commits
538f52c1
Commit
538f52c1
authored
2 years ago
by
famelis
Browse files
Options
Downloads
Patches
Plain Diff
feat: add annotations for metrics in p4_service_handler.py
parent
8065cee7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!142
Release TeraFlowSDN 2.1
,
!83
Add annotations to p4 service handler
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/service/service/service_handlers/p4/p4_service_handler.py
+23
-0
23 additions, 0 deletions
...service/service/service_handlers/p4/p4_service_handler.py
with
23 additions
and
0 deletions
src/service/service/service_handlers/p4/p4_service_handler.py
+
23
−
0
View file @
538f52c1
...
...
@@ -28,6 +28,23 @@ from service.service.task_scheduler.TaskExecutor import TaskExecutor
LOGGER
=
logging
.
getLogger
(
__name__
)
HISTOGRAM_BUCKETS
=
(
# .005, .01, .025, .05, .075, .1, .25, .5, .75, 1.0, INF
0.0010
,
0.0025
,
0.0050
,
0.0075
,
0.0100
,
0.0250
,
0.0500
,
0.0750
,
0.1000
,
0.2500
,
0.5000
,
0.7500
,
1.0000
,
2.5000
,
5.0000
,
7.5000
,
10.0000
,
25.000
,
50.0000
,
75.000
,
100.0
,
INF
)
METRICS_POOL
=
MetricsPool
(
'
Service
'
,
'
Handler
'
,
labels
=
{
'
handler
'
:
'
p4
'
})
METRICS_POOL
.
get_or_create
(
'
SetEndpoint
'
,
MetricTypeEnum
.
HISTOGRAM_DURATION
,
buckets
=
HISTOGRAM_BUCKETS
)
METRICS_POOL
.
get_or_create
(
'
DeleteEndpoint
'
,
MetricTypeEnum
.
HISTOGRAM_DURATION
,
buckets
=
HISTOGRAM_BUCKETS
)
METRICS_POOL
.
get_or_create
(
'
SetConstraint
'
,
MetricTypeEnum
.
HISTOGRAM_DURATION
,
buckets
=
HISTOGRAM_BUCKETS
)
METRICS_POOL
.
get_or_create
(
'
DeleteConstraint
'
,
MetricTypeEnum
.
HISTOGRAM_DURATION
,
buckets
=
HISTOGRAM_BUCKETS
)
METRICS_POOL
.
get_or_create
(
'
SetConfig
'
,
MetricTypeEnum
.
HISTOGRAM_DURATION
,
buckets
=
HISTOGRAM_BUCKETS
)
METRICS_POOL
.
get_or_create
(
'
DeleteConfig
'
,
MetricTypeEnum
.
HISTOGRAM_DURATION
,
buckets
=
HISTOGRAM_BUCKETS
)
def
create_rule_set
(
endpoint_a
,
endpoint_b
):
return
json_config_rule_set
(
'
table
'
,
...
...
@@ -99,6 +116,7 @@ class P4ServiceHandler(_ServiceHandler):
self
.
__service
=
service
self
.
__task_executor
=
task_executor
# pylint: disable=unused-private-member
@metered_subclass_method
(
METRICS_POOL
)
def
SetEndpoint
(
self
,
endpoints
:
List
[
Tuple
[
str
,
str
,
Optional
[
str
]]],
connection_uuid
:
Optional
[
str
]
=
None
...
...
@@ -169,6 +187,7 @@ class P4ServiceHandler(_ServiceHandler):
return
results
@metered_subclass_method
(
METRICS_POOL
)
def
DeleteEndpoint
(
self
,
endpoints
:
List
[
Tuple
[
str
,
str
,
Optional
[
str
]]],
connection_uuid
:
Optional
[
str
]
=
None
...
...
@@ -239,6 +258,7 @@ class P4ServiceHandler(_ServiceHandler):
return
results
@metered_subclass_method
(
METRICS_POOL
)
def
SetConstraint
(
self
,
constraints
:
List
[
Tuple
[
str
,
Any
]])
\
->
List
[
Union
[
bool
,
Exception
]]:
"""
Create/Update service constraints.
...
...
@@ -261,6 +281,7 @@ class P4ServiceHandler(_ServiceHandler):
LOGGER
.
warning
(
msg
.
format
(
str
(
constraints
)))
return
[
True
for
_
in
range
(
len
(
constraints
))]
@metered_subclass_method
(
METRICS_POOL
)
def
DeleteConstraint
(
self
,
constraints
:
List
[
Tuple
[
str
,
Any
]])
\
->
List
[
Union
[
bool
,
Exception
]]:
"""
Delete service constraints.
...
...
@@ -285,6 +306,7 @@ class P4ServiceHandler(_ServiceHandler):
LOGGER
.
warning
(
msg
.
format
(
str
(
constraints
)))
return
[
True
for
_
in
range
(
len
(
constraints
))]
@metered_subclass_method
(
METRICS_POOL
)
def
SetConfig
(
self
,
resources
:
List
[
Tuple
[
str
,
Any
]])
\
->
List
[
Union
[
bool
,
Exception
]]:
"""
Create/Update configuration for a list of service resources.
...
...
@@ -308,6 +330,7 @@ class P4ServiceHandler(_ServiceHandler):
LOGGER
.
warning
(
msg
.
format
(
str
(
resources
)))
return
[
True
for
_
in
range
(
len
(
resources
))]
@metered_subclass_method
(
METRICS_POOL
)
def
DeleteConfig
(
self
,
resources
:
List
[
Tuple
[
str
,
Any
]])
\
->
List
[
Union
[
bool
,
Exception
]]:
"""
Delete configuration for a list of service resources.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment