Skip to content

Conversation

@joaopgrassi
Copy link
Member

Internal PR for adding the trace capture reason to the Dynatrace sampler in Envoy.

Copy link

Copilot AI left a 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 TraceCaptureReason class to parse and encode trace capture reason bitmasks from hex strings
  • Extended DynatraceTag to 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;
Copy link

Copilot AI Nov 18, 2025

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.

Suggested change
absl::optional<TraceCaptureReason> tcr_extension = std::nullopt;
absl::optional<TraceCaptureReason> tcr_extension = absl::nullopt;

Copilot uses AI. Check for mistakes.
/**
* @brief Open-telemetry Attribute
* see
* https://github.com/open-telemetry/opentelemetry-cpp/blob/main/api/include/opentelemetry/common/attribute_value.h
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants