resolveTraceId static method
Returns the traceId to use for an outgoing network request.
Inherits the active custom span's traceId so the request appears on the same OTel trace — unless CoralogixIgnoredInstrument.networkRequests is in the current ignored set, in which case a fresh id is generated.
Implementation
static String resolveTraceId() {
final activeSpanId = CustomSpanRegistry.getActiveGlobalSpanId();
final activeTraceId = activeSpanId != null
? CustomSpanRegistry.getTraceId(activeSpanId)
: null;
final networkIgnored = CustomSpanRegistry.ignoredInstruments
.contains(CoralogixIgnoredInstrument.networkRequests);
return (!networkIgnored && activeTraceId != null)
? activeTraceId
: generateHex(32);
}