buildCustomSpanNetworkContext static method

Map<String, String> buildCustomSpanNetworkContext()

Returns hybrid-network linkage fields for native SDK consumption.

Adds customTraceId and customSpanId only when there is an active global custom span in the current zone and network instrumentation is not ignored.

Implementation

static Map<String, String> buildCustomSpanNetworkContext() {
  final activeSpanId = CustomSpanRegistry.getActiveGlobalSpanId();
  if (activeSpanId == null || activeSpanId.isEmpty) return const {};

  final networkIgnored = CustomSpanRegistry.ignoredInstruments
      .contains(CoralogixIgnoredInstrument.networkRequests);
  if (networkIgnored) return const {};

  final activeTraceId = CustomSpanRegistry.getTraceId(activeSpanId);
  if (activeTraceId == null || activeTraceId.isEmpty) return const {};

  return <String, String>{
    'customTraceId': activeTraceId,
    'customSpanId': activeSpanId,
  };
}