2424import io .opentelemetry .sdk .autoconfigure .spi .ConfigProperties ;
2525import io .opentelemetry .sdk .autoconfigure .spi .ResourceProvider ;
2626import io .opentelemetry .sdk .resources .Resource ;
27- import io .opentelemetry .semconv .ResourceAttributes ;
27+ import io .opentelemetry .semconv .incubating .*;
28+
2829import java .util .Map ;
2930import java .util .Optional ;
3031import 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