Class TraceSupport

java.lang.Object
swiss.trustbroker.common.tracing.TraceSupport

public class TraceSupport extends Object
This class adopts the OpenTelemetry effort providing these features:
  • MDC traceId to tag every log line with the OpenTelemetry compatible traceId.spanId where spanId is our own root
  • OpTrace logs are tagged with trID=traceId.spanId for request based tracing
The related W3C specification lists these propagations:
  • traceparent is set by XTB if not received from client, we derive traceId from x-request-id if it's compliant.
  • tracestate is not (yet) supported
Note that the ID displayed in error screen are either based on current requests or the related login conversation depending on the processing phase within XTB. If we do not yet know a conversation because OpenTelemetry tracing is not supported by our user-agent, the ID can switch from one to the other.
  • Field Details

  • Method Details

    • getCallerTraceParent

      public static String getCallerTraceParent()
      Provide traceId injected by client. If present our own request or conversation is derived from it.
      Returns:
      request client injected may be OpenTelemetry compliant traceId[.parentId]
    • getOwnTraceParent

      public static String getOwnTraceParent()
      Provide traceId for logging, error handling and backend propagation.
      Returns:
      request or conversation based own OpenTelemetry complaint traceId parent spanId
    • getOwnTraceParentForHttp

      public static String getOwnTraceParentForHttp()
      Provide OpenTelemetry compliant traceId for HTTP propagation to services.
      Returns:
      OpenTelemetry compliant HTTP traceparent header.
    • getOwnTraceParentForSaml

      public static String getOwnTraceParentForSaml()
      Provide SAML compliant traceId for propagation in own SAML messages. SAML compliant means: XML ID must start with a _ or character, RelayState max 80 characters.
      Returns:
      SAML compliant traceparent representation.
    • getOwnTraceParentForSaml

      public static String getOwnTraceParentForSaml(String tmpFedSession)
    • matchOwnTraceParentForSaml

      public static boolean matchOwnTraceParentForSaml(String lastMsgId, String firstMsgId)
    • getHttpTraceIdHeaderName

      public static String getHttpTraceIdHeaderName()
    • setHttpTraceIdHeaderName

      public static void setHttpTraceIdHeaderName(String newHttpHeaderLbTraceId)
    • setMdcTraceContext

      public static void setMdcTraceContext(jakarta.servlet.http.HttpServletRequest request)
    • setMdcTraceContext

      public static void setMdcTraceContext(String traceId)
    • clearMdcTraceContext

      public static void clearMdcTraceContext()
    • getClientIp

      public static String getClientIp()
    • getGatewayIp

      public static String getGatewayIp()
    • switchToConversation

      public static void switchToConversation(String messageId)
    • switchToConversationFromSamlId

      public static String switchToConversationFromSamlId(String messageId)