|
46 | 46 | public class MetricRecord { |
47 | 47 | private static final Logger logger = Logger.getLogger(MetricRecord.class.getName()); |
48 | 48 |
|
| 49 | + // https://github.com/open-telemetry/opentelemetry-java/blob/04642a06138a889fce8a8224f489c14d9d55cf3f/sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java#L52C43-L52C63 |
49 | 50 | private static final String SERVICE_DIMENSION_NAME = "Service"; |
50 | 51 | private static final String ENVIRONMENT_DIMENSION_NAME = "Environment"; |
| 52 | + |
| 53 | + private static final String OTEL_UNKNOWN_SERVICE = "unknown_service:java"; |
51 | 54 | private static final String UNKNOWN_SERVICE = "UnknownService"; |
52 | 55 | private static final String UNKNOWN_ENVIRONMENT = "generic:default"; |
53 | 56 |
|
| 57 | + private static final String EC2_DEFAULT_ENVIRONMENT = "ec2:default"; |
| 58 | + private static final String ECS_DEFAULT_ENVIRONMENT = "ecs:default"; |
| 59 | + private static final String EKS_DEFAULT_ENVIRONMENT = "eks:default"; |
| 60 | + private static final String LAMBDA_DEFAULT_ENVIRONMENT = "lambda:default"; |
| 61 | + |
54 | 62 | // CloudWatch EMF supported units |
55 | 63 | // Ref: https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html |
56 | 64 | private static final Set<String> EMF_SUPPORTED_UNITS = |
@@ -241,7 +249,9 @@ private static void addApplicationSignalsDimensions( |
241 | 249 | List<String> dimensionNames, Map<String, Object> emfLog, Attributes resourceAttributes) { |
242 | 250 | if (!MetricRecord.hasDimension(dimensionNames, SERVICE_DIMENSION_NAME)) { |
243 | 251 | String serviceName = resourceAttributes.get(ServiceAttributes.SERVICE_NAME); |
244 | | - if (serviceName == null || serviceName.isEmpty()) { |
| 252 | + if (serviceName == null |
| 253 | + || serviceName.isEmpty() |
| 254 | + || serviceName.equals(OTEL_UNKNOWN_SERVICE)) { |
245 | 255 | serviceName = UNKNOWN_SERVICE; |
246 | 256 | } |
247 | 257 | dimensionNames.add(SERVICE_DIMENSION_NAME); |
@@ -289,13 +299,13 @@ private static String getDeploymentEnvironment(Attributes resourceAttributes) { |
289 | 299 | if (platform != null && !platform.isEmpty()) { |
290 | 300 | switch (platform) { |
291 | 301 | case AWS_EC2: |
292 | | - return "ec2:default"; |
| 302 | + return EC2_DEFAULT_ENVIRONMENT; |
293 | 303 | case AWS_ECS: |
294 | | - return "ecs:default"; |
| 304 | + return ECS_DEFAULT_ENVIRONMENT; |
295 | 305 | case AWS_EKS: |
296 | | - return "eks:default"; |
| 306 | + return EKS_DEFAULT_ENVIRONMENT; |
297 | 307 | case AWS_LAMBDA: |
298 | | - return "lambda:default"; |
| 308 | + return LAMBDA_DEFAULT_ENVIRONMENT; |
299 | 309 | default: |
300 | 310 | return UNKNOWN_ENVIRONMENT; |
301 | 311 | } |
|
0 commit comments