Class DatadogMapping
Two Datadog shapes are mapped:
- a trace span as the Agent forwards it and as
GET /api/v2/trace/{id}returns it (meta,metrics, nanosecondstart/startTime, decimal ids; camelCase or snake_case keys):traceSpanToSpan(JsonNode); - a span event of the spans search API (
attributes.trace_id,start_timestamp, ...):searchSpanToSpan(JsonNode).
For spans that came in over OTLP the Datadog resource is the OpenTelemetry span name and the
Datadog name is the operation (Internal, server.request, ...), so the normalized
name is the resource; the Datadog operation is kept as attribute operation_name. Parse
JSON with Jackson (as Json.tree(byte[]) does) so ids above 2^53 stay exact.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Span.KinddatadogKind(String value) Converts a Datadogspan.kind(or OpenTelemetry kind name) to a span kind.static SpansearchSpanToSpan(com.fasterxml.jackson.databind.JsonNode item) Maps one span of the spans search API (data[i]ofPOST /api/v2/spans/events/search, or itsattributes) to a span.static SpantraceSpanToSpan(com.fasterxml.jackson.databind.JsonNode raw) Maps a Datadog trace span to a span: the Agent's format (trace_id,span_id,parent_id,start,duration,meta,metrics) or the trace-by-id API format (traceID,traceIDFull,spanID,parentID,startTime,endTime,duration).static SpantraceSpanToSpan(Map<String, ?> raw) traceSpanToSpan(JsonNode)for a decoded map.
-
Method Details
-
datadogKind
Converts a Datadogspan.kind(or OpenTelemetry kind name) to a span kind.- Parameters:
value- kind text- Returns:
- kind (
UNSPECIFIEDwhen unknown)
-
traceSpanToSpan
Maps a Datadog trace span to a span: the Agent's format (trace_id,span_id,parent_id,start,duration,meta,metrics) or the trace-by-id API format (traceID,traceIDFull,spanID,parentID,startTime,endTime,duration).The full trace id comes from
traceIDFull/trace_id_hex/ metaotel.trace_id, else the decimal low 64 bits plus meta_dd.p.tid. Name = Datadog resource, kind = metaspan.kind, status =errorflag (message fromerror.message,error.msgorotel.status_description) or metaotel.status_code. Events come from metaeventsandspan_events, links from meta_dd.span_linksandspan_links. Attributes are the remaining meta (strings) and metrics (numbers), plusoperation_name,resource_nameandspan.type.- Parameters:
raw- span object- Returns:
- span
- Throws:
ValidationException- for invalid ids
-
traceSpanToSpan
traceSpanToSpan(JsonNode)for a decoded map.- Parameters:
raw- span map- Returns:
- span
-
searchSpanToSpan
Maps one span of the spans search API (data[i]ofPOST /api/v2/spans/events/search, or itsattributes) to a span. Nested span attributes (attributes,custom) are flattened to dotted keys; tags (key:value) are added as attributes. Name =resource_name, kind fromspan.kind, status error whenstatusiserrororerroris set; duration from thedurationattribute (nanoseconds) when present, else end - start.- Parameters:
item- span event- Returns:
- span
- Throws:
ValidationException- for invalid ids
-