getCustomTracer static method
CoralogixCustomTracer?
getCustomTracer({
- List<
CoralogixIgnoredInstrument> ignoredInstruments = const [],
Returns a CoralogixCustomTracer when the SDK was initialized with
traceParentInHeader enabled (enable: true in that map). Mirrors the
browser SDK: returns null if trace context in headers is not enabled.
Only the first call's ignoredInstruments takes effect; later calls return the
originally-cached tracer (mirrors the native one-tracer-per-lifecycle constraint) and
log a warning if ignoredInstruments differs.
Implementation
static CoralogixCustomTracer? getCustomTracer({
List<CoralogixIgnoredInstrument> ignoredInstruments = const [],
}) {
final opts = _globalOptions;
if (opts == null) {
_cachedCustomTracer = null;
CustomSpanRegistry.setIgnoredInstruments(<CoralogixIgnoredInstrument>{});
return null;
}
final traceEnabled =
TraceParentInHeader.params(opts.traceParentInHeader).enable;
if (!traceEnabled) {
_cachedCustomTracer = null;
CustomSpanRegistry.setIgnoredInstruments(<CoralogixIgnoredInstrument>{});
return null;
}
final cached = _cachedCustomTracer;
if (cached != null) {
if (!setEquals(
cached._ignoredInstruments.toSet(),
ignoredInstruments.toSet(),
)) {
debugPrint(
'Coralogix RUM: getCustomTracer was already called with a different '
'ignoredInstruments set (${cached._ignoredInstruments}); the first call wins, '
'returning the cached tracer.',
);
}
return cached;
}
CustomSpanRegistry.setIgnoredInstruments(
Set<CoralogixIgnoredInstrument>.from(ignoredInstruments),
);
final tracer = CoralogixCustomTracer._(
List<CoralogixIgnoredInstrument>.unmodifiable(
List<CoralogixIgnoredInstrument>.from(ignoredInstruments),
),
);
_cachedCustomTracer = tracer;
return tracer;
}