Skip to content

Commit a0c8304

Browse files
committed
Update OpenTelemetry dependencies
(cherry picked from commit b7c0dc1)
1 parent c671829 commit a0c8304

14 files changed

Lines changed: 339 additions & 318 deletions

File tree

build.gradle

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,12 @@ subprojects {
160160
googleTraceVersion = '2.51.0'
161161
googleCloudBomVersion = '26.48.0'
162162
cloudMonitoringVersion = '3.52.0'
163-
openTelemetryBomVersion = '1.47.0'
164-
openTelemetryVersion = '1.47.0'
165-
openTelemetryInstrumentationBomVersion = '2.12.0'
166-
openTelemetryInstrumentationVersion = '2.12.0'
167-
openTelemetrySemconvVersion = '1.29.0'
168-
openTelemetryContribVersion = '1.44.0'
163+
openTelemetryBomVersion = '1.49.0'
164+
openTelemetryVersion = '1.49.0'
165+
openTelemetryInstrumentationBomVersion = '2.15.0'
166+
openTelemetryInstrumentationVersion = '2.15.0'
167+
openTelemetrySemconvVersion = '1.32.0'
168+
openTelemetryContribVersion = '1.46.0'
169169
junitVersion = '4.13'
170170
junit5Version = '5.10.0'
171171
mockitoVersion = '5.2.0'
@@ -204,7 +204,8 @@ subprojects {
204204
opentelemetry_context : "io.opentelemetry:opentelemetry-context:${openTelemetryVersion}",
205205
opentelemetry_sdk : "io.opentelemetry:opentelemetry-sdk:${openTelemetryVersion}",
206206
opentelemetry_sdk_common : "io.opentelemetry:opentelemetry-sdk-common:${openTelemetryVersion}",
207-
opentelemetry_semconv : "io.opentelemetry.semconv:opentelemetry-semconv:${openTelemetrySemconvVersion}-alpha",
207+
opentelemetry_semconv : "io.opentelemetry.semconv:opentelemetry-semconv:${openTelemetrySemconvVersion}",
208+
opentelemetry_semconv_incubating : "io.opentelemetry.semconv:opentelemetry-semconv-incubating:${openTelemetrySemconvVersion}-alpha",
208209
opentelemetry_sdk_metrics : "io.opentelemetry:opentelemetry-sdk-metrics:${openTelemetryVersion}",
209210
opentelemetry_sdk_autoconf : "io.opentelemetry:opentelemetry-sdk-extension-autoconfigure:${openTelemetryVersion}",
210211
opentelemetry_autoconfigure_spi : "io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi:${openTelemetryVersion}",

detectors/resources/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ dependencies {
2020
implementation(libraries.opentelemetry_sdk)
2121
implementation(libraries.opentelemetry_sdk_autoconf)
2222
implementation(libraries.opentelemetry_semconv)
23+
implementation(libraries.opentelemetry_semconv_incubating)
2324
implementation platform(libraries.opentelemetry_bom)
2425
implementation project(':detector-resources-support')
2526
testImplementation(testLibraries.junit5)

detectors/resources/src/main/java/com/google/cloud/opentelemetry/detectors/AttributesExtractorUtil.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
package com.google.cloud.opentelemetry.detectors;
1717

1818
import io.opentelemetry.api.common.AttributesBuilder;
19-
import io.opentelemetry.semconv.ResourceAttributes;
19+
import io.opentelemetry.semconv.incubating.CloudIncubatingAttributes;
20+
import io.opentelemetry.semconv.incubating.FaasIncubatingAttributes;
2021

2122
/**
2223
* A utility class that contains method that facilitate extraction of attributes from environment
2324
* variables and metadata configurations.
2425
*
25-
* <p>This class only adds helper methods to extract {@link ResourceAttributes} that are common
26+
* <p>This class only adds helper methods to extract {@link CloudIncubatingAttributes}
27+
* and {@link FaasIncubatingAttributes} that are common
2628
* across all the supported compute environments.
2729
*
2830
* @deprecated Not for public use. This class is expected to be retained only as package private.
@@ -37,7 +39,7 @@ public class AttributesExtractorUtil {
3739
*
3840
* <ul>
3941
* <li>If the availability zone cannot be found, calling this method has no effect.
40-
* <li>Calling this method will update {@link ResourceAttributes#CLOUD_AVAILABILITY_ZONE}
42+
* <li>Calling this method will update {@link CloudIncubatingAttributes#CLOUD_AVAILABILITY_ZONE}
4143
* attribute.
4244
* </ul>
4345
*
@@ -52,7 +54,7 @@ public static void addAvailabilityZoneFromMetadata(
5254
AttributesBuilder attributesBuilder, GCPMetadataConfig metadataConfig) {
5355
String zone = metadataConfig.getZone();
5456
if (zone != null) {
55-
attributesBuilder.put(ResourceAttributes.CLOUD_AVAILABILITY_ZONE, zone);
57+
attributesBuilder.put(CloudIncubatingAttributes.CLOUD_AVAILABILITY_ZONE, zone);
5658
}
5759
}
5860

@@ -62,7 +64,7 @@ public static void addAvailabilityZoneFromMetadata(
6264
*
6365
* <ul>
6466
* <li>If the cloud region cannot be found, calling this method has no effect.
65-
* <li>Calling this method will update {@link ResourceAttributes#CLOUD_REGION} attribute.
67+
* <li>Calling this method will update {@link CloudIncubatingAttributes#CLOUD_REGION} attribute.
6668
* <li>This method uses zone attribute to parse region from it.
6769
* </ul>
6870
*
@@ -80,7 +82,7 @@ public static void addCloudRegionFromMetadataUsingZone(
8082
// Parsing required to scope up to a region
8183
String[] splitArr = zone.split("-");
8284
if (splitArr.length > 2) {
83-
attributesBuilder.put(ResourceAttributes.CLOUD_REGION, splitArr[0] + "-" + splitArr[1]);
85+
attributesBuilder.put(CloudIncubatingAttributes.CLOUD_REGION, splitArr[0] + "-" + splitArr[1]);
8486
}
8587
}
8688
}
@@ -91,7 +93,7 @@ public static void addCloudRegionFromMetadataUsingZone(
9193
*
9294
* <ul>
9395
* <li>If the cloud region cannot be found, calling this method has no effect.
94-
* <li>Calling this method will update {@link ResourceAttributes#CLOUD_REGION} attribute.
96+
* <li>Calling this method will update {@link CloudIncubatingAttributes#CLOUD_REGION} attribute.
9597
* <li>This method directly uses the region attribute from the metadata config.
9698
* </ul>
9799
*
@@ -106,7 +108,7 @@ public static void addCloudRegionFromMetadataUsingRegion(
106108
AttributesBuilder attributesBuilder, GCPMetadataConfig metadataConfig) {
107109
String region = metadataConfig.getRegion();
108110
if (region != null) {
109-
attributesBuilder.put(ResourceAttributes.CLOUD_REGION, region);
111+
attributesBuilder.put(CloudIncubatingAttributes.CLOUD_REGION, region);
110112
}
111113
}
112114

@@ -117,7 +119,7 @@ public static void addCloudRegionFromMetadataUsingRegion(
117119
*
118120
* <ul>
119121
* <li>If the instance ID cannot be found, calling this method has no effect.
120-
* <li>Calling this method will update {@link ResourceAttributes#FAAS_INSTANCE} attribute.
122+
* <li>Calling this method will update {@link FaasIncubatingAttributes#FAAS_INSTANCE} attribute.
121123
* </ul>
122124
*
123125
* @param attributesBuilder The {@link AttributesBuilder} to which the extracted property needs to
@@ -129,7 +131,7 @@ public static void addInstanceIdFromMetadata(
129131
AttributesBuilder attributesBuilder, GCPMetadataConfig metadataConfig) {
130132
String instanceId = metadataConfig.getInstanceId();
131133
if (instanceId != null) {
132-
attributesBuilder.put(ResourceAttributes.FAAS_INSTANCE, instanceId);
134+
attributesBuilder.put(FaasIncubatingAttributes.FAAS_INSTANCE, instanceId);
133135
}
134136
}
135137
}

detectors/resources/src/main/java/com/google/cloud/opentelemetry/detectors/GCPResource.java

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
2525
import io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider;
2626
import io.opentelemetry.sdk.resources.Resource;
27-
import io.opentelemetry.semconv.ResourceAttributes;
27+
import io.opentelemetry.semconv.incubating.*;
28+
2829
import java.util.Map;
2930
import java.util.Optional;
3031
import java.util.logging.Logger;
@@ -68,8 +69,8 @@ public Attributes getAttributes() {
6869

6970
// This is running on some sort of GCPCompute - figure out the platform
7071
AttributesBuilder attrBuilder = Attributes.builder();
71-
attrBuilder.put(ResourceAttributes.CLOUD_PROVIDER, ResourceAttributes.CloudProviderValues.GCP);
72-
attrBuilder.put(ResourceAttributes.CLOUD_ACCOUNT_ID, detectedPlatform.getProjectId());
72+
attrBuilder.put(CloudIncubatingAttributes.CLOUD_PROVIDER, CloudIncubatingAttributes.CloudProviderIncubatingValues.GCP);
73+
attrBuilder.put(CloudIncubatingAttributes.CLOUD_ACCOUNT_ID, detectedPlatform.getProjectId());
7374

7475
switch (detectedPlatform.getSupportedPlatform()) {
7576
case GOOGLE_KUBERNETES_ENGINE:
@@ -107,27 +108,27 @@ public Resource createResource(ConfigProperties config) {
107108
*/
108109
private void addGCEAttributes(AttributesBuilder attrBuilder, Map<String, String> attributesMap) {
109110
attrBuilder.put(
110-
ResourceAttributes.CLOUD_PLATFORM,
111-
ResourceAttributes.CloudPlatformValues.GCP_COMPUTE_ENGINE);
111+
CloudIncubatingAttributes.CLOUD_PLATFORM,
112+
CloudIncubatingAttributes.CloudPlatformIncubatingValues.GCP_COMPUTE_ENGINE);
112113

113114
Optional.ofNullable(attributesMap.get(GCE_AVAILABILITY_ZONE))
114-
.ifPresent(zone -> attrBuilder.put(ResourceAttributes.CLOUD_AVAILABILITY_ZONE, zone));
115+
.ifPresent(zone -> attrBuilder.put(CloudIncubatingAttributes.CLOUD_AVAILABILITY_ZONE, zone));
115116
Optional.ofNullable(attributesMap.get(GCE_CLOUD_REGION))
116-
.ifPresent(region -> attrBuilder.put(ResourceAttributes.CLOUD_REGION, region));
117+
.ifPresent(region -> attrBuilder.put(CloudIncubatingAttributes.CLOUD_REGION, region));
117118
Optional.ofNullable(attributesMap.get(GCE_INSTANCE_ID))
118-
.ifPresent(instanceId -> attrBuilder.put(ResourceAttributes.HOST_ID, instanceId));
119+
.ifPresent(instanceId -> attrBuilder.put(HostIncubatingAttributes.HOST_ID, instanceId));
119120
Optional.ofNullable(attributesMap.get(GCE_INSTANCE_NAME))
120121
.ifPresent(
121122
instanceName -> {
122-
attrBuilder.put(ResourceAttributes.HOST_NAME, instanceName);
123-
attrBuilder.put(ResourceAttributes.GCP_GCE_INSTANCE_NAME, instanceName);
123+
attrBuilder.put(HostIncubatingAttributes.HOST_NAME, instanceName);
124+
attrBuilder.put(GcpIncubatingAttributes.GCP_GCE_INSTANCE_NAME, instanceName);
124125
});
125126
Optional.ofNullable(attributesMap.get(GCE_INSTANCE_HOSTNAME))
126127
.ifPresent(
127128
instanceHostname ->
128-
attrBuilder.put(ResourceAttributes.GCP_GCE_INSTANCE_HOSTNAME, instanceHostname));
129+
attrBuilder.put(GcpIncubatingAttributes.GCP_GCE_INSTANCE_HOSTNAME, instanceHostname));
129130
Optional.ofNullable(attributesMap.get(GCE_MACHINE_TYPE))
130-
.ifPresent(machineType -> attrBuilder.put(ResourceAttributes.HOST_TYPE, machineType));
131+
.ifPresent(machineType -> attrBuilder.put(HostIncubatingAttributes.HOST_TYPE, machineType));
131132
}
132133

133134
/**
@@ -139,26 +140,26 @@ private void addGCEAttributes(AttributesBuilder attrBuilder, Map<String, String>
139140
*/
140141
private void addGKEAttributes(AttributesBuilder attrBuilder, Map<String, String> attributesMap) {
141142
attrBuilder.put(
142-
ResourceAttributes.CLOUD_PLATFORM,
143-
ResourceAttributes.CloudPlatformValues.GCP_KUBERNETES_ENGINE);
143+
CloudIncubatingAttributes.CLOUD_PLATFORM,
144+
CloudIncubatingAttributes.CloudPlatformIncubatingValues.GCP_KUBERNETES_ENGINE);
144145

145146
Optional.ofNullable(attributesMap.get(GKE_CLUSTER_NAME))
146147
.ifPresent(
147-
clusterName -> attrBuilder.put(ResourceAttributes.K8S_CLUSTER_NAME, clusterName));
148+
clusterName -> attrBuilder.put(K8sIncubatingAttributes.K8S_CLUSTER_NAME, clusterName));
148149
Optional.ofNullable(attributesMap.get(GKE_HOST_ID))
149-
.ifPresent(hostId -> attrBuilder.put(ResourceAttributes.HOST_ID, hostId));
150+
.ifPresent(hostId -> attrBuilder.put(HostIncubatingAttributes.HOST_ID, hostId));
150151
Optional.ofNullable(attributesMap.get(GKE_CLUSTER_LOCATION_TYPE))
151152
.ifPresent(
152153
locationType -> {
153154
if (attributesMap.get(GKE_CLUSTER_LOCATION) != null) {
154155
switch (locationType) {
155156
case GKE_LOCATION_TYPE_REGION:
156157
attrBuilder.put(
157-
ResourceAttributes.CLOUD_REGION, attributesMap.get(GKE_CLUSTER_LOCATION));
158+
CloudIncubatingAttributes.CLOUD_REGION, attributesMap.get(GKE_CLUSTER_LOCATION));
158159
break;
159160
case GKE_LOCATION_TYPE_ZONE:
160161
attrBuilder.put(
161-
ResourceAttributes.CLOUD_AVAILABILITY_ZONE,
162+
CloudIncubatingAttributes.CLOUD_AVAILABILITY_ZONE,
162163
attributesMap.get(GKE_CLUSTER_LOCATION));
163164
default:
164165
// TODO: Figure out how to handle unexpected conditions like this - Issue #183
@@ -180,7 +181,7 @@ private void addGKEAttributes(AttributesBuilder attrBuilder, Map<String, String>
180181
*/
181182
private void addGCRAttributes(AttributesBuilder attrBuilder, Map<String, String> attributesMap) {
182183
attrBuilder.put(
183-
ResourceAttributes.CLOUD_PLATFORM, ResourceAttributes.CloudPlatformValues.GCP_CLOUD_RUN);
184+
CloudIncubatingAttributes.CLOUD_PLATFORM, CloudIncubatingAttributes.CloudPlatformIncubatingValues.GCP_CLOUD_RUN);
184185
addCommonAttributesForServerlessCompute(attrBuilder, attributesMap);
185186
}
186187

@@ -193,8 +194,8 @@ private void addGCRAttributes(AttributesBuilder attrBuilder, Map<String, String>
193194
*/
194195
private void addGCFAttributes(AttributesBuilder attrBuilder, Map<String, String> attributesMap) {
195196
attrBuilder.put(
196-
ResourceAttributes.CLOUD_PLATFORM,
197-
ResourceAttributes.CloudPlatformValues.GCP_CLOUD_FUNCTIONS);
197+
CloudIncubatingAttributes.CLOUD_PLATFORM,
198+
CloudIncubatingAttributes.CloudPlatformIncubatingValues.GCP_CLOUD_FUNCTIONS);
198199
addCommonAttributesForServerlessCompute(attrBuilder, attributesMap);
199200
}
200201

@@ -207,20 +208,20 @@ private void addGCFAttributes(AttributesBuilder attrBuilder, Map<String, String>
207208
*/
208209
private void addGAEAttributes(AttributesBuilder attrBuilder, Map<String, String> attributesMap) {
209210
attrBuilder.put(
210-
ResourceAttributes.CLOUD_PLATFORM, ResourceAttributes.CloudPlatformValues.GCP_APP_ENGINE);
211+
CloudIncubatingAttributes.CLOUD_PLATFORM, CloudIncubatingAttributes.CloudPlatformIncubatingValues.GCP_APP_ENGINE);
211212
Optional.ofNullable(attributesMap.get(GAE_MODULE_NAME))
212-
.ifPresent(appName -> attrBuilder.put(ResourceAttributes.FAAS_NAME, appName));
213+
.ifPresent(appName -> attrBuilder.put(FaasIncubatingAttributes.FAAS_NAME, appName));
213214
Optional.ofNullable(attributesMap.get(GAE_APP_VERSION))
214-
.ifPresent(appVersion -> attrBuilder.put(ResourceAttributes.FAAS_VERSION, appVersion));
215+
.ifPresent(appVersion -> attrBuilder.put(FaasIncubatingAttributes.FAAS_VERSION, appVersion));
215216
Optional.ofNullable(attributesMap.get(GAE_INSTANCE_ID))
216217
.ifPresent(
217-
appInstanceId -> attrBuilder.put(ResourceAttributes.FAAS_INSTANCE, appInstanceId));
218+
appInstanceId -> attrBuilder.put(FaasIncubatingAttributes.FAAS_INSTANCE, appInstanceId));
218219
Optional.ofNullable(attributesMap.get(GAE_CLOUD_REGION))
219-
.ifPresent(cloudRegion -> attrBuilder.put(ResourceAttributes.CLOUD_REGION, cloudRegion));
220+
.ifPresent(cloudRegion -> attrBuilder.put(CloudIncubatingAttributes.CLOUD_REGION, cloudRegion));
220221
Optional.ofNullable(attributesMap.get(GAE_AVAILABILITY_ZONE))
221222
.ifPresent(
222223
cloudAvailabilityZone ->
223-
attrBuilder.put(ResourceAttributes.CLOUD_AVAILABILITY_ZONE, cloudAvailabilityZone));
224+
attrBuilder.put(CloudIncubatingAttributes.CLOUD_AVAILABILITY_ZONE, cloudAvailabilityZone));
224225
}
225226

226227
/**
@@ -233,14 +234,14 @@ private void addGAEAttributes(AttributesBuilder attrBuilder, Map<String, String>
233234
private void addCommonAttributesForServerlessCompute(
234235
AttributesBuilder attrBuilder, Map<String, String> attributesMap) {
235236
Optional.ofNullable(attributesMap.get(SERVERLESS_COMPUTE_NAME))
236-
.ifPresent(name -> attrBuilder.put(ResourceAttributes.FAAS_NAME, name));
237+
.ifPresent(name -> attrBuilder.put(FaasIncubatingAttributes.FAAS_NAME, name));
237238
Optional.ofNullable(attributesMap.get(SERVERLESS_COMPUTE_REVISION))
238-
.ifPresent(revision -> attrBuilder.put(ResourceAttributes.FAAS_VERSION, revision));
239+
.ifPresent(revision -> attrBuilder.put(FaasIncubatingAttributes.FAAS_VERSION, revision));
239240
Optional.ofNullable(attributesMap.get(SERVERLESS_COMPUTE_INSTANCE_ID))
240-
.ifPresent(instanceId -> attrBuilder.put(ResourceAttributes.FAAS_INSTANCE, instanceId));
241+
.ifPresent(instanceId -> attrBuilder.put(FaasIncubatingAttributes.FAAS_INSTANCE, instanceId));
241242
Optional.ofNullable(attributesMap.get(SERVERLESS_COMPUTE_AVAILABILITY_ZONE))
242-
.ifPresent(zone -> attrBuilder.put(ResourceAttributes.CLOUD_AVAILABILITY_ZONE, zone));
243+
.ifPresent(zone -> attrBuilder.put(CloudIncubatingAttributes.CLOUD_AVAILABILITY_ZONE, zone));
243244
Optional.ofNullable(attributesMap.get(SERVERLESS_COMPUTE_CLOUD_REGION))
244-
.ifPresent(region -> attrBuilder.put(ResourceAttributes.CLOUD_REGION, region));
245+
.ifPresent(region -> attrBuilder.put(CloudIncubatingAttributes.CLOUD_REGION, region));
245246
}
246247
}

0 commit comments

Comments
 (0)