Invalid `x-datadog-sampling-priority` header format
Closed this issue · 2 comments
Problem Description
in the context propagation format mentioned in Datadog documentation it's mentioned that x-datadog-sampling-priority
is used to specify the sampling decision made for the represented span as an integer, in decimal format.
currently, dd-trace-cpp throws this error when it receives x-datadog-sampling-priority
of 0.0
[2024-08-21 11:30:57.214][40][error][tracing] [source/extensions/tracers/datadog/tracer.cc:133] Unable to extract span context. Creating a new trace instead. Error [error 16]: While extracting trace context in the Datadog propagation style from the following headers: [x-datadog-trace-id: 1440130837183445134, x-datadog-parent-id: 10794189177351031766, x-datadog-sampling-priority: 0.0], an error occurred: Could not extract Datadog-style sampling priority from x-datadog-sampling-priority: 0.0 Integer has trailing characters in: "0.0"
Is this a correct behavior or not ?
I think 0.0 or 1.0 or any decimal value should be accepted as valid input. if not, the documentation page needs to be updated
Reproduction steps
- use dd-trace-py to generate a DD context.
tracer.context_provider.activate(
Context(
trace_id=int(datadog_json.get('x-datadog-trace-id')),
span_id=int(datadog_json.get('x-datadog-parent-id')),
sampling_priority=float(datadog_json.get('x-datadog-sampling-priority', 1))
)
)
notice that in dd-trace-py they accept both int/float types for sampling-priority header
- make a request to C++ application that is instrumented using dd-trace-cpp , in our case the request is made to the envoy proxy that has datadog tracing enabled on it.
Decimal as opposed to hexadecimal. It parses an integer and so will reject text that contains a decimal point. Sorry for the use of the ambiguous term "decimal."
thanks for the clarification @dgoffredo , I think this issue isn't related to dd-trace-cpp.
but an enhancement can be made from dd-trace-py to not send/accept float values in dd-context if float isn't an acceptable input.