-
Notifications
You must be signed in to change notification settings - Fork 0
Add trace capture reason extension parsing to Dynatrace tag #26
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
base: feat/dt-trace-capture-reason
Are you sure you want to change the base?
Add trace capture reason extension parsing to Dynatrace tag #26
Conversation
Signed-off-by: Joao Grassi <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds trace capture reason extension parsing to the Dynatrace sampler in Envoy. The implementation introduces a new TraceCaptureReason class to parse and encode trace capture reasons (like "atm", "fixed", "custom", "rum", etc.) from Dynatrace tracestate tags, and integrates this functionality into the existing sampling workflow.
Key changes:
- Added
TraceCaptureReasonclass to parse and encode trace capture reason bitmasks from hex strings - Extended
DynatraceTagto support optional trace capture reason extension (8h prefix) - Modified sampler to add trace.capture.reasons as span attributes and include them in tracestate
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
trace_capture_reason_test.cc |
New test file with comprehensive test coverage for TraceCaptureReason parsing |
dynatrace_sampler_test.cc |
Updated tests to verify trace capture reason handling in sampling results and tracestate |
dynatrace_sampler_integration_test.cc |
Added integration tests to verify trace capture reason extension presence in tracestate |
BUILD (test) |
Added trace_capture_reason_test.cc to test sources |
trace_capture_reason.h |
New header defining TraceCaptureReason class with parsing and encoding logic |
dynatrace_tag.h |
Extended to parse and include optional trace capture reason extension |
dynatrace_sampler.cc |
Updated to create trace capture reason for new traces and add as span attributes |
BUILD (source) |
Added trace_capture_reason.h and absl::optional dependency |
otlp_utils.h |
Redefined OTelAttribute to use absl::variant instead of opentelemetry::common::AttributeValue |
otlp_utils.cc |
Updated attribute serialization to handle new attribute types including string_view vectors |
Comments suppressed due to low confidence (1)
source/extensions/tracers/opentelemetry/samplers/dynatrace/trace_capture_reason.h:1
- Redundant absl::string_view constructor call. The substr(2) already returns an absl::string_view, so the explicit constructor is unnecessary.
#pragma once
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| // Parse optional payload for trace capture reason (id 8h) | ||
| absl::optional<TraceCaptureReason> tcr_extension = std::nullopt; |
Copilot
AI
Nov 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent use of std::nullopt instead of absl::nullopt for absl::optional initialization. Use absl::nullopt for consistency with absl::optional.
| absl::optional<TraceCaptureReason> tcr_extension = std::nullopt; | |
| absl::optional<TraceCaptureReason> tcr_extension = absl::nullopt; |
| /** | ||
| * @brief Open-telemetry Attribute | ||
| * see | ||
| * https://github.com/open-telemetry/opentelemetry-cpp/blob/main/api/include/opentelemetry/common/attribute_value.h |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Need to update this reference now to point to the "OwnedAttributeType" we were inspired on, since we can't add the SDK to Envoy
Internal PR for adding the trace capture reason to the Dynatrace sampler in Envoy.