-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathDistroResourceProvider.java
More file actions
33 lines (27 loc) · 1.11 KB
/
Copy pathDistroResourceProvider.java
File metadata and controls
33 lines (27 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.javaagent.tooling.resources;
import static io.opentelemetry.semconv.TelemetryAttributes.TELEMETRY_DISTRO_NAME;
import static io.opentelemetry.semconv.TelemetryAttributes.TELEMETRY_DISTRO_VERSION;
import com.google.auto.service.AutoService;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.javaagent.tooling.AgentVersion;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider;
import io.opentelemetry.sdk.resources.Resource;
@AutoService(ResourceProvider.class)
public class DistroResourceProvider implements ResourceProvider {
@Override
public Resource createResource(ConfigProperties config) {
return get("opentelemetry-java-instrumentation");
}
static Resource get(String distroName) {
return AgentVersion.VERSION == null
? Resource.empty()
: Resource.create(
Attributes.of(
TELEMETRY_DISTRO_NAME, distroName, TELEMETRY_DISTRO_VERSION, AgentVersion.VERSION));
}
}