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 .CloudIncubatingAttributes ;
28+ import io .opentelemetry .semconv .incubating .FaasIncubatingAttributes ;
29+ import io .opentelemetry .semconv .incubating .GcpIncubatingAttributes ;
30+ import io .opentelemetry .semconv .incubating .HostIncubatingAttributes ;
31+ import io .opentelemetry .semconv .incubating .K8sIncubatingAttributes ;
2832import java .util .Map ;
2933import java .util .Optional ;
3034import java .util .logging .Logger ;
@@ -68,8 +72,10 @@ public Attributes getAttributes() {
6872
6973 // This is running on some sort of GCPCompute - figure out the platform
7074 AttributesBuilder attrBuilder = Attributes .builder ();
71- attrBuilder .put (ResourceAttributes .CLOUD_PROVIDER , ResourceAttributes .CloudProviderValues .GCP );
72- attrBuilder .put (ResourceAttributes .CLOUD_ACCOUNT_ID , detectedPlatform .getProjectId ());
75+ attrBuilder .put (
76+ CloudIncubatingAttributes .CLOUD_PROVIDER ,
77+ CloudIncubatingAttributes .CloudProviderIncubatingValues .GCP );
78+ attrBuilder .put (CloudIncubatingAttributes .CLOUD_ACCOUNT_ID , detectedPlatform .getProjectId ());
7379
7480 switch (detectedPlatform .getSupportedPlatform ()) {
7581 case GOOGLE_KUBERNETES_ENGINE :
@@ -107,27 +113,29 @@ public Resource createResource(ConfigProperties config) {
107113 */
108114 private void addGCEAttributes (AttributesBuilder attrBuilder , Map <String , String > attributesMap ) {
109115 attrBuilder .put (
110- ResourceAttributes .CLOUD_PLATFORM ,
111- ResourceAttributes . CloudPlatformValues .GCP_COMPUTE_ENGINE );
116+ CloudIncubatingAttributes .CLOUD_PLATFORM ,
117+ CloudIncubatingAttributes . CloudPlatformIncubatingValues .GCP_COMPUTE_ENGINE );
112118
113119 Optional .ofNullable (attributesMap .get (GCE_AVAILABILITY_ZONE ))
114- .ifPresent (zone -> attrBuilder .put (ResourceAttributes .CLOUD_AVAILABILITY_ZONE , zone ));
120+ .ifPresent (
121+ zone -> attrBuilder .put (CloudIncubatingAttributes .CLOUD_AVAILABILITY_ZONE , zone ));
115122 Optional .ofNullable (attributesMap .get (GCE_CLOUD_REGION ))
116- .ifPresent (region -> attrBuilder .put (ResourceAttributes .CLOUD_REGION , region ));
123+ .ifPresent (region -> attrBuilder .put (CloudIncubatingAttributes .CLOUD_REGION , region ));
117124 Optional .ofNullable (attributesMap .get (GCE_INSTANCE_ID ))
118- .ifPresent (instanceId -> attrBuilder .put (ResourceAttributes .HOST_ID , instanceId ));
125+ .ifPresent (instanceId -> attrBuilder .put (HostIncubatingAttributes .HOST_ID , instanceId ));
119126 Optional .ofNullable (attributesMap .get (GCE_INSTANCE_NAME ))
120127 .ifPresent (
121128 instanceName -> {
122- attrBuilder .put (ResourceAttributes .HOST_NAME , instanceName );
123- attrBuilder .put (ResourceAttributes .GCP_GCE_INSTANCE_NAME , instanceName );
129+ attrBuilder .put (HostIncubatingAttributes .HOST_NAME , instanceName );
130+ attrBuilder .put (GcpIncubatingAttributes .GCP_GCE_INSTANCE_NAME , instanceName );
124131 });
125132 Optional .ofNullable (attributesMap .get (GCE_INSTANCE_HOSTNAME ))
126133 .ifPresent (
127134 instanceHostname ->
128- attrBuilder .put (ResourceAttributes .GCP_GCE_INSTANCE_HOSTNAME , instanceHostname ));
135+ attrBuilder .put (
136+ GcpIncubatingAttributes .GCP_GCE_INSTANCE_HOSTNAME , instanceHostname ));
129137 Optional .ofNullable (attributesMap .get (GCE_MACHINE_TYPE ))
130- .ifPresent (machineType -> attrBuilder .put (ResourceAttributes .HOST_TYPE , machineType ));
138+ .ifPresent (machineType -> attrBuilder .put (HostIncubatingAttributes .HOST_TYPE , machineType ));
131139 }
132140
133141 /**
@@ -139,26 +147,27 @@ private void addGCEAttributes(AttributesBuilder attrBuilder, Map<String, String>
139147 */
140148 private void addGKEAttributes (AttributesBuilder attrBuilder , Map <String , String > attributesMap ) {
141149 attrBuilder .put (
142- ResourceAttributes .CLOUD_PLATFORM ,
143- ResourceAttributes . CloudPlatformValues .GCP_KUBERNETES_ENGINE );
150+ CloudIncubatingAttributes .CLOUD_PLATFORM ,
151+ CloudIncubatingAttributes . CloudPlatformIncubatingValues .GCP_KUBERNETES_ENGINE );
144152
145153 Optional .ofNullable (attributesMap .get (GKE_CLUSTER_NAME ))
146154 .ifPresent (
147- clusterName -> attrBuilder .put (ResourceAttributes .K8S_CLUSTER_NAME , clusterName ));
155+ clusterName -> attrBuilder .put (K8sIncubatingAttributes .K8S_CLUSTER_NAME , clusterName ));
148156 Optional .ofNullable (attributesMap .get (GKE_HOST_ID ))
149- .ifPresent (hostId -> attrBuilder .put (ResourceAttributes .HOST_ID , hostId ));
157+ .ifPresent (hostId -> attrBuilder .put (HostIncubatingAttributes .HOST_ID , hostId ));
150158 Optional .ofNullable (attributesMap .get (GKE_CLUSTER_LOCATION_TYPE ))
151159 .ifPresent (
152160 locationType -> {
153161 if (attributesMap .get (GKE_CLUSTER_LOCATION ) != null ) {
154162 switch (locationType ) {
155163 case GKE_LOCATION_TYPE_REGION :
156164 attrBuilder .put (
157- ResourceAttributes .CLOUD_REGION , attributesMap .get (GKE_CLUSTER_LOCATION ));
165+ CloudIncubatingAttributes .CLOUD_REGION ,
166+ attributesMap .get (GKE_CLUSTER_LOCATION ));
158167 break ;
159168 case GKE_LOCATION_TYPE_ZONE :
160169 attrBuilder .put (
161- ResourceAttributes .CLOUD_AVAILABILITY_ZONE ,
170+ CloudIncubatingAttributes .CLOUD_AVAILABILITY_ZONE ,
162171 attributesMap .get (GKE_CLUSTER_LOCATION ));
163172 default :
164173 // TODO: Figure out how to handle unexpected conditions like this - Issue #183
@@ -180,7 +189,8 @@ private void addGKEAttributes(AttributesBuilder attrBuilder, Map<String, String>
180189 */
181190 private void addGCRAttributes (AttributesBuilder attrBuilder , Map <String , String > attributesMap ) {
182191 attrBuilder .put (
183- ResourceAttributes .CLOUD_PLATFORM , ResourceAttributes .CloudPlatformValues .GCP_CLOUD_RUN );
192+ CloudIncubatingAttributes .CLOUD_PLATFORM ,
193+ CloudIncubatingAttributes .CloudPlatformIncubatingValues .GCP_CLOUD_RUN );
184194 addCommonAttributesForServerlessCompute (attrBuilder , attributesMap );
185195 }
186196
@@ -193,8 +203,8 @@ private void addGCRAttributes(AttributesBuilder attrBuilder, Map<String, String>
193203 */
194204 private void addGCFAttributes (AttributesBuilder attrBuilder , Map <String , String > attributesMap ) {
195205 attrBuilder .put (
196- ResourceAttributes .CLOUD_PLATFORM ,
197- ResourceAttributes . CloudPlatformValues .GCP_CLOUD_FUNCTIONS );
206+ CloudIncubatingAttributes .CLOUD_PLATFORM ,
207+ CloudIncubatingAttributes . CloudPlatformIncubatingValues .GCP_CLOUD_FUNCTIONS );
198208 addCommonAttributesForServerlessCompute (attrBuilder , attributesMap );
199209 }
200210
@@ -207,20 +217,25 @@ private void addGCFAttributes(AttributesBuilder attrBuilder, Map<String, String>
207217 */
208218 private void addGAEAttributes (AttributesBuilder attrBuilder , Map <String , String > attributesMap ) {
209219 attrBuilder .put (
210- ResourceAttributes .CLOUD_PLATFORM , ResourceAttributes .CloudPlatformValues .GCP_APP_ENGINE );
220+ CloudIncubatingAttributes .CLOUD_PLATFORM ,
221+ CloudIncubatingAttributes .CloudPlatformIncubatingValues .GCP_APP_ENGINE );
211222 Optional .ofNullable (attributesMap .get (GAE_MODULE_NAME ))
212- .ifPresent (appName -> attrBuilder .put (ResourceAttributes .FAAS_NAME , appName ));
223+ .ifPresent (appName -> attrBuilder .put (FaasIncubatingAttributes .FAAS_NAME , appName ));
213224 Optional .ofNullable (attributesMap .get (GAE_APP_VERSION ))
214- .ifPresent (appVersion -> attrBuilder .put (ResourceAttributes .FAAS_VERSION , appVersion ));
225+ .ifPresent (
226+ appVersion -> attrBuilder .put (FaasIncubatingAttributes .FAAS_VERSION , appVersion ));
215227 Optional .ofNullable (attributesMap .get (GAE_INSTANCE_ID ))
216228 .ifPresent (
217- appInstanceId -> attrBuilder .put (ResourceAttributes .FAAS_INSTANCE , appInstanceId ));
229+ appInstanceId ->
230+ attrBuilder .put (FaasIncubatingAttributes .FAAS_INSTANCE , appInstanceId ));
218231 Optional .ofNullable (attributesMap .get (GAE_CLOUD_REGION ))
219- .ifPresent (cloudRegion -> attrBuilder .put (ResourceAttributes .CLOUD_REGION , cloudRegion ));
232+ .ifPresent (
233+ cloudRegion -> attrBuilder .put (CloudIncubatingAttributes .CLOUD_REGION , cloudRegion ));
220234 Optional .ofNullable (attributesMap .get (GAE_AVAILABILITY_ZONE ))
221235 .ifPresent (
222236 cloudAvailabilityZone ->
223- attrBuilder .put (ResourceAttributes .CLOUD_AVAILABILITY_ZONE , cloudAvailabilityZone ));
237+ attrBuilder .put (
238+ CloudIncubatingAttributes .CLOUD_AVAILABILITY_ZONE , cloudAvailabilityZone ));
224239 }
225240
226241 /**
@@ -233,14 +248,16 @@ private void addGAEAttributes(AttributesBuilder attrBuilder, Map<String, String>
233248 private void addCommonAttributesForServerlessCompute (
234249 AttributesBuilder attrBuilder , Map <String , String > attributesMap ) {
235250 Optional .ofNullable (attributesMap .get (SERVERLESS_COMPUTE_NAME ))
236- .ifPresent (name -> attrBuilder .put (ResourceAttributes .FAAS_NAME , name ));
251+ .ifPresent (name -> attrBuilder .put (FaasIncubatingAttributes .FAAS_NAME , name ));
237252 Optional .ofNullable (attributesMap .get (SERVERLESS_COMPUTE_REVISION ))
238- .ifPresent (revision -> attrBuilder .put (ResourceAttributes .FAAS_VERSION , revision ));
253+ .ifPresent (revision -> attrBuilder .put (FaasIncubatingAttributes .FAAS_VERSION , revision ));
239254 Optional .ofNullable (attributesMap .get (SERVERLESS_COMPUTE_INSTANCE_ID ))
240- .ifPresent (instanceId -> attrBuilder .put (ResourceAttributes .FAAS_INSTANCE , instanceId ));
255+ .ifPresent (
256+ instanceId -> attrBuilder .put (FaasIncubatingAttributes .FAAS_INSTANCE , instanceId ));
241257 Optional .ofNullable (attributesMap .get (SERVERLESS_COMPUTE_AVAILABILITY_ZONE ))
242- .ifPresent (zone -> attrBuilder .put (ResourceAttributes .CLOUD_AVAILABILITY_ZONE , zone ));
258+ .ifPresent (
259+ zone -> attrBuilder .put (CloudIncubatingAttributes .CLOUD_AVAILABILITY_ZONE , zone ));
243260 Optional .ofNullable (attributesMap .get (SERVERLESS_COMPUTE_CLOUD_REGION ))
244- .ifPresent (region -> attrBuilder .put (ResourceAttributes .CLOUD_REGION , region ));
261+ .ifPresent (region -> attrBuilder .put (CloudIncubatingAttributes .CLOUD_REGION , region ));
245262 }
246263}
0 commit comments