Class OpenTelemetryUtils

java.lang.Object
org.forgerock.opendj.otel.OpenTelemetryUtils

public final class OpenTelemetryUtils extends Object
Utility class for OpenTelemetry.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static 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 Type
    Method
    Description
    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.
    static void
    recordExceptionIfNotNull(io.opentelemetry.api.trace.Span span, Throwable e)
    Replaces Span.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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • TRANSACTION_ID_CTX_KEY

      public static final io.opentelemetry.context.ContextKey<String> TRANSACTION_ID_CTX_KEY
      Key for storing a transaction ID in the OpenTelemetry context.
    • LDAP_REQUEST_DN

      public static final io.opentelemetry.api.common.AttributeKey<String> 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_REQUEST
      Allows 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_REQUEST
      Allows OTel to write trace parent and trace state into an LDAP request.
  • Method Details

    • recordExceptionIfNotNull

      public static void recordExceptionIfNotNull(io.opentelemetry.api.trace.Span span, Throwable e)
      Replaces Span.recordException(java.lang.Throwable) with a version having a more compact stacktrace.
      Parameters:
      span - the span to record the exception on
      e - 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 builder
      kind - the kind of the span to build
      request - the request used to build the span name
      Returns:
      a SpanBuilder
    • spanName

      public static String spanName(Request.RequestType requestType, Dn backendDn)
      Returns a span name according to the request type and the backend DN.
      Parameters:
      requestType - the type of the request
      backendDn - the DN of the backend
      Returns:
      a span name built with the request type and the backend DN