Class EnvironmentGetter
java.lang.Object
io.opentelemetry.api.incubator.propagation.EnvironmentGetter
public final class EnvironmentGetter
extends Object
implements io.opentelemetry.context.propagation.TextMapGetter<Map<String,String>>
A
TextMapGetter that extracts context from a map carrier containing environment
variables.
This is useful when a child process extracts propagated context from environment variables that an application placed in the child process environment. For example:
Map<String, String> env = System.getenv();
Context context = contextPropagators.getTextMapPropagator()
.extract(Context.current(), env, EnvironmentGetter.getInstance());
This getter automatically normalizes keys as environment variable names:
- Replaces an empty key with a single underscore (
_) - Converts ASCII letters to uppercase (e.g.,
traceparentbecomesTRACEPARENT) - Replaces every character that is not an ASCII letter, digit, or underscore with an underscore
- Prepends an underscore if the result would otherwise start with an ASCII digit
Values are treated as opaque strings. Any propagation-format-specific validation or parsing is the responsibility of the propagator, not this carrier.
If the underlying carrier performs case-insensitive lookup, as Windows environment variable lookup does, reading a normalized key may resolve an entry whose stored name differs only by case.
- See Also:
-
Method Details
-
getInstance
Returns the singleton instance ofEnvironmentGetter. -
keys
-
get
-
toString
-