-
Notifications
You must be signed in to change notification settings - Fork 1
NH-53473 benchmark always sample #248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
tammy-baylis-swi
wants to merge
2
commits into
main
Choose a base branch
from
benchmark-always-sample
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Comment on lines
+174
to
+195
# def test_scenario_4_not_sampled(self): | ||
# """ | ||
# Scenario #4, NOT sampled: | ||
# 1. Decision to NOT sample is continued at service entry span (mocked). This is | ||
# not the root span because it continues an existing OTel context. | ||
# 2. traceparent and tracestate headers in the request to the test app are | ||
# injected into the outgoing request (done by OTel TraceContextTextMapPropagator). | ||
# 3. No spans are exported. | ||
# """ | ||
# trace_id = "11112222333344445555666677778888" | ||
# span_id = "1000100010001000" | ||
# trace_flags = "00" | ||
# traceparent = "00-{}-{}-{}".format(trace_id, span_id, trace_flags) | ||
# tracestate_span = "e000baa4e000baa4" | ||
# tracestate = "sw={}-{}".format(tracestate_span, trace_flags) | ||
|
||
# Use in-process test app client and mock to propagate context | ||
# and create in-memory trace | ||
resp = None | ||
# liboboe mocked to guarantee return of "do_sample" (2nd arg) | ||
mock_decision = mock.Mock( | ||
return_value=(1, 0, 3, 4, 5.0, 6.0, 1, 0, "ok", "ok", 0) | ||
) | ||
with mock.patch( | ||
target="solarwinds_apm.extension.oboe.Context.getDecisions", | ||
new=mock_decision, | ||
): | ||
# Request to instrumented app with headers | ||
resp = self.client.get( | ||
"/test_trace/", | ||
headers={ | ||
"traceparent": traceparent, | ||
"tracestate": tracestate, | ||
"some-header": "some-value" | ||
} | ||
) | ||
resp_json = json.loads(resp.data) | ||
# # Use in-process test app client and mock to propagate context | ||
# # and create in-memory trace | ||
# resp = None | ||
# # liboboe mocked to guarantee return of "do_sample" (2nd arg) | ||
# mock_decision = mock.Mock( | ||
# return_value=(1, 0, 3, 4, 5.0, 6.0, 1, 0, "ok", "ok", 0) |
Check notice
Code scanning / CodeQL
Commented-out code
This comment appears to contain commented-out code.
Comment on lines
+213
to
+221
# try: | ||
# assert resp_json["incoming-headers"]["some-header"] == "some-value" | ||
# except KeyError as e: | ||
# self.fail("KeyError was raised at incoming-headers check: {}".format(e)) | ||
|
||
# Verify trace context injected into test app's outgoing postman-echo call | ||
# (added to Flask app's response data) includes: | ||
# - traceparent with a trace_id, trace_flags from original request | ||
# - tracestate from original request | ||
assert "traceparent" in resp_json | ||
_TRACEPARENT_HEADER_FORMAT = ( | ||
"^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$" | ||
) | ||
_TRACEPARENT_HEADER_FORMAT_RE = re.compile(_TRACEPARENT_HEADER_FORMAT) | ||
traceparent_re_result = re.search( | ||
_TRACEPARENT_HEADER_FORMAT_RE, | ||
resp_json["traceparent"], | ||
) | ||
new_trace_id = traceparent_re_result.group(2) | ||
assert new_trace_id is not None | ||
assert new_trace_id == trace_id | ||
new_span_id = traceparent_re_result.group(3) | ||
assert new_span_id is not None | ||
new_trace_flags = traceparent_re_result.group(4) | ||
assert new_trace_flags == trace_flags | ||
# # Verify trace context injected into test app's outgoing postman-echo call | ||
# # (added to Flask app's response data) includes: | ||
# # - traceparent with a trace_id, trace_flags from original request | ||
# # - tracestate from original request |
Check notice
Code scanning / CodeQL
Commented-out code
This comment appears to contain commented-out code.
Comment on lines
+246
to
+261
# try: | ||
# assert resp_json["incoming-headers"]["traceparent"] == traceparent | ||
# assert new_trace_id in resp_json["incoming-headers"]["traceparent"] | ||
# assert new_span_id not in resp_json["incoming-headers"]["traceparent"] | ||
# assert new_trace_flags in resp_json["incoming-headers"]["traceparent"] | ||
|
||
assert resp_json["incoming-headers"]["tracestate"] == tracestate | ||
assert "sw=" in resp_json["incoming-headers"]["tracestate"] | ||
assert new_span_id not in resp_json["incoming-headers"]["tracestate"] | ||
assert new_trace_flags in resp_json["incoming-headers"]["tracestate"] | ||
except KeyError as e: | ||
self.fail("KeyError was raised at continue trace check: {}".format(e)) | ||
# assert resp_json["incoming-headers"]["tracestate"] == tracestate | ||
# assert "sw=" in resp_json["incoming-headers"]["tracestate"] | ||
# assert new_span_id not in resp_json["incoming-headers"]["tracestate"] | ||
# assert new_trace_flags in resp_json["incoming-headers"]["tracestate"] | ||
# except KeyError as e: | ||
# self.fail("KeyError was raised at continue trace check: {}".format(e)) | ||
|
||
# Verify x-trace response header has same trace_id | ||
# though it will have different span ID because of Flask | ||
# app's outgoing request | ||
assert "x-trace" in resp.headers | ||
assert new_trace_id in resp.headers["x-trace"] | ||
# # Verify x-trace response header has same trace_id | ||
# # though it will have different span ID because of Flask | ||
# # app's outgoing request |
Check notice
Code scanning / CodeQL
Commented-out code
This comment appears to contain commented-out code.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Do NOT merge.