Description
Expected Behavior
Execute DataDog Synthetic Test and see trace linked to the executed request.
Actual Behavior
Traces are not linked.
Steps to Reproduce the Problem
In our case the headers are not passed via headers
, but multiValueHeaders
:
"multiValueHeaders": {
"x-datadog-origin": [
"synthetics"
],
"x-datadog-parent-id": [
"0"
],
"x-datadog-sampling-priority": [
"1"
],
"x-datadog-trace-id": [
"1775877486757059156"
],
}
datadog-lambda-go/internal/trace/context.go
Line 173 in 82f6bee
It is possible to set a custom TraceContextExtractor
in the config, but would be nice to have this supported out of the box.
// lambda.Start(ddlambda.WrapFunction(proxiedHandler, &ddlambda.Config{
// DDTraceEnabled: true,
// DebugLogging: false,
// TraceContextExtractor: getHeadersFromEventHeaders,
// }))
type eventWithHeaders struct {
MultiValueHeaders map[string][]string `json:"multiValueHeaders"`
}
func getHeadersFromEventHeaders(ctx context.Context, ev json.RawMessage) map[string]string {
eh := eventWithHeaders{}
headers := map[string]string{}
err := json.Unmarshal(ev, &eh)
if err != nil {
return headers
}
lowercaseHeaders := map[string]string{}
for k, v := range eh.MultiValueHeaders {
if len(v) > 0 {
lowercaseHeaders[strings.ToLower(k)] = v[0]
}
}
return lowercaseHeaders
}
Additionally we had to patch getTraceContext
to include x-datadog-origin
:
datadog-lambda-go/internal/trace/context.go
Line 130 in 82f6bee
tc[samplingPriorityHeader] = samplingPriority
tc[traceIDHeader] = traceID
tc[parentIDHeader] = parentID
if origin, ok := headers["x-datadog-origin"]; ok {
tc["x-datadog-origin"] = origin
}
return tc, true
Otherwise it is missing for the check in extractTextMap
(no origin, thus ErrSpanContextNotFound
):
Specifications
- Datadog Go Lambda package version: 1.20.0
- Go version: 1.24.0
Metadata
Metadata
Assignees
Labels
No labels