Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
Domain Data Mgmt Services
Wellbore
Wellbore Domain Services
Commits
51f46b12
Commit
51f46b12
authored
Jul 12, 2021
by
Alexandre Vincent
Browse files
trace data-partition-id even in None case
parent
d86f746a
Changes
2
Show whitespace changes
Inline
Side-by-side
app/middleware/traces_middleware.py
View file @
51f46b12
...
...
@@ -91,8 +91,6 @@ class TracingMiddleware(BaseHTTPMiddleware):
ctx_partition_id
=
get_or_create_ctx
().
partition_id
partition_id
=
ctx_partition_id
if
ctx_partition_id
is
not
None
\
else
request
.
headers
.
get
(
conf
.
PARTITION_ID_HEADER_NAME
)
# only put in the trace if there is data
if
partition_id
is
not
None
:
tracer
.
add_attribute_to_current_span
(
attribute_key
=
conf
.
PARTITION_ID_HEADER_NAME
,
attribute_value
=
partition_id
)
...
...
tests/unit/middleware/traces_middleware_test.py
View file @
51f46b12
...
...
@@ -88,10 +88,11 @@ def test_about_call_traces_existing_data_partition_id(client: TestClient):
response
=
client
.
get
(
build_url
(
"/about"
))
assert
response
.
status_code
==
200
# one call was exported, with
out
data-partition-id
# one call was exported, with data-partition-id
assert
len
(
wdms_app
.
trace_exporter
.
exported
)
==
1
# one call => one export
spandata
=
wdms_app
.
trace_exporter
.
exported
[
0
]
assert
'data-partition-id'
not
in
spandata
.
attributes
.
keys
()
assert
'data-partition-id'
in
spandata
.
attributes
.
keys
()
assert
spandata
.
attributes
[
'data-partition-id'
]
is
None
# data-partition-id header -> works as well
client
.
get
(
build_url
(
"/about"
),
headers
=
{
'data-partition-id'
:
'some partition id'
})
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment