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] 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" ] }