Package codes.grow.packages.datadogapm
Class DatadogSpanErrors
java.lang.Object
codes.grow.packages.datadogapm.DatadogSpanErrors
Datadog error attributes (DECISIONS.md #2). The Datadog Agent keeps an OTLP exception only inside
the
events JSON and does not fill error.type / error.stack, so this
package sets error.type, error.message and error.stack span attributes
itself, which Datadog Error Tracking reads.
recordException(java.lang.Throwable) and setError(java.lang.Throwable) replace the generic helpers of Spans of
the same name. The generic helpers (and withSpan, @Traced, the HTTP adapters and
plain OpenTelemetry recordException calls) also get the attributes when spans are
exported through DatadogTracing.initTracing(): its exporter fills them from the exception
event (withDatadogErrorAttributes(SpanData)).
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondatadogErrorAttributes(Throwable error) The Datadog error attributes for an exception:error.type(canonical class name, the same as OpenTelemetry'sexception.type),error.message(when the exception has a message) anderror.stack(the printed stack trace).static io.opentelemetry.api.common.AttributesderivedErrorAttributes(io.opentelemetry.sdk.trace.data.SpanData span) The Datadog error attributes derived from a finished span: from its lastexceptionevent (exception.type,exception.message,exception.stacktrace) or, for an ERROR status without an event message,error.messagefrom the status description.static voidrecordException(Throwable error) Records an exception event on the current span (likeSpans.recordException(java.lang.Throwable)) and sets the Datadog error attributes.static voidSets ERROR status (with the message) on the current span, records the exception event (likeSpans.setError(Throwable)) and sets the Datadog error attributes.static voidsetErrorAttributes(io.opentelemetry.api.trace.Span span, Throwable error) Sets the Datadog error attributes forerroronspan.static voidsetErrorAttributes(Throwable error) Sets the Datadog error attributes forerroron the current span.static io.opentelemetry.sdk.trace.data.SpanDatawithDatadogErrorAttributes(io.opentelemetry.sdk.trace.data.SpanData span)
-
Field Details
-
ATTR_ERROR_TYPE
error.typespan attribute (exception class name).- See Also:
-
ATTR_ERROR_MESSAGE
error.messagespan attribute.- See Also:
-
ATTR_ERROR_STACK
error.stackspan attribute.- See Also:
-
-
Method Details
-
datadogErrorAttributes
The Datadog error attributes for an exception:error.type(canonical class name, the same as OpenTelemetry'sexception.type),error.message(when the exception has a message) anderror.stack(the printed stack trace).nullgives an empty map.- Parameters:
error- exception- Returns:
- attributes
-
setErrorAttributes
Sets the Datadog error attributes forerroronspan. No-op fornull.- Parameters:
span- spanerror- exception
-
setErrorAttributes
Sets the Datadog error attributes forerroron the current span.- Parameters:
error- exception
-
recordException
Records an exception event on the current span (likeSpans.recordException(java.lang.Throwable)) and sets the Datadog error attributes. The status is unchanged.nullis ignored.- Parameters:
error- exception
-
setError
Sets ERROR status (with the message) on the current span, records the exception event (likeSpans.setError(Throwable)) and sets the Datadog error attributes.nullis ignored.- Parameters:
error- exception
-
derivedErrorAttributes
public static io.opentelemetry.api.common.Attributes derivedErrorAttributes(io.opentelemetry.sdk.trace.data.SpanData span) The Datadog error attributes derived from a finished span: from its lastexceptionevent (exception.type,exception.message,exception.stacktrace) or, for an ERROR status without an event message,error.messagefrom the status description. Empty when the span already haserror.typeorerror.message, or has no error.- Parameters:
span- finished span- Returns:
- attributes to add
-
withDatadogErrorAttributes
public static io.opentelemetry.sdk.trace.data.SpanData withDatadogErrorAttributes(io.opentelemetry.sdk.trace.data.SpanData span) - Parameters:
span- finished span- Returns:
- span data
-