Skip to content

Commit 947aca7

Browse files
authored
semconv 1.41.0 update (#1093)
* make semconv version in catalog have priority over upstream * migreate to stable telemetry semconv * deployment.environment.name is now stable * add changelog entry * spotless
1 parent 3039d25 commit 947aca7

10 files changed

Lines changed: 42 additions & 55 deletions

File tree

buildSrc/src/main/kotlin/elastic-otel.java-conventions.gradle.kts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ repositories {
1919

2020
//https://github.com/gradle/gradle/issues/15383
2121
val catalog = extensions.getByType<VersionCatalogsExtension>().named("catalog")
22+
23+
configurations.all {
24+
resolutionStrategy {
25+
// Force the semconv version to be the one we explicitly set into version catalog and override
26+
// the upstream version, hence allowing to use a different version than upstream.
27+
force(
28+
"io.opentelemetry.semconv:opentelemetry-semconv:${catalog.findVersion("opentelemetrySemconv").get()}",
29+
"io.opentelemetry.semconv:opentelemetry-semconv-incubating:${catalog.findVersion("opentelemetrySemconvAlpha").get()}"
30+
)
31+
}
32+
}
33+
2234
dependencies {
2335

2436
implementation(platform(catalog.findLibrary("opentelemetryInstrumentationAlphaBom").get()))

custom/src/main/java/co/elastic/otel/ElasticAutoConfigurationCustomizerProvider.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*/
1919
package co.elastic.otel;
2020

21+
import static io.opentelemetry.semconv.DeploymentAttributes.DEPLOYMENT_ENVIRONMENT_NAME;
22+
2123
import co.elastic.otel.config.ConfigLoggingAgentListener;
2224
import co.elastic.otel.dynamicconfig.BlockableLogRecordExporter;
2325
import co.elastic.otel.dynamicconfig.BlockableMetricExporter;
@@ -59,8 +61,6 @@ public class ElasticAutoConfigurationCustomizerProvider
5961

6062
private static final AttributeKey<String> DEPLOYMENT_LEGACY =
6163
AttributeKey.stringKey("deployment.environment");
62-
private static final AttributeKey<String> DEPLOYMENT =
63-
AttributeKey.stringKey("deployment.environment.name");
6464
private static final String OTEL_JAVAAGENT_EXPERIMENTAL_INDY = "otel.javaagent.experimental.indy";
6565

6666
@Override
@@ -118,8 +118,8 @@ static BiFunction<Resource, ConfigProperties, Resource> resourceProviders() {
118118

119119
// duplicate deprecated deployment.environment to deployment.environment.name as a convenience
120120
String deploymentLegacy = resource.getAttribute(DEPLOYMENT_LEGACY);
121-
if (deploymentLegacy != null && resource.getAttribute(DEPLOYMENT) == null) {
122-
resource = resource.toBuilder().put(DEPLOYMENT, deploymentLegacy).build();
121+
if (deploymentLegacy != null && resource.getAttribute(DEPLOYMENT_ENVIRONMENT_NAME) == null) {
122+
resource = resource.toBuilder().put(DEPLOYMENT_ENVIRONMENT_NAME, deploymentLegacy).build();
123123
}
124124

125125
return resource;

custom/src/main/java/co/elastic/otel/ElasticDistroResource.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import io.opentelemetry.api.common.Attributes;
2222
import io.opentelemetry.javaagent.tooling.AgentVersion;
2323
import io.opentelemetry.sdk.resources.Resource;
24-
import io.opentelemetry.semconv.incubating.TelemetryIncubatingAttributes;
24+
import io.opentelemetry.semconv.TelemetryAttributes;
2525

2626
public class ElasticDistroResource {
2727

@@ -40,9 +40,9 @@ public static Resource get() {
4040
}
4141
return Resource.create(
4242
Attributes.of(
43-
TelemetryIncubatingAttributes.TELEMETRY_DISTRO_NAME,
43+
TelemetryAttributes.TELEMETRY_DISTRO_NAME,
4444
"elastic",
45-
TelemetryIncubatingAttributes.TELEMETRY_DISTRO_VERSION,
45+
TelemetryAttributes.TELEMETRY_DISTRO_VERSION,
4646
AgentVersion.VERSION));
4747
}
4848
}

custom/src/main/java/co/elastic/otel/dynamicconfig/CentralConfig.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*/
1919
package co.elastic.otel.dynamicconfig;
2020

21+
import static io.opentelemetry.semconv.DeploymentAttributes.DEPLOYMENT_ENVIRONMENT_NAME;
22+
2123
import co.elastic.otel.compositesampling.DynamicCompositeParentBasedTraceIdRatioBasedSampler;
2224
import co.elastic.otel.config.ConfigLoggingAgentListener;
2325
import co.elastic.otel.dynamicconfig.internal.OpampManager;
@@ -138,7 +140,7 @@ static String getServiceName(ConfigProperties properties) {
138140
@Nullable
139141
static String getServiceEnvironment(ConfigProperties properties) {
140142
Map<String, String> resourceMap = properties.getMap("otel.resource.attributes");
141-
String environment = resourceMap.get("deployment.environment.name"); // semconv
143+
String environment = resourceMap.get(DEPLOYMENT_ENVIRONMENT_NAME.getKey());
142144
if (environment != null) {
143145
return environment;
144146
}

custom/src/main/java/co/elastic/otel/dynamicconfig/internal/OpampManager.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*/
1919
package co.elastic.otel.dynamicconfig.internal;
2020

21+
import static io.opentelemetry.semconv.DeploymentAttributes.DEPLOYMENT_ENVIRONMENT_NAME;
22+
2123
import com.dslplatform.json.DslJson;
2224
import com.dslplatform.json.JsonReader;
2325
import com.dslplatform.json.MapConverter;
@@ -85,7 +87,8 @@ public void start(CentralConfigurationProcessor processor) {
8587
builder.putIdentifyingAttribute("service.name", configuration.serviceName);
8688
}
8789
if (configuration.environment != null) {
88-
builder.putIdentifyingAttribute("deployment.environment.name", configuration.environment);
90+
builder.putIdentifyingAttribute(
91+
DEPLOYMENT_ENVIRONMENT_NAME.getKey(), configuration.environment);
8992
}
9093
PeriodicDelay retryDelay = RetryPeriodicDelay.create(configuration.pollingInterval);
9194
builder.setRequestService(HttpRequestService.create(httpSender, pollingDelay, retryDelay));

custom/src/test/java/co/elastic/otel/SemconvTest.java

Lines changed: 0 additions & 37 deletions
This file was deleted.

docs/changelog/1093.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
prs:
2+
- "1093"
3+
type: enhancement
4+
products:
5+
- product: edot-java
6+
lifecycle: ga
7+
title: semconv 1.41.0 update

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ opentelemetryContribAlpha = "1.55.0-alpha"
2121
# updated from upstream agent with .ci/update-upstream.sh
2222
# While the semconv stable/incubating artifacts are provided as transitive dependencies, keeping
2323
# an explicit version here allows to easily override to a not-yet-released version.
24-
opentelemetrySemconv = "1.40.0"
25-
opentelemetrySemconvAlpha = "1.40.0-alpha"
24+
opentelemetrySemconv = "1.41.0"
25+
opentelemetrySemconvAlpha = "1.41.0-alpha"
2626

2727
[libraries]
2828

smoke-tests/src/test/java/com/example/javaagent/smoketest/DeclarativeConfigSmokeTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020

2121
import static io.opentelemetry.semconv.ServiceAttributes.SERVICE_INSTANCE_ID;
2222
import static io.opentelemetry.semconv.ServiceAttributes.SERVICE_NAME;
23+
import static io.opentelemetry.semconv.TelemetryAttributes.TELEMETRY_DISTRO_NAME;
24+
import static io.opentelemetry.semconv.TelemetryAttributes.TELEMETRY_DISTRO_VERSION;
2325
import static io.opentelemetry.semconv.incubating.ContainerIncubatingAttributes.CONTAINER_ID;
2426
import static io.opentelemetry.semconv.incubating.HostIncubatingAttributes.HOST_ARCH;
2527
import static io.opentelemetry.semconv.incubating.HostIncubatingAttributes.HOST_NAME;
2628
import static io.opentelemetry.semconv.incubating.OsIncubatingAttributes.OS_TYPE;
2729
import static io.opentelemetry.semconv.incubating.OsIncubatingAttributes.OS_VERSION;
2830
import static io.opentelemetry.semconv.incubating.ProcessIncubatingAttributes.PROCESS_COMMAND_ARGS;
2931
import static io.opentelemetry.semconv.incubating.ProcessIncubatingAttributes.PROCESS_PID;
30-
import static io.opentelemetry.semconv.incubating.TelemetryIncubatingAttributes.TELEMETRY_DISTRO_NAME;
31-
import static io.opentelemetry.semconv.incubating.TelemetryIncubatingAttributes.TELEMETRY_DISTRO_VERSION;
3232
import static org.assertj.core.api.Assertions.assertThat;
3333
import static org.assertj.core.api.Assertions.tuple;
3434

testing/integration-tests/agent-internals/src/test/java/DistroResourceAttributesTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import io.opentelemetry.api.trace.Span;
2323
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
2424
import io.opentelemetry.sdk.resources.Resource;
25-
import io.opentelemetry.semconv.incubating.TelemetryIncubatingAttributes;
25+
import io.opentelemetry.semconv.TelemetryAttributes;
2626
import org.junit.jupiter.api.Test;
2727
import org.junit.jupiter.api.extension.RegisterExtension;
2828

@@ -43,16 +43,16 @@ public void checkDistroName() {
4343

4444
if (isRunningDistro) {
4545
assertThat(resource.getAttributes())
46-
.containsEntry(TelemetryIncubatingAttributes.TELEMETRY_DISTRO_NAME, "elastic");
46+
.containsEntry(TelemetryAttributes.TELEMETRY_DISTRO_NAME, "elastic");
4747
assertThat(resource.getAttributes())
48-
.containsKey(TelemetryIncubatingAttributes.TELEMETRY_DISTRO_VERSION);
48+
.containsKey(TelemetryAttributes.TELEMETRY_DISTRO_VERSION);
4949
} else {
5050
// we are running with the vanilla agent as extension: we should not be setting the distro
5151
// name
5252
assertThat(resource.getAttributes())
53-
.doesNotContainKey(TelemetryIncubatingAttributes.TELEMETRY_DISTRO_NAME);
53+
.doesNotContainKey(TelemetryAttributes.TELEMETRY_DISTRO_NAME);
5454
assertThat(resource.getAttributes())
55-
.doesNotContainKey(TelemetryIncubatingAttributes.TELEMETRY_DISTRO_VERSION);
55+
.doesNotContainKey(TelemetryAttributes.TELEMETRY_DISTRO_VERSION);
5656
}
5757
}
5858
}

0 commit comments

Comments
 (0)