From f3bdacfb0f6d25be02cea17c8695565fccef656a Mon Sep 17 00:00:00 2001 From: Gary Sassano <10464497+garysassano@users.noreply.github.com> Date: Fri, 17 Jan 2025 20:52:08 +0100 Subject: [PATCH 1/7] fix(detector-aws): remove semconv incubating import --- .../lib/semconv.ts | 72 +++++++++++++++++++ .../src/detectors/AwsBeanstalkDetectorSync.ts | 2 +- .../src/detectors/AwsEc2DetectorSync.ts | 2 +- .../src/detectors/AwsEcsDetectorSync.ts | 2 +- .../src/detectors/AwsEksDetectorSync.ts | 2 +- .../src/detectors/AwsLambdaDetectorSync.ts | 2 +- .../tsconfig.json | 3 +- 7 files changed, 79 insertions(+), 6 deletions(-) create mode 100644 detectors/node/opentelemetry-resource-detector-aws/lib/semconv.ts diff --git a/detectors/node/opentelemetry-resource-detector-aws/lib/semconv.ts b/detectors/node/opentelemetry-resource-detector-aws/lib/semconv.ts new file mode 100644 index 0000000000..83ee3910d2 --- /dev/null +++ b/detectors/node/opentelemetry-resource-detector-aws/lib/semconv.ts @@ -0,0 +1,72 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Following OpenTelemetry semantic conventions best practices, we copy the incubating + * semantic conventions into our codebase rather than importing them directly. + * This prevents breaking changes in minor versions and reduces disk usage from multiple versions. + * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv + */ + +// AWS attributes +export const ATTR_AWS_ECS_CLUSTER_ARN = 'aws.ecs.cluster.arn'; +export const ATTR_AWS_ECS_CONTAINER_ARN = 'aws.ecs.container.arn'; +export const ATTR_AWS_ECS_LAUNCHTYPE = 'aws.ecs.launchtype'; +export const ATTR_AWS_ECS_TASK_ARN = 'aws.ecs.task.arn'; +export const ATTR_AWS_ECS_TASK_FAMILY = 'aws.ecs.task.family'; +export const ATTR_AWS_ECS_TASK_REVISION = 'aws.ecs.task.revision'; +export const ATTR_AWS_LOG_GROUP_ARNS = 'aws.log.group.arns'; +export const ATTR_AWS_LOG_GROUP_NAMES = 'aws.log.group.names'; +export const ATTR_AWS_LOG_STREAM_ARNS = 'aws.log.stream.arns'; +export const ATTR_AWS_LOG_STREAM_NAMES = 'aws.log.stream.names'; + +// Cloud attributes +export const ATTR_CLOUD_ACCOUNT_ID = 'cloud.account.id'; +export const ATTR_CLOUD_AVAILABILITY_ZONE = 'cloud.availability.zone'; +export const ATTR_CLOUD_PLATFORM = 'cloud.platform'; +export const ATTR_CLOUD_PROVIDER = 'cloud.provider'; +export const ATTR_CLOUD_REGION = 'cloud.region'; + +// Container attributes +export const ATTR_CONTAINER_ID = 'container.id'; +export const ATTR_CONTAINER_NAME = 'container.name'; + +// FaaS attributes +export const ATTR_FAAS_NAME = 'faas.name'; +export const ATTR_FAAS_VERSION = 'faas.version'; + +// Host attributes +export const ATTR_HOST_ID = 'host.id'; +export const ATTR_HOST_NAME = 'host.name'; +export const ATTR_HOST_TYPE = 'host.type'; + +// Kubernetes attributes +export const ATTR_K8S_CLUSTER_NAME = 'k8s.cluster.name'; + +// Service attributes +export const ATTR_SERVICE_INSTANCE_ID = 'service.instance.id'; +export const ATTR_SERVICE_NAME = 'service.name'; +export const ATTR_SERVICE_NAMESPACE = 'service.namespace'; +export const ATTR_SERVICE_VERSION = 'service.version'; + +// Cloud provider/platform values +export const CLOUD_PROVIDER_VALUE_AWS = 'aws'; +export const CLOUD_PLATFORM_VALUE_AWS_EC2 = 'aws_ec2'; +export const CLOUD_PLATFORM_VALUE_AWS_ECS = 'aws_ecs'; +export const CLOUD_PLATFORM_VALUE_AWS_EKS = 'aws_eks'; +export const CLOUD_PLATFORM_VALUE_AWS_ELASTIC_BEANSTALK = + 'aws_elastic_beanstalk'; +export const CLOUD_PLATFORM_VALUE_AWS_LAMBDA = 'aws_lambda'; diff --git a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetectorSync.ts b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetectorSync.ts index 1716c97a49..4e8d167406 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetectorSync.ts +++ b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetectorSync.ts @@ -33,7 +33,7 @@ import { ATTR_SERVICE_INSTANCE_ID, CLOUD_PROVIDER_VALUE_AWS, CLOUD_PLATFORM_VALUE_AWS_ELASTIC_BEANSTALK, -} from '@opentelemetry/semantic-conventions/incubating'; +} from '../../lib/semconv'; import * as fs from 'fs'; import * as util from 'util'; diff --git a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEc2DetectorSync.ts b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEc2DetectorSync.ts index 471b2b9085..9a2e25085c 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEc2DetectorSync.ts +++ b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEc2DetectorSync.ts @@ -34,7 +34,7 @@ import { ATTR_HOST_NAME, CLOUD_PROVIDER_VALUE_AWS, CLOUD_PLATFORM_VALUE_AWS_EC2, -} from '@opentelemetry/semantic-conventions/incubating'; +} from '../../lib/semconv'; import * as http from 'http'; /** diff --git a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetectorSync.ts b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetectorSync.ts index 5b4f4ccd09..e1145b6d4c 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetectorSync.ts +++ b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetectorSync.ts @@ -42,7 +42,7 @@ import { ATTR_AWS_LOG_STREAM_ARNS, CLOUD_PROVIDER_VALUE_AWS, CLOUD_PLATFORM_VALUE_AWS_ECS, -} from '@opentelemetry/semantic-conventions/incubating'; +} from '../../lib/semconv'; // Patch until the OpenTelemetry SDK is updated to ship this attribute import { SemanticResourceAttributes as AdditionalSemanticResourceAttributes } from './SemanticResourceAttributes'; import * as http from 'http'; diff --git a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEksDetectorSync.ts b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEksDetectorSync.ts index 857fb2f217..a96e410a57 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEksDetectorSync.ts +++ b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEksDetectorSync.ts @@ -30,7 +30,7 @@ import { ATTR_CONTAINER_ID, CLOUD_PROVIDER_VALUE_AWS, CLOUD_PLATFORM_VALUE_AWS_EKS, -} from '@opentelemetry/semantic-conventions/incubating'; +} from '../../lib/semconv'; import * as https from 'https'; import * as fs from 'fs'; import * as util from 'util'; diff --git a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsLambdaDetectorSync.ts b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsLambdaDetectorSync.ts index da7187e565..5eb398d639 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsLambdaDetectorSync.ts +++ b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsLambdaDetectorSync.ts @@ -29,7 +29,7 @@ import { ATTR_FAAS_NAME, CLOUD_PROVIDER_VALUE_AWS, CLOUD_PLATFORM_VALUE_AWS_LAMBDA, -} from '@opentelemetry/semantic-conventions/incubating'; +} from '../../lib/semconv'; /** * The AwsLambdaDetector can be used to detect if a process is running in AWS Lambda diff --git a/detectors/node/opentelemetry-resource-detector-aws/tsconfig.json b/detectors/node/opentelemetry-resource-detector-aws/tsconfig.json index 28be80d266..a6da3ce22c 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/tsconfig.json +++ b/detectors/node/opentelemetry-resource-detector-aws/tsconfig.json @@ -6,6 +6,7 @@ }, "include": [ "src/**/*.ts", - "test/**/*.ts" + "test/**/*.ts", + "lib/**/*.ts" ] } From 9062abfce6b8fb6bd2075e67f63b588ab53c896c Mon Sep 17 00:00:00 2001 From: Gary Sassano <10464497+garysassano@users.noreply.github.com> Date: Fri, 17 Jan 2025 21:25:21 +0100 Subject: [PATCH 2/7] move lib dir --- .../src/detectors/AwsBeanstalkDetectorSync.ts | 2 +- .../src/detectors/AwsEc2DetectorSync.ts | 2 +- .../src/detectors/AwsEcsDetectorSync.ts | 2 +- .../src/detectors/AwsEksDetectorSync.ts | 2 +- .../src/detectors/AwsLambdaDetectorSync.ts | 2 +- .../{ => src}/lib/semconv.ts | 0 .../node/opentelemetry-resource-detector-aws/tsconfig.json | 2 +- 7 files changed, 6 insertions(+), 6 deletions(-) rename detectors/node/opentelemetry-resource-detector-aws/{ => src}/lib/semconv.ts (100%) diff --git a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetectorSync.ts b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetectorSync.ts index 4e8d167406..0cce5a5c7a 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetectorSync.ts +++ b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetectorSync.ts @@ -33,7 +33,7 @@ import { ATTR_SERVICE_INSTANCE_ID, CLOUD_PROVIDER_VALUE_AWS, CLOUD_PLATFORM_VALUE_AWS_ELASTIC_BEANSTALK, -} from '../../lib/semconv'; +} from '../lib/semconv'; import * as fs from 'fs'; import * as util from 'util'; diff --git a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEc2DetectorSync.ts b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEc2DetectorSync.ts index 9a2e25085c..cba878e04c 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEc2DetectorSync.ts +++ b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEc2DetectorSync.ts @@ -34,7 +34,7 @@ import { ATTR_HOST_NAME, CLOUD_PROVIDER_VALUE_AWS, CLOUD_PLATFORM_VALUE_AWS_EC2, -} from '../../lib/semconv'; +} from '../lib/semconv'; import * as http from 'http'; /** diff --git a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetectorSync.ts b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetectorSync.ts index e1145b6d4c..9dd1fa7c08 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetectorSync.ts +++ b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetectorSync.ts @@ -42,7 +42,7 @@ import { ATTR_AWS_LOG_STREAM_ARNS, CLOUD_PROVIDER_VALUE_AWS, CLOUD_PLATFORM_VALUE_AWS_ECS, -} from '../../lib/semconv'; +} from '../lib/semconv'; // Patch until the OpenTelemetry SDK is updated to ship this attribute import { SemanticResourceAttributes as AdditionalSemanticResourceAttributes } from './SemanticResourceAttributes'; import * as http from 'http'; diff --git a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEksDetectorSync.ts b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEksDetectorSync.ts index a96e410a57..57b4773c54 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEksDetectorSync.ts +++ b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEksDetectorSync.ts @@ -30,7 +30,7 @@ import { ATTR_CONTAINER_ID, CLOUD_PROVIDER_VALUE_AWS, CLOUD_PLATFORM_VALUE_AWS_EKS, -} from '../../lib/semconv'; +} from '../lib/semconv'; import * as https from 'https'; import * as fs from 'fs'; import * as util from 'util'; diff --git a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsLambdaDetectorSync.ts b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsLambdaDetectorSync.ts index 5eb398d639..d715bf8fa7 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsLambdaDetectorSync.ts +++ b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsLambdaDetectorSync.ts @@ -29,7 +29,7 @@ import { ATTR_FAAS_NAME, CLOUD_PROVIDER_VALUE_AWS, CLOUD_PLATFORM_VALUE_AWS_LAMBDA, -} from '../../lib/semconv'; +} from '../lib/semconv'; /** * The AwsLambdaDetector can be used to detect if a process is running in AWS Lambda diff --git a/detectors/node/opentelemetry-resource-detector-aws/lib/semconv.ts b/detectors/node/opentelemetry-resource-detector-aws/src/lib/semconv.ts similarity index 100% rename from detectors/node/opentelemetry-resource-detector-aws/lib/semconv.ts rename to detectors/node/opentelemetry-resource-detector-aws/src/lib/semconv.ts diff --git a/detectors/node/opentelemetry-resource-detector-aws/tsconfig.json b/detectors/node/opentelemetry-resource-detector-aws/tsconfig.json index a6da3ce22c..17401e5ad2 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/tsconfig.json +++ b/detectors/node/opentelemetry-resource-detector-aws/tsconfig.json @@ -7,6 +7,6 @@ "include": [ "src/**/*.ts", "test/**/*.ts", - "lib/**/*.ts" + "src/lib/**/*.ts" ] } From f426498da36b2a29054c37367ef605aacf964a79 Mon Sep 17 00:00:00 2001 From: Gary Sassano <10464497+garysassano@users.noreply.github.com> Date: Fri, 17 Jan 2025 22:00:01 +0100 Subject: [PATCH 3/7] remove redundant include --- .../src/test-utils/resource-assertions.ts | 1 + .../test/utils/resource-assertions.ts | 1 + .../node/opentelemetry-resource-detector-aws/tsconfig.json | 3 +-- 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 detectors/node/opentelemetry-resource-detector-aws/src/test-utils/resource-assertions.ts create mode 100644 detectors/node/opentelemetry-resource-detector-aws/test/utils/resource-assertions.ts diff --git a/detectors/node/opentelemetry-resource-detector-aws/src/test-utils/resource-assertions.ts b/detectors/node/opentelemetry-resource-detector-aws/src/test-utils/resource-assertions.ts new file mode 100644 index 0000000000..0519ecba6e --- /dev/null +++ b/detectors/node/opentelemetry-resource-detector-aws/src/test-utils/resource-assertions.ts @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/detectors/node/opentelemetry-resource-detector-aws/test/utils/resource-assertions.ts b/detectors/node/opentelemetry-resource-detector-aws/test/utils/resource-assertions.ts new file mode 100644 index 0000000000..0519ecba6e --- /dev/null +++ b/detectors/node/opentelemetry-resource-detector-aws/test/utils/resource-assertions.ts @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/detectors/node/opentelemetry-resource-detector-aws/tsconfig.json b/detectors/node/opentelemetry-resource-detector-aws/tsconfig.json index 17401e5ad2..28be80d266 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/tsconfig.json +++ b/detectors/node/opentelemetry-resource-detector-aws/tsconfig.json @@ -6,7 +6,6 @@ }, "include": [ "src/**/*.ts", - "test/**/*.ts", - "src/lib/**/*.ts" + "test/**/*.ts" ] } From af088dff0715fa93da9d3e25b419f940737f6225 Mon Sep 17 00:00:00 2001 From: Gary Sassano <10464497+garysassano@users.noreply.github.com> Date: Fri, 17 Jan 2025 22:04:32 +0100 Subject: [PATCH 4/7] remove dirs --- .../src/test-utils/resource-assertions.ts | 1 - .../test/utils/resource-assertions.ts | 1 - 2 files changed, 2 deletions(-) delete mode 100644 detectors/node/opentelemetry-resource-detector-aws/src/test-utils/resource-assertions.ts delete mode 100644 detectors/node/opentelemetry-resource-detector-aws/test/utils/resource-assertions.ts diff --git a/detectors/node/opentelemetry-resource-detector-aws/src/test-utils/resource-assertions.ts b/detectors/node/opentelemetry-resource-detector-aws/src/test-utils/resource-assertions.ts deleted file mode 100644 index 0519ecba6e..0000000000 --- a/detectors/node/opentelemetry-resource-detector-aws/src/test-utils/resource-assertions.ts +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/detectors/node/opentelemetry-resource-detector-aws/test/utils/resource-assertions.ts b/detectors/node/opentelemetry-resource-detector-aws/test/utils/resource-assertions.ts deleted file mode 100644 index 0519ecba6e..0000000000 --- a/detectors/node/opentelemetry-resource-detector-aws/test/utils/resource-assertions.ts +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file From 9723b4f1545c331474e72b8f065f068749d2c7b5 Mon Sep 17 00:00:00 2001 From: Gary Sassano <10464497+garysassano@users.noreply.github.com> Date: Fri, 17 Jan 2025 22:23:13 +0100 Subject: [PATCH 5/7] fix cloud az attribute --- .../src/detectors/AwsEcsDetectorSync.ts | 3 +-- .../opentelemetry-resource-detector-aws/src/lib/semconv.ts | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetectorSync.ts b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetectorSync.ts index 9dd1fa7c08..375a136e38 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetectorSync.ts +++ b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetectorSync.ts @@ -166,8 +166,7 @@ export class AwsEcsDetectorSync implements DetectorSync { const accountId: string = AwsEcsDetectorSync._getAccountFromArn(taskArn); const region: string = AwsEcsDetectorSync._getRegionFromArn(taskArn); - const availabilityZone: string | undefined = - taskMetadata?.['AvailabilityZone']; + const availabilityZone: string | undefined = taskMetadata?.AvailabilityZone; const clusterArn = cluster.startsWith('arn:') ? cluster diff --git a/detectors/node/opentelemetry-resource-detector-aws/src/lib/semconv.ts b/detectors/node/opentelemetry-resource-detector-aws/src/lib/semconv.ts index 83ee3910d2..12f0ab173f 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/src/lib/semconv.ts +++ b/detectors/node/opentelemetry-resource-detector-aws/src/lib/semconv.ts @@ -35,7 +35,7 @@ export const ATTR_AWS_LOG_STREAM_NAMES = 'aws.log.stream.names'; // Cloud attributes export const ATTR_CLOUD_ACCOUNT_ID = 'cloud.account.id'; -export const ATTR_CLOUD_AVAILABILITY_ZONE = 'cloud.availability.zone'; +export const ATTR_CLOUD_AVAILABILITY_ZONE = 'cloud.availability_zone'; export const ATTR_CLOUD_PLATFORM = 'cloud.platform'; export const ATTR_CLOUD_PROVIDER = 'cloud.provider'; export const ATTR_CLOUD_REGION = 'cloud.region'; From fe0895f74026328591b2dc33246c8fbd35965465 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Fri, 17 Jan 2025 16:17:17 -0800 Subject: [PATCH 6/7] move src/lib/semconv.ts to src/semconv.ts --- .../src/detectors/AwsBeanstalkDetectorSync.ts | 2 +- .../src/detectors/AwsEc2DetectorSync.ts | 2 +- .../src/detectors/AwsEcsDetectorSync.ts | 2 +- .../src/detectors/AwsEksDetectorSync.ts | 2 +- .../src/detectors/AwsLambdaDetectorSync.ts | 2 +- .../src/{lib => }/semconv.ts | 0 6 files changed, 5 insertions(+), 5 deletions(-) rename detectors/node/opentelemetry-resource-detector-aws/src/{lib => }/semconv.ts (100%) diff --git a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetectorSync.ts b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetectorSync.ts index 0cce5a5c7a..e9204c2446 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetectorSync.ts +++ b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetectorSync.ts @@ -33,7 +33,7 @@ import { ATTR_SERVICE_INSTANCE_ID, CLOUD_PROVIDER_VALUE_AWS, CLOUD_PLATFORM_VALUE_AWS_ELASTIC_BEANSTALK, -} from '../lib/semconv'; +} from '../semconv'; import * as fs from 'fs'; import * as util from 'util'; diff --git a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEc2DetectorSync.ts b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEc2DetectorSync.ts index cba878e04c..5b91d51b10 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEc2DetectorSync.ts +++ b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEc2DetectorSync.ts @@ -34,7 +34,7 @@ import { ATTR_HOST_NAME, CLOUD_PROVIDER_VALUE_AWS, CLOUD_PLATFORM_VALUE_AWS_EC2, -} from '../lib/semconv'; +} from '../semconv'; import * as http from 'http'; /** diff --git a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetectorSync.ts b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetectorSync.ts index 375a136e38..d7ccaf8465 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetectorSync.ts +++ b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetectorSync.ts @@ -42,7 +42,7 @@ import { ATTR_AWS_LOG_STREAM_ARNS, CLOUD_PROVIDER_VALUE_AWS, CLOUD_PLATFORM_VALUE_AWS_ECS, -} from '../lib/semconv'; +} from '../semconv'; // Patch until the OpenTelemetry SDK is updated to ship this attribute import { SemanticResourceAttributes as AdditionalSemanticResourceAttributes } from './SemanticResourceAttributes'; import * as http from 'http'; diff --git a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEksDetectorSync.ts b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEksDetectorSync.ts index 57b4773c54..244bf50247 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEksDetectorSync.ts +++ b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEksDetectorSync.ts @@ -30,7 +30,7 @@ import { ATTR_CONTAINER_ID, CLOUD_PROVIDER_VALUE_AWS, CLOUD_PLATFORM_VALUE_AWS_EKS, -} from '../lib/semconv'; +} from '../semconv'; import * as https from 'https'; import * as fs from 'fs'; import * as util from 'util'; diff --git a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsLambdaDetectorSync.ts b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsLambdaDetectorSync.ts index d715bf8fa7..66fe94ee2a 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsLambdaDetectorSync.ts +++ b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsLambdaDetectorSync.ts @@ -29,7 +29,7 @@ import { ATTR_FAAS_NAME, CLOUD_PROVIDER_VALUE_AWS, CLOUD_PLATFORM_VALUE_AWS_LAMBDA, -} from '../lib/semconv'; +} from '../semconv'; /** * The AwsLambdaDetector can be used to detect if a process is running in AWS Lambda diff --git a/detectors/node/opentelemetry-resource-detector-aws/src/lib/semconv.ts b/detectors/node/opentelemetry-resource-detector-aws/src/semconv.ts similarity index 100% rename from detectors/node/opentelemetry-resource-detector-aws/src/lib/semconv.ts rename to detectors/node/opentelemetry-resource-detector-aws/src/semconv.ts From 0ac7ca1b6dec9eb820f6128749614692ee71c761 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Fri, 17 Jan 2025 16:56:18 -0800 Subject: [PATCH 7/7] use gen-semconv-ts.js script from https://github.com/open-telemetry/opentelemetry-js-contrib/pull/2669 to generate semconv.ts file --- .../src/detectors/AwsBeanstalkDetectorSync.ts | 6 +- .../src/semconv.ts | 303 +++++++++++++++++- 2 files changed, 292 insertions(+), 17 deletions(-) diff --git a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetectorSync.ts b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetectorSync.ts index e9204c2446..47b279738a 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetectorSync.ts +++ b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetectorSync.ts @@ -24,12 +24,14 @@ import { ResourceAttributes, ResourceDetectionConfig, } from '@opentelemetry/resources'; +import { + ATTR_SERVICE_NAME, + ATTR_SERVICE_VERSION, +} from '@opentelemetry/semantic-conventions'; import { ATTR_CLOUD_PROVIDER, ATTR_CLOUD_PLATFORM, - ATTR_SERVICE_NAME, ATTR_SERVICE_NAMESPACE, - ATTR_SERVICE_VERSION, ATTR_SERVICE_INSTANCE_ID, CLOUD_PROVIDER_VALUE_AWS, CLOUD_PLATFORM_VALUE_AWS_ELASTIC_BEANSTALK, diff --git a/detectors/node/opentelemetry-resource-detector-aws/src/semconv.ts b/detectors/node/opentelemetry-resource-detector-aws/src/semconv.ts index 12f0ab173f..3d34526643 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/src/semconv.ts +++ b/detectors/node/opentelemetry-resource-detector-aws/src/semconv.ts @@ -14,59 +14,332 @@ * limitations under the License. */ -/** - * Following OpenTelemetry semantic conventions best practices, we copy the incubating - * semantic conventions into our codebase rather than importing them directly. - * This prevents breaking changes in minor versions and reduces disk usage from multiple versions. +/* + * This file contains a copy of unstable semantic convention definitions + * used by this package. * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv */ -// AWS attributes +/** + * The ARN of an [ECS cluster](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/clusters.html). + * + * @example arn:aws:ecs:us-west-2:123456789123:cluster/my-cluster + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ export const ATTR_AWS_ECS_CLUSTER_ARN = 'aws.ecs.cluster.arn'; + +/** + * The Amazon Resource Name (ARN) of an [ECS container instance](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ECS_instances.html). + * + * @example arn:aws:ecs:us-west-1:123456789123:container/32624152-9086-4f0e-acae-1a75b14fe4d9 + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ export const ATTR_AWS_ECS_CONTAINER_ARN = 'aws.ecs.container.arn'; + +/** + * The [launch type](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/launch_types.html) for an ECS task. + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ export const ATTR_AWS_ECS_LAUNCHTYPE = 'aws.ecs.launchtype'; + +/** + * The ARN of a running [ECS task](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-account-settings.html#ecs-resource-ids). + * + * @example arn:aws:ecs:us-west-1:123456789123:task/10838bed-421f-43ef-870a-f43feacbbb5b + * @example arn:aws:ecs:us-west-1:123456789123:task/my-cluster/task-id/23ebb8ac-c18f-46c6-8bbe-d55d0e37cfbd + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ export const ATTR_AWS_ECS_TASK_ARN = 'aws.ecs.task.arn'; + +/** + * The family name of the [ECS task definition](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definitions.html) used to create the ECS task. + * + * @example opentelemetry-family + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ export const ATTR_AWS_ECS_TASK_FAMILY = 'aws.ecs.task.family'; + +/** + * The revision for the task definition used to create the ECS task. + * + * @example 8 + * @example 26 + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ export const ATTR_AWS_ECS_TASK_REVISION = 'aws.ecs.task.revision'; + +/** + * The Amazon Resource Name(s) (ARN) of the AWS log group(s). + * + * @example ["arn:aws:logs:us-west-1:123456789012:log-group:/aws/my/group:*"] + * + * @note See the [log group ARN format documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/iam-access-control-overview-cwl.html#CWL_ARN_Format). + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ export const ATTR_AWS_LOG_GROUP_ARNS = 'aws.log.group.arns'; + +/** + * The name(s) of the AWS log group(s) an application is writing to. + * + * @example ["/aws/lambda/my-function", "opentelemetry-service"] + * + * @note Multiple log groups must be supported for cases like multi-container applications, where a single application has sidecar containers, and each write to their own log group. + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ export const ATTR_AWS_LOG_GROUP_NAMES = 'aws.log.group.names'; + +/** + * The ARN(s) of the AWS log stream(s). + * + * @example ["arn:aws:logs:us-west-1:123456789012:log-group:/aws/my/group:log-stream:logs/main/10838bed-421f-43ef-870a-f43feacbbb5b"] + * + * @note See the [log stream ARN format documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/iam-access-control-overview-cwl.html#CWL_ARN_Format). One log group can contain several log streams, so these ARNs necessarily identify both a log group and a log stream. + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ export const ATTR_AWS_LOG_STREAM_ARNS = 'aws.log.stream.arns'; + +/** + * The name(s) of the AWS log stream(s) an application is writing to. + * + * @example ["logs/main/10838bed-421f-43ef-870a-f43feacbbb5b"] + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ export const ATTR_AWS_LOG_STREAM_NAMES = 'aws.log.stream.names'; -// Cloud attributes +/** + * The cloud account ID the resource is assigned to. + * + * @example 111111111111 + * @example opentelemetry + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ export const ATTR_CLOUD_ACCOUNT_ID = 'cloud.account.id'; + +/** + * Cloud regions often have multiple, isolated locations known as zones to increase availability. Availability zone represents the zone where the resource is running. + * + * @example us-east-1c + * + * @note Availability zones are called "zones" on Alibaba Cloud and Google Cloud. + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ export const ATTR_CLOUD_AVAILABILITY_ZONE = 'cloud.availability_zone'; + +/** + * The cloud platform in use. + * + * @note The prefix of the service **SHOULD** match the one specified in `cloud.provider`. + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ export const ATTR_CLOUD_PLATFORM = 'cloud.platform'; + +/** + * Name of the cloud provider. + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ export const ATTR_CLOUD_PROVIDER = 'cloud.provider'; + +/** + * The geographical region the resource is running. + * + * @example us-central1 + * @example us-east-1 + * + * @note Refer to your provider's docs to see the available regions, for example [Alibaba Cloud regions](https://www.alibabacloud.com/help/doc-detail/40654.htm), [AWS regions](https://aws.amazon.com/about-aws/global-infrastructure/regions_az/), [Azure regions](https://azure.microsoft.com/global-infrastructure/geographies/), [Google Cloud regions](https://cloud.google.com/about/locations), or [Tencent Cloud regions](https://www.tencentcloud.com/document/product/213/6091). + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ export const ATTR_CLOUD_REGION = 'cloud.region'; -// Container attributes +/** + * Container ID. Usually a UUID, as for example used to [identify Docker containers](https://docs.docker.com/engine/containers/run/#container-identification). The UUID might be abbreviated. + * + * @example a3bf90e006b2 + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ export const ATTR_CONTAINER_ID = 'container.id'; + +/** + * Container name used by container runtime. + * + * @example opentelemetry-autoconf + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ export const ATTR_CONTAINER_NAME = 'container.name'; -// FaaS attributes +/** + * The name of the single function that this runtime instance executes. + * + * @example my-function + * @example myazurefunctionapp/some-function-name + * + * @note This is the name of the function as configured/deployed on the FaaS + * platform and is usually different from the name of the callback + * function (which may be stored in the + * [`code.namespace`/`code.function`](/docs/general/attributes.md#source-code-attributes) + * span attributes). + * + * For some cloud providers, the above definition is ambiguous. The following + * definition of function name **MUST** be used for this attribute + * (and consequently the span name) for the listed cloud providers/products: + * + * - **Azure:** The full name `/`, i.e., function app name + * followed by a forward slash followed by the function name (this form + * can also be seen in the resource JSON for the function). + * This means that a span attribute **MUST** be used, as an Azure function + * app can host multiple functions that would usually share + * a TracerProvider (see also the `cloud.resource_id` attribute). + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ export const ATTR_FAAS_NAME = 'faas.name'; + +/** + * The immutable version of the function being executed. + * + * @example 26 + * @example pinkfroid-00002 + * + * @note Depending on the cloud provider and platform, use: + * + * - **AWS Lambda:** The [function version](https://docs.aws.amazon.com/lambda/latest/dg/configuration-versions.html) + * (an integer represented as a decimal string). + * - **Google Cloud Run (Services):** The [revision](https://cloud.google.com/run/docs/managing/revisions) + * (i.e., the function name plus the revision suffix). + * - **Google Cloud Functions:** The value of the + * [`K_REVISION` environment variable](https://cloud.google.com/functions/docs/env-var#runtime_environment_variables_set_automatically). + * - **Azure Functions:** Not applicable. Do not set this attribute. + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ export const ATTR_FAAS_VERSION = 'faas.version'; -// Host attributes +/** + * Unique host ID. For Cloud, this must be the instance_id assigned by the cloud provider. For non-containerized systems, this should be the `machine-id`. See the table below for the sources to use to determine the `machine-id` based on operating system. + * + * @example fdbf79e8af94cb7f9e8df36789187052 + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ export const ATTR_HOST_ID = 'host.id'; + +/** + * Name of the host. On Unix systems, it may contain what the hostname command returns, or the fully qualified hostname, or another name specified by the user. + * + * @example opentelemetry-test + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ export const ATTR_HOST_NAME = 'host.name'; + +/** + * Type of host. For Cloud, this must be the machine type. + * + * @example n1-standard-1 + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ export const ATTR_HOST_TYPE = 'host.type'; -// Kubernetes attributes +/** + * The name of the cluster. + * + * @example opentelemetry-cluster + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ export const ATTR_K8S_CLUSTER_NAME = 'k8s.cluster.name'; -// Service attributes +/** + * The string ID of the service instance. + * + * @example 627cc493-f310-47de-96bd-71410b7dec09 + * + * @note **MUST** be unique for each instance of the same `service.namespace,service.name` pair (in other words + * `service.namespace,service.name,service.instance.id` triplet **MUST** be globally unique). The ID helps to + * distinguish instances of the same service that exist at the same time (e.g. instances of a horizontally scaled + * service). + * + * Implementations, such as SDKs, are recommended to generate a random Version 1 or Version 4 [RFC + * 4122](https://www.ietf.org/rfc/rfc4122.txt) UUID, but are free to use an inherent unique ID as the source of + * this value if stability is desirable. In that case, the ID **SHOULD** be used as source of a UUID Version 5 and + * **SHOULD** use the following UUID as the namespace: `4d63009a-8d0f-11ee-aad7-4c796ed8e320`. + * + * UUIDs are typically recommended, as only an opaque value for the purposes of identifying a service instance is + * needed. Similar to what can be seen in the man page for the + * [`/etc/machine-id`](https://www.freedesktop.org/software/systemd/man/machine-id.html) file, the underlying + * data, such as pod name and namespace should be treated as confidential, being the user's choice to expose it + * or not via another resource attribute. + * + * For applications running behind an application server (like unicorn), we do not recommend using one identifier + * for all processes participating in the application. Instead, it's recommended each division (e.g. a worker + * thread in unicorn) to have its own instance.id. + * + * It's not recommended for a Collector to set `service.instance.id` if it can't unambiguously determine the + * service instance that is generating that telemetry. For instance, creating an UUID based on `pod.name` will + * likely be wrong, as the Collector might not know from which container within that pod the telemetry originated. + * However, Collectors can set the `service.instance.id` if they can unambiguously determine the service instance + * for that telemetry. This is typically the case for scraping receivers, as they know the target address and + * port. + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ export const ATTR_SERVICE_INSTANCE_ID = 'service.instance.id'; -export const ATTR_SERVICE_NAME = 'service.name'; + +/** + * A namespace for `service.name`. + * + * @example Shop + * + * @note A string value having a meaning that helps to distinguish a group of services, for example the team name that owns a group of services. `service.name` is expected to be unique within the same namespace. If `service.namespace` is not specified in the Resource then `service.name` is expected to be unique for all services that have no explicit namespace defined (so the empty/unspecified namespace is simply one more valid namespace). Zero-length namespace string is assumed equal to unspecified namespace. + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ export const ATTR_SERVICE_NAMESPACE = 'service.namespace'; -export const ATTR_SERVICE_VERSION = 'service.version'; -// Cloud provider/platform values -export const CLOUD_PROVIDER_VALUE_AWS = 'aws'; +/** + * Enum value "aws_ec2" for attribute {@link ATTR_CLOUD_PLATFORM}. + */ export const CLOUD_PLATFORM_VALUE_AWS_EC2 = 'aws_ec2'; + +/** + * Enum value "aws_ecs" for attribute {@link ATTR_CLOUD_PLATFORM}. + */ export const CLOUD_PLATFORM_VALUE_AWS_ECS = 'aws_ecs'; + +/** + * Enum value "aws_eks" for attribute {@link ATTR_CLOUD_PLATFORM}. + */ export const CLOUD_PLATFORM_VALUE_AWS_EKS = 'aws_eks'; + +/** + * Enum value "aws_elastic_beanstalk" for attribute {@link ATTR_CLOUD_PLATFORM}. + */ export const CLOUD_PLATFORM_VALUE_AWS_ELASTIC_BEANSTALK = 'aws_elastic_beanstalk'; + +/** + * Enum value "aws_lambda" for attribute {@link ATTR_CLOUD_PLATFORM}. + */ export const CLOUD_PLATFORM_VALUE_AWS_LAMBDA = 'aws_lambda'; + +/** + * Enum value "aws" for attribute {@link ATTR_CLOUD_PROVIDER}. + */ +export const CLOUD_PROVIDER_VALUE_AWS = 'aws';