TelemetryContext¶
This docs was updated at: 2026-02-23
com.paragon.telemetry.TelemetryContext ยท Record
Context for telemetry events to add user metadata, tags, and custom attributes.
Used to enrich OpenTelemetry spans with additional context for vendors like Langfuse and Grafana.
Usage:
var context = TelemetryContext.builder()
.userId("user-123")
.traceName("chat.completion")
.addTag("production")
.addMetadata("version", "1.0")
.build();
responder.respond(payload, sessionId, context);
Methods¶
empty¶
Creates an empty telemetry context.
forUser¶
Creates a minimal context with just a user ID.
builder¶
Creates a new builder.
toAttributes¶
Returns all context data as OpenTelemetry attributes.
getTraceNameOrDefault¶
Returns the trace name or the default.
userId¶
Sets the user ID for telemetry correlation.
traceName¶
Sets the trace/span name.
parentTraceId¶
Sets the parent trace ID for distributed tracing.
parentSpanId¶
Sets the parent span ID for distributed tracing.
requestId¶
Sets the request ID for high-level correlation.
addMetadata¶
Adds a metadata key-value pair.
metadata¶
Adds all metadata from a map.
addTag¶
Adds a tag.
tags¶
Adds multiple tags.
build¶
Builds the TelemetryContext.