Package org.forgerock.opendj.otel
Class OpenTelemetryUtils
java.lang.Object
org.forgerock.opendj.otel.OpenTelemetryUtils
Utility class for OpenTelemetry.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final io.opentelemetry.api.common.AttributeKey
<String> Key for storing the LDAP request DN.static final io.opentelemetry.context.propagation.TextMapGetter
<Request> Allows OTel to read trace parent and state from an LDAP request.static final io.opentelemetry.context.ContextKey
<String> Key for storing a transaction ID in the OpenTelemetry context.static final io.opentelemetry.context.propagation.TextMapSetter
<Request> Allows OTel to write trace parent and trace state into an LDAP request. -
Method Summary
Modifier and TypeMethodDescriptionstatic io.opentelemetry.api.trace.SpanBuilder
ldapSpanBuilder
(io.opentelemetry.api.trace.Tracer tracer, io.opentelemetry.api.trace.SpanKind kind, Request request) Returns a span builder whose name is based on the given request.static void
recordExceptionIfNotNull
(io.opentelemetry.api.trace.Span span, Throwable e) ReplacesSpan.recordException(java.lang.Throwable)
with a version having a more compact stacktrace.static String
spanName
(Request.RequestType requestType, Dn backendDn) Returns a span name according to the request type and the backend DN.
-
Field Details
-
TRANSACTION_ID_CTX_KEY
Key for storing a transaction ID in the OpenTelemetry context. -
LDAP_REQUEST_DN
Key for storing the LDAP request DN. -
READ_FROM_LDAP_REQUEST
public static final io.opentelemetry.context.propagation.TextMapGetter<Request> READ_FROM_LDAP_REQUESTAllows OTel to read trace parent and state from an LDAP request. -
WRITE_INTO_LDAP_REQUEST
public static final io.opentelemetry.context.propagation.TextMapSetter<Request> WRITE_INTO_LDAP_REQUESTAllows OTel to write trace parent and trace state into an LDAP request.
-
-
Method Details
-
recordExceptionIfNotNull
ReplacesSpan.recordException(java.lang.Throwable)
with a version having a more compact stacktrace.- Parameters:
span
- the span to record the exception one
- if not-null
, the exception to record
-
ldapSpanBuilder
public static io.opentelemetry.api.trace.SpanBuilder ldapSpanBuilder(io.opentelemetry.api.trace.Tracer tracer, io.opentelemetry.api.trace.SpanKind kind, Request request) Returns a span builder whose name is based on the given request. The name follows the OpenTelemetry naming conventions defined here and there- Parameters:
tracer
- the tracer to build the span builderkind
- the kind of the span to buildrequest
- the request used to build the span name- Returns:
- a
SpanBuilder
-
spanName
Returns a span name according to the request type and the backend DN.- Parameters:
requestType
- the type of the requestbackendDn
- the DN of the backend- Returns:
- a span name built with the request type and the backend DN
-