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
c92e688a
Commit
c92e688a
authored
6 months ago
by
Waleed Akbar
Browse files
Options
Downloads
Patches
Plain Diff
Changes to resolve KpiValueAPI CI/CD unit test error
parent
6aa08173
No related branches found
No related tags found
2 merge requests
!294
Release TeraFlowSDN 4.0
,
!279
Resolve "(CTTC) Issues in KpiValueWriter CI/CD pipeline"
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scripts/run_tests_locally-kpi-value-writer.sh
+1
-0
1 addition, 0 deletions
scripts/run_tests_locally-kpi-value-writer.sh
src/kpi_value_writer/service/MetricWriterToPrometheus.py
+5
-6
5 additions, 6 deletions
src/kpi_value_writer/service/MetricWriterToPrometheus.py
with
6 additions
and
6 deletions
scripts/run_tests_locally-kpi-value-writer.sh
+
1
−
0
View file @
c92e688a
...
...
@@ -18,6 +18,7 @@ PROJECTDIR=`pwd`
cd
$PROJECTDIR
/src
export
KFK_SERVER_ADDRESS
=
'127.0.0.1:9092'
RCFILE
=
$PROJECTDIR
/coverage/.coveragerc
python3
-m
pytest
--log-level
=
DEBUG
--log-cli-level
=
DEBUG
--verbose
\
kpi_value_writer/tests/test_kpi_value_writer.py
This diff is collapsed.
Click to expand it.
src/kpi_value_writer/service/MetricWriterToPrometheus.py
+
5
−
6
View file @
c92e688a
...
...
@@ -15,7 +15,6 @@
# read Kafka stream from Kafka topic
import
logging
from
typing
import
Dict
from
prometheus_client
import
Gauge
from
common.proto.kpi_sample_types_pb2
import
KpiSampleType
...
...
@@ -45,13 +44,13 @@ class MetricWriterToPrometheus:
'
slice_id
'
:
kpi_descriptor
.
slice_id
.
slice_uuid
.
uuid
,
'
connection_id
'
:
kpi_descriptor
.
connection_id
.
connection_uuid
.
uuid
,
'
link_id
'
:
kpi_descriptor
.
link_id
.
link_uuid
.
uuid
,
'
time_stamp
'
:
kpi_value
[
'
timestamp
'
]
,
'
kpi_value
'
:
kpi_value
[
'
kpi_value_type
'
]
'
time_stamp
'
:
kpi_value
.
timestamp
.
timestamp
,
'
kpi_value
'
:
kpi_value
.
kpi_value_type
.
floatVal
}
#
LOGGER.debug("Cooked Kpi: {:}".format(cooked_kpi))
LOGGER
.
debug
(
"
Cooked Kpi: {:}
"
.
format
(
cooked_kpi
))
return
cooked_kpi
def
create_and_expose_cooked_kpi
(
self
,
kpi_descriptor
:
KpiDescriptor
,
kpi_value
:
Dict
):
def
create_and_expose_cooked_kpi
(
self
,
kpi_descriptor
:
KpiDescriptor
,
kpi_value
:
KpiValue
):
# merge both gRPC messages into single varible.
cooked_kpi
=
self
.
merge_kpi_descriptor_and_kpi_value
(
kpi_descriptor
,
kpi_value
)
tags_to_exclude
=
{
'
kpi_description
'
,
'
kpi_sample_type
'
,
'
kpi_value
'
}
...
...
@@ -74,7 +73,7 @@ class MetricWriterToPrometheus:
connection_id
=
cooked_kpi
[
'
connection_id
'
],
link_id
=
cooked_kpi
[
'
link_id
'
],
time_stamp
=
cooked_kpi
[
'
time_stamp
'
],
).
set
(
cooked_kpi
[
'
kpi_value
'
])
).
set
(
float
(
cooked_kpi
[
'
kpi_value
'
])
)
LOGGER
.
debug
(
"
Metric pushed to the endpoints: {:}
"
.
format
(
PROM_METRICS
[
metric_name
]))
except
ValueError
as
e
:
...
...
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