Package swiss.trustbroker.common.tracing
Class TraceSupport
java.lang.Object
swiss.trustbroker.common.tracing.TraceSupport
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
- 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
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidstatic StringProvide traceId injected by client.static Stringstatic Stringstatic Stringstatic StringProvide traceId for logging, error handling and backend propagation.static StringProvide OpenTelemetry compliant traceId for HTTP propagation to services.static StringProvide SAML compliant traceId for propagation in own SAML messages.static StringgetOwnTraceParentForSaml(String tmpFedSession) static booleanmatchOwnTraceParentForSaml(String lastMsgId, String firstMsgId) static voidsetHttpTraceIdHeaderName(String newHttpHeaderLbTraceId) static voidsetMdcTraceContext(jakarta.servlet.http.HttpServletRequest request) static voidsetMdcTraceContext(String traceId) static voidswitchToConversation(String messageId) static StringswitchToConversationFromSamlId(String messageId)
-
Field Details
-
XTB_CLIENTIP
- See Also:
-
XTB_GATEWAYIP
- See Also:
-
HTTP_REQUEST_ID
- See Also:
-
W3C_TRACEPARENT
- See Also:
-
XTB_TRACEID
- See Also:
-
-
Method Details
-
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
Provide traceId for logging, error handling and backend propagation.- Returns:
- request or conversation based own OpenTelemetry complaint traceId parent spanId
-
getOwnTraceParentForHttp
Provide OpenTelemetry compliant traceId for HTTP propagation to services.- Returns:
- OpenTelemetry compliant HTTP traceparent header.
-
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
-
matchOwnTraceParentForSaml
-
getHttpTraceIdHeaderName
-
setHttpTraceIdHeaderName
-
setMdcTraceContext
public static void setMdcTraceContext(jakarta.servlet.http.HttpServletRequest request) -
setMdcTraceContext
-
clearMdcTraceContext
public static void clearMdcTraceContext() -
getClientIp
-
getGatewayIp
-
switchToConversation
-
switchToConversationFromSamlId
-