io.opentelemetry.javaagent.bootstrap.internal.ConfiguredResourceAttributesHolder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of opentelemetry-javaagent-extension-api Show documentation
Show all versions of opentelemetry-javaagent-extension-api Show documentation
Instrumentation of Java libraries using OpenTelemetry.
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.javaagent.bootstrap.internal;
import static io.opentelemetry.api.common.AttributeKey.stringKey;
import io.opentelemetry.api.common.Attributes;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
/**
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
* any time.
*/
public final class ConfiguredResourceAttributesHolder {
private static final Map resourceAttributes = new HashMap<>();
public static Map getResourceAttributes() {
return resourceAttributes;
}
public static void initialize(Attributes resourceAttribute) {
List mdcResourceAttributes =
AgentInstrumentationConfig.get()
.getList(
"otel.instrumentation.common.mdc.resource-attributes", Collections.emptyList());
for (String key : mdcResourceAttributes) {
String value = resourceAttribute.get(stringKey(key));
if (value != null) {
ConfiguredResourceAttributesHolder.resourceAttributes.put(key, value);
}
}
}
@Nullable
public static String getAttributeValue(String key) {
return resourceAttributes.get(key);
}
private ConfiguredResourceAttributesHolder() {}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy