All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.microsoft.azure.functions.opentelemetry.TraceContextTextMapGetter Maven / Gradle / Ivy

Go to download

This package contains classes/interfaces for advanced SDK-based type bindings for Azure Functions Java Worker.

The newest version!
package com.microsoft.azure.functions.opentelemetry;

import com.microsoft.azure.functions.TraceContext;
import io.opentelemetry.context.propagation.TextMapGetter;

/**
 * A singleton {@link TextMapGetter} that adapts an Azure Functions
 * {@link TraceContext} to OpenTelemetry’s propagation API.
 *
 * 

Implementation is deliberately allocation-free: * the enum constant {@link #INSTANCE} is reused for every extraction call.

*/ public enum TraceContextTextMapGetter implements TextMapGetter { /** The single shared instance. */ INSTANCE; @Override public Iterable keys(final TraceContext carrier) { return carrier.getAttributes().keySet(); } @Override public String get(final TraceContext carrier, final String key) { if (carrier == null || key == null) { return null; } // Match W3C header names first if ("traceparent".equalsIgnoreCase(key)) { return carrier.getTraceparent(); } if ("tracestate".equalsIgnoreCase(key)) { return carrier.getTracestate(); } // Fallback to custom attributes return carrier.getAttributes().get(key); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy