Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
satella
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
satella
Commits
4dacccd8
Commit
4dacccd8
authored
5 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
add extra test for timestamp exports
parent
65aad937
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
satella/instrumentation/metrics/exporters/prometheus.py
+3
-3
3 additions, 3 deletions
satella/instrumentation/metrics/exporters/prometheus.py
tests/test_instrumentation/test_metrics/test_exporters.py
+4
-0
4 additions, 0 deletions
tests/test_instrumentation/test_metrics/test_exporters.py
with
7 additions
and
3 deletions
satella/instrumentation/metrics/exporters/prometheus.py
+
3
−
3
View file @
4dacccd8
...
...
@@ -20,11 +20,11 @@ class RendererObject(io.StringIO):
if
is_leaf_node
(
tree
):
self
.
write
(
'
_
'
.
join
(
prefix
for
prefix
in
prefixes
if
prefix
!=
''
))
curly_braces_used
=
len
(
tree
)
>
1
if
curly_braces_used
:
self
.
write
(
'
{
'
)
main_value
=
tree
.
pop
(
'
_
'
)
ts
=
tree
.
pop
(
'
_timestamp
'
,
None
)
curly_braces_used
=
len
(
tree
)
>
0
if
curly_braces_used
:
self
.
write
(
'
{
'
)
if
curly_braces_used
:
labels
=
[]
for
key
,
value
in
tree
.
items
():
...
...
This diff is collapsed.
Click to expand it.
tests/test_instrumentation/test_metrics/test_exporters.py
+
4
−
0
View file @
4dacccd8
...
...
@@ -7,6 +7,10 @@ logger = logging.getLogger(__name__)
class
TestExporters
(
unittest
.
TestCase
):
def
test_prometheus_timestamps
(
self
):
a
=
{
'
root
'
:
{
'
_
'
:
5
,
'
_timestamp
'
:
10
}}
self
.
assertEqual
(
"""
root 5 10000
\n
"""
,
json_to_prometheus
(
a
))
def
test_prometheus
(
self
):
a
=
{
'
root
'
:
{
'
metric
'
:
[{
'
k
'
:
2
,
'
_
'
:
3
,
'
m
'
:
'"'
},
{
'
k
'
:
4
,
'
_
'
:
6
}]}}
...
...
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