diff --git a/detectors/node/opentelemetry-resource-detector-alibaba-cloud/package.json b/detectors/node/opentelemetry-resource-detector-alibaba-cloud/package.json index 137bcec331..8f3254afc9 100644 --- a/detectors/node/opentelemetry-resource-detector-alibaba-cloud/package.json +++ b/detectors/node/opentelemetry-resource-detector-alibaba-cloud/package.json @@ -61,5 +61,6 @@ "@opentelemetry/resources": "^1.10.0", "@opentelemetry/semantic-conventions": "^1.27.0" }, - "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-alibaba-cloud#readme" + "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-alibaba-cloud#readme", + "sideEffects": false } diff --git a/detectors/node/opentelemetry-resource-detector-aws/package.json b/detectors/node/opentelemetry-resource-detector-aws/package.json index a0c8c7496a..c27ac5a67f 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/package.json +++ b/detectors/node/opentelemetry-resource-detector-aws/package.json @@ -62,5 +62,6 @@ "@opentelemetry/resources": "^1.10.0", "@opentelemetry/semantic-conventions": "^1.27.0" }, - "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-aws#readme" + "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-aws#readme", + "sideEffects": false } 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 9f938f91a8..1716c97a49 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetectorSync.ts +++ b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetectorSync.ts @@ -25,15 +25,15 @@ import { ResourceDetectionConfig, } from '@opentelemetry/resources'; import { - SEMRESATTRS_CLOUD_PROVIDER, - SEMRESATTRS_CLOUD_PLATFORM, - SEMRESATTRS_SERVICE_NAME, - SEMRESATTRS_SERVICE_NAMESPACE, - SEMRESATTRS_SERVICE_VERSION, - SEMRESATTRS_SERVICE_INSTANCE_ID, - CLOUDPROVIDERVALUES_AWS, - CLOUDPLATFORMVALUES_AWS_ELASTIC_BEANSTALK, -} from '@opentelemetry/semantic-conventions'; + 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, +} from '@opentelemetry/semantic-conventions/incubating'; import * as fs from 'fs'; import * as util from 'util'; @@ -95,12 +95,12 @@ export class AwsBeanstalkDetectorSync implements DetectorSync { const parsedData = JSON.parse(rawData); return { - [SEMRESATTRS_CLOUD_PROVIDER]: CLOUDPROVIDERVALUES_AWS, - [SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_AWS_ELASTIC_BEANSTALK, - [SEMRESATTRS_SERVICE_NAME]: CLOUDPLATFORMVALUES_AWS_ELASTIC_BEANSTALK, - [SEMRESATTRS_SERVICE_NAMESPACE]: parsedData.environment_name, - [SEMRESATTRS_SERVICE_VERSION]: parsedData.version_label, - [SEMRESATTRS_SERVICE_INSTANCE_ID]: parsedData.deployment_id, + [ATTR_CLOUD_PROVIDER]: CLOUD_PROVIDER_VALUE_AWS, + [ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_AWS_ELASTIC_BEANSTALK, + [ATTR_SERVICE_NAME]: CLOUD_PLATFORM_VALUE_AWS_ELASTIC_BEANSTALK, + [ATTR_SERVICE_NAMESPACE]: parsedData.environment_name, + [ATTR_SERVICE_VERSION]: parsedData.version_label, + [ATTR_SERVICE_INSTANCE_ID]: parsedData.deployment_id, }; } catch (e: any) { diag.debug(`AwsBeanstalkDetectorSync failed: ${e.message}`); 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 a0ef6b47b1..471b2b9085 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEc2DetectorSync.ts +++ b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEc2DetectorSync.ts @@ -24,17 +24,17 @@ import { ResourceDetectionConfig, } from '@opentelemetry/resources'; import { - SEMRESATTRS_CLOUD_PROVIDER, - SEMRESATTRS_CLOUD_PLATFORM, - SEMRESATTRS_CLOUD_REGION, - SEMRESATTRS_CLOUD_ACCOUNT_ID, - SEMRESATTRS_CLOUD_AVAILABILITY_ZONE, - SEMRESATTRS_HOST_ID, - SEMRESATTRS_HOST_TYPE, - SEMRESATTRS_HOST_NAME, - CLOUDPROVIDERVALUES_AWS, - CLOUDPLATFORMVALUES_AWS_EC2, -} from '@opentelemetry/semantic-conventions'; + ATTR_CLOUD_PROVIDER, + ATTR_CLOUD_PLATFORM, + ATTR_CLOUD_REGION, + ATTR_CLOUD_ACCOUNT_ID, + ATTR_CLOUD_AVAILABILITY_ZONE, + ATTR_HOST_ID, + ATTR_HOST_TYPE, + ATTR_HOST_NAME, + CLOUD_PROVIDER_VALUE_AWS, + CLOUD_PLATFORM_VALUE_AWS_EC2, +} from '@opentelemetry/semantic-conventions/incubating'; import * as http from 'http'; /** @@ -79,14 +79,14 @@ class AwsEc2DetectorSync implements DetectorSync { const hostname = await this._fetchHost(token); return { - [SEMRESATTRS_CLOUD_PROVIDER]: CLOUDPROVIDERVALUES_AWS, - [SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_AWS_EC2, - [SEMRESATTRS_CLOUD_ACCOUNT_ID]: accountId, - [SEMRESATTRS_CLOUD_REGION]: region, - [SEMRESATTRS_CLOUD_AVAILABILITY_ZONE]: availabilityZone, - [SEMRESATTRS_HOST_ID]: instanceId, - [SEMRESATTRS_HOST_TYPE]: instanceType, - [SEMRESATTRS_HOST_NAME]: hostname, + [ATTR_CLOUD_PROVIDER]: CLOUD_PROVIDER_VALUE_AWS, + [ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_AWS_EC2, + [ATTR_CLOUD_ACCOUNT_ID]: accountId, + [ATTR_CLOUD_REGION]: region, + [ATTR_CLOUD_AVAILABILITY_ZONE]: availabilityZone, + [ATTR_HOST_ID]: instanceId, + [ATTR_HOST_TYPE]: instanceType, + [ATTR_HOST_NAME]: hostname, }; } catch { return {}; 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 56977c2c01..5b4f4ccd09 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetectorSync.ts +++ b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetectorSync.ts @@ -23,26 +23,26 @@ import { ResourceAttributes, } from '@opentelemetry/resources'; import { - SEMRESATTRS_CLOUD_PROVIDER, - SEMRESATTRS_CLOUD_PLATFORM, - SEMRESATTRS_CONTAINER_ID, - SEMRESATTRS_CONTAINER_NAME, - SEMRESATTRS_AWS_ECS_CONTAINER_ARN, - SEMRESATTRS_AWS_ECS_CLUSTER_ARN, - SEMRESATTRS_AWS_ECS_LAUNCHTYPE, - SEMRESATTRS_AWS_ECS_TASK_ARN, - SEMRESATTRS_AWS_ECS_TASK_FAMILY, - SEMRESATTRS_AWS_ECS_TASK_REVISION, - SEMRESATTRS_CLOUD_ACCOUNT_ID, - SEMRESATTRS_CLOUD_REGION, - SEMRESATTRS_CLOUD_AVAILABILITY_ZONE, - SEMRESATTRS_AWS_LOG_GROUP_NAMES, - SEMRESATTRS_AWS_LOG_GROUP_ARNS, - SEMRESATTRS_AWS_LOG_STREAM_NAMES, - SEMRESATTRS_AWS_LOG_STREAM_ARNS, - CLOUDPROVIDERVALUES_AWS, - CLOUDPLATFORMVALUES_AWS_ECS, -} from '@opentelemetry/semantic-conventions'; + ATTR_CLOUD_PROVIDER, + ATTR_CLOUD_PLATFORM, + ATTR_CONTAINER_ID, + ATTR_CONTAINER_NAME, + ATTR_AWS_ECS_CONTAINER_ARN, + ATTR_AWS_ECS_CLUSTER_ARN, + ATTR_AWS_ECS_LAUNCHTYPE, + ATTR_AWS_ECS_TASK_ARN, + ATTR_AWS_ECS_TASK_FAMILY, + ATTR_AWS_ECS_TASK_REVISION, + ATTR_CLOUD_ACCOUNT_ID, + ATTR_CLOUD_REGION, + ATTR_CLOUD_AVAILABILITY_ZONE, + ATTR_AWS_LOG_GROUP_NAMES, + ATTR_AWS_LOG_GROUP_ARNS, + ATTR_AWS_LOG_STREAM_NAMES, + ATTR_AWS_LOG_STREAM_ARNS, + CLOUD_PROVIDER_VALUE_AWS, + CLOUD_PLATFORM_VALUE_AWS_ECS, +} from '@opentelemetry/semantic-conventions/incubating'; // Patch until the OpenTelemetry SDK is updated to ship this attribute import { SemanticResourceAttributes as AdditionalSemanticResourceAttributes } from './SemanticResourceAttributes'; import * as http from 'http'; @@ -86,8 +86,8 @@ export class AwsEcsDetectorSync implements DetectorSync { try { let resource = new Resource({ - [SEMRESATTRS_CLOUD_PROVIDER]: CLOUDPROVIDERVALUES_AWS, - [SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_AWS_ECS, + [ATTR_CLOUD_PROVIDER]: CLOUD_PROVIDER_VALUE_AWS, + [ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_AWS_ECS, }).merge(await AwsEcsDetectorSync._getContainerIdAndHostnameResource()); const metadataUrl = getEnv().ECS_CONTAINER_METADATA_URI_V4; @@ -146,8 +146,8 @@ export class AwsEcsDetectorSync implements DetectorSync { if (hostName || containerId) { return new Resource({ - [SEMRESATTRS_CONTAINER_NAME]: hostName || '', - [SEMRESATTRS_CONTAINER_ID]: containerId || '', + [ATTR_CONTAINER_NAME]: hostName || '', + [ATTR_CONTAINER_ID]: containerId || '', }); } @@ -177,21 +177,21 @@ export class AwsEcsDetectorSync implements DetectorSync { // https://github.com/open-telemetry/semantic-conventions/blob/main/semantic_conventions/resource/cloud_provider/aws/ecs.yaml const attributes: ResourceAttributes = { - [SEMRESATTRS_AWS_ECS_CONTAINER_ARN]: containerArn, - [SEMRESATTRS_AWS_ECS_CLUSTER_ARN]: clusterArn, - [SEMRESATTRS_AWS_ECS_LAUNCHTYPE]: launchType?.toLowerCase(), - [SEMRESATTRS_AWS_ECS_TASK_ARN]: taskArn, - [SEMRESATTRS_AWS_ECS_TASK_FAMILY]: taskMetadata['Family'], - [SEMRESATTRS_AWS_ECS_TASK_REVISION]: taskMetadata['Revision'], - - [SEMRESATTRS_CLOUD_ACCOUNT_ID]: accountId, - [SEMRESATTRS_CLOUD_REGION]: region, + [ATTR_AWS_ECS_CONTAINER_ARN]: containerArn, + [ATTR_AWS_ECS_CLUSTER_ARN]: clusterArn, + [ATTR_AWS_ECS_LAUNCHTYPE]: launchType?.toLowerCase(), + [ATTR_AWS_ECS_TASK_ARN]: taskArn, + [ATTR_AWS_ECS_TASK_FAMILY]: taskMetadata['Family'], + [ATTR_AWS_ECS_TASK_REVISION]: taskMetadata['Revision'], + + [ATTR_CLOUD_ACCOUNT_ID]: accountId, + [ATTR_CLOUD_REGION]: region, [AdditionalSemanticResourceAttributes.CLOUD_RESOURCE_ID]: containerArn, }; // The availability zone is not available in all Fargate runtimes if (availabilityZone) { - attributes[SEMRESATTRS_CLOUD_AVAILABILITY_ZONE] = availabilityZone; + attributes[ATTR_CLOUD_AVAILABILITY_ZONE] = availabilityZone; } return new Resource(attributes); @@ -222,10 +222,10 @@ export class AwsEcsDetectorSync implements DetectorSync { const logsStreamArn = `arn:aws:logs:${logsRegion}:${awsAccount}:log-group:${logsGroupName}:log-stream:${logsStreamName}`; return new Resource({ - [SEMRESATTRS_AWS_LOG_GROUP_NAMES]: [logsGroupName], - [SEMRESATTRS_AWS_LOG_GROUP_ARNS]: [logsGroupArn], - [SEMRESATTRS_AWS_LOG_STREAM_NAMES]: [logsStreamName], - [SEMRESATTRS_AWS_LOG_STREAM_ARNS]: [logsStreamArn], + [ATTR_AWS_LOG_GROUP_NAMES]: [logsGroupName], + [ATTR_AWS_LOG_GROUP_ARNS]: [logsGroupArn], + [ATTR_AWS_LOG_STREAM_NAMES]: [logsStreamName], + [ATTR_AWS_LOG_STREAM_ARNS]: [logsStreamArn], }); } 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 051d3af5e8..857fb2f217 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEksDetectorSync.ts +++ b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEksDetectorSync.ts @@ -24,13 +24,13 @@ import { ResourceDetectionConfig, } from '@opentelemetry/resources'; import { - SEMRESATTRS_CLOUD_PROVIDER, - SEMRESATTRS_CLOUD_PLATFORM, - SEMRESATTRS_K8S_CLUSTER_NAME, - SEMRESATTRS_CONTAINER_ID, - CLOUDPROVIDERVALUES_AWS, - CLOUDPLATFORMVALUES_AWS_EKS, -} from '@opentelemetry/semantic-conventions'; + ATTR_CLOUD_PROVIDER, + ATTR_CLOUD_PLATFORM, + ATTR_K8S_CLUSTER_NAME, + ATTR_CONTAINER_ID, + CLOUD_PROVIDER_VALUE_AWS, + CLOUD_PLATFORM_VALUE_AWS_EKS, +} from '@opentelemetry/semantic-conventions/incubating'; import * as https from 'https'; import * as fs from 'fs'; import * as util from 'util'; @@ -94,10 +94,10 @@ export class AwsEksDetectorSync implements DetectorSync { return !containerId && !clusterName ? {} : { - [SEMRESATTRS_CLOUD_PROVIDER]: CLOUDPROVIDERVALUES_AWS, - [SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_AWS_EKS, - [SEMRESATTRS_K8S_CLUSTER_NAME]: clusterName || '', - [SEMRESATTRS_CONTAINER_ID]: containerId || '', + [ATTR_CLOUD_PROVIDER]: CLOUD_PROVIDER_VALUE_AWS, + [ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_AWS_EKS, + [ATTR_K8S_CLUSTER_NAME]: clusterName || '', + [ATTR_CONTAINER_ID]: containerId || '', }; } catch (e) { diag.debug('Process is not running on K8S', e); 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 4b85f44bdc..da7187e565 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsLambdaDetectorSync.ts +++ b/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsLambdaDetectorSync.ts @@ -22,14 +22,14 @@ import { ResourceDetectionConfig, } from '@opentelemetry/resources'; import { - SEMRESATTRS_CLOUD_PROVIDER, - SEMRESATTRS_CLOUD_PLATFORM, - SEMRESATTRS_CLOUD_REGION, - SEMRESATTRS_FAAS_VERSION, - SEMRESATTRS_FAAS_NAME, - CLOUDPROVIDERVALUES_AWS, - CLOUDPLATFORMVALUES_AWS_LAMBDA, -} from '@opentelemetry/semantic-conventions'; + ATTR_CLOUD_PROVIDER, + ATTR_CLOUD_PLATFORM, + ATTR_CLOUD_REGION, + ATTR_FAAS_VERSION, + ATTR_FAAS_NAME, + CLOUD_PROVIDER_VALUE_AWS, + CLOUD_PLATFORM_VALUE_AWS_LAMBDA, +} from '@opentelemetry/semantic-conventions/incubating'; /** * The AwsLambdaDetector can be used to detect if a process is running in AWS Lambda @@ -47,18 +47,18 @@ export class AwsLambdaDetectorSync implements DetectorSync { const region = process.env.AWS_REGION; const attributes: ResourceAttributes = { - [SEMRESATTRS_CLOUD_PROVIDER]: String(CLOUDPROVIDERVALUES_AWS), - [SEMRESATTRS_CLOUD_PLATFORM]: String(CLOUDPLATFORMVALUES_AWS_LAMBDA), + [ATTR_CLOUD_PROVIDER]: String(CLOUD_PROVIDER_VALUE_AWS), + [ATTR_CLOUD_PLATFORM]: String(CLOUD_PLATFORM_VALUE_AWS_LAMBDA), }; if (region) { - attributes[SEMRESATTRS_CLOUD_REGION] = region; + attributes[ATTR_CLOUD_REGION] = region; } if (functionName) { - attributes[SEMRESATTRS_FAAS_NAME] = functionName; + attributes[ATTR_FAAS_NAME] = functionName; } if (functionVersion) { - attributes[SEMRESATTRS_FAAS_VERSION] = functionVersion; + attributes[ATTR_FAAS_VERSION] = functionVersion; } return new Resource(attributes); diff --git a/detectors/node/opentelemetry-resource-detector-azure/package.json b/detectors/node/opentelemetry-resource-detector-azure/package.json index 8901bc884e..04b7ee668b 100644 --- a/detectors/node/opentelemetry-resource-detector-azure/package.json +++ b/detectors/node/opentelemetry-resource-detector-azure/package.json @@ -53,5 +53,6 @@ "@opentelemetry/resources": "^1.10.1", "@opentelemetry/semantic-conventions": "^1.27.0" }, - "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-azure#readme" + "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-azure#readme", + "sideEffects": false } diff --git a/detectors/node/opentelemetry-resource-detector-container/package.json b/detectors/node/opentelemetry-resource-detector-container/package.json index 68328e7e7d..7e65aef46a 100644 --- a/detectors/node/opentelemetry-resource-detector-container/package.json +++ b/detectors/node/opentelemetry-resource-detector-container/package.json @@ -56,5 +56,6 @@ "@opentelemetry/resources": "^1.10.0", "@opentelemetry/semantic-conventions": "^1.27.0" }, - "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-container#readme" + "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-container#readme", + "sideEffects": false } diff --git a/detectors/node/opentelemetry-resource-detector-gcp/package.json b/detectors/node/opentelemetry-resource-detector-gcp/package.json index 64f08e1251..260fcd9222 100644 --- a/detectors/node/opentelemetry-resource-detector-gcp/package.json +++ b/detectors/node/opentelemetry-resource-detector-gcp/package.json @@ -61,5 +61,6 @@ "@opentelemetry/semantic-conventions": "^1.27.0", "gcp-metadata": "^6.0.0" }, - "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-gcp#readme" + "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-gcp#readme", + "sideEffects": false } diff --git a/detectors/node/opentelemetry-resource-detector-github/package.json b/detectors/node/opentelemetry-resource-detector-github/package.json index 9e9e6f3c47..b873ae89af 100644 --- a/detectors/node/opentelemetry-resource-detector-github/package.json +++ b/detectors/node/opentelemetry-resource-detector-github/package.json @@ -57,5 +57,6 @@ "dependencies": { "@opentelemetry/resources": "^1.10.0" }, - "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-github#readme" + "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-github#readme", + "sideEffects": false } diff --git a/detectors/node/opentelemetry-resource-detector-instana/package.json b/detectors/node/opentelemetry-resource-detector-instana/package.json index 3aef268d2f..9e12ab749d 100644 --- a/detectors/node/opentelemetry-resource-detector-instana/package.json +++ b/detectors/node/opentelemetry-resource-detector-instana/package.json @@ -58,5 +58,6 @@ "peerDependencies": { "@opentelemetry/api": "^1.3.0" }, - "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-instana#readme" + "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-instana#readme", + "sideEffects": false } diff --git a/metapackages/auto-instrumentations-node/test/register.test.ts b/metapackages/auto-instrumentations-node/test/register.test.ts index 2f952541db..47917c854b 100644 --- a/metapackages/auto-instrumentations-node/test/register.test.ts +++ b/metapackages/auto-instrumentations-node/test/register.test.ts @@ -90,7 +90,7 @@ describe('Register', function () { it('shuts down the NodeSDK when SIGTERM is received', async () => { const runPromise = runWithRegister('./test-app/app-server.js'); const { child } = runPromise; - await waitForString(child.stdout!, 'Finshed request'); + await waitForString(child.stdout!, 'Finished request'); child.kill('SIGTERM'); const { stdout } = await runPromise; diff --git a/metapackages/auto-instrumentations-node/test/test-app/app-server.js b/metapackages/auto-instrumentations-node/test/test-app/app-server.js index 489b4dfb7a..786cf0f175 100644 --- a/metapackages/auto-instrumentations-node/test/test-app/app-server.js +++ b/metapackages/auto-instrumentations-node/test/test-app/app-server.js @@ -27,7 +27,7 @@ const options = { const req = http.request(options); req.end(); req.on('close', () => { - console.log('Finshed request'); + console.log('Finished request'); }); // Make sure there is work on the event loop diff --git a/package-lock.json b/package-lock.json index 5f91ece94e..9932d7393c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38730,7 +38730,7 @@ "dependencies": { "@opentelemetry/core": "^1.26.0", "@opentelemetry/instrumentation": "^0.57.0", - "@opentelemetry/semantic-conventions": "1.27.0", + "@opentelemetry/semantic-conventions": "^1.27.0", "@opentelemetry/sql-common": "^0.40.1", "@types/pg": "8.6.1", "@types/pg-pool": "2.0.6" @@ -38761,14 +38761,6 @@ "@opentelemetry/api": "^1.3.0" } }, - "plugins/node/opentelemetry-instrumentation-pg/node_modules/@opentelemetry/semantic-conventions": { - "version": "1.27.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.27.0.tgz", - "integrity": "sha512-sAay1RrB+ONOem0OZanAR1ZI/k7yDpnOQSQmTMuGImUQb2y8EbSaCJ94FQluM74xoU03vlb2d2U90hZluL6nQg==", - "engines": { - "node": ">=14" - } - }, "plugins/node/opentelemetry-instrumentation-pg/node_modules/@types/mocha": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-7.0.2.tgz", @@ -48806,7 +48798,7 @@ "@opentelemetry/instrumentation": "^0.57.0", "@opentelemetry/sdk-trace-base": "^1.8.0", "@opentelemetry/sdk-trace-node": "^1.8.0", - "@opentelemetry/semantic-conventions": "1.27.0", + "@opentelemetry/semantic-conventions": "^1.27.0", "@opentelemetry/sql-common": "^0.40.1", "@types/mocha": "7.0.2", "@types/node": "18.18.14", @@ -48824,11 +48816,6 @@ "typescript": "4.4.4" }, "dependencies": { - "@opentelemetry/semantic-conventions": { - "version": "1.27.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.27.0.tgz", - "integrity": "sha512-sAay1RrB+ONOem0OZanAR1ZI/k7yDpnOQSQmTMuGImUQb2y8EbSaCJ94FQluM74xoU03vlb2d2U90hZluL6nQg==" - }, "@types/mocha": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-7.0.2.tgz", diff --git a/plugins/node/opentelemetry-instrumentation-pg/package.json b/plugins/node/opentelemetry-instrumentation-pg/package.json index 4698da4a5c..bc2ec76777 100644 --- a/plugins/node/opentelemetry-instrumentation-pg/package.json +++ b/plugins/node/opentelemetry-instrumentation-pg/package.json @@ -71,7 +71,7 @@ "dependencies": { "@opentelemetry/core": "^1.26.0", "@opentelemetry/instrumentation": "^0.57.0", - "@opentelemetry/semantic-conventions": "1.27.0", + "@opentelemetry/semantic-conventions": "^1.27.0", "@opentelemetry/sql-common": "^0.40.1", "@types/pg": "8.6.1", "@types/pg-pool": "2.0.6" diff --git a/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts index 933796be7c..b7cd5d3406 100644 --- a/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts @@ -65,7 +65,7 @@ import { METRIC_DB_CLIENT_OPERATION_DURATION, ATTR_DB_NAMESPACE, ATTR_DB_OPERATION_NAME, -} from '@opentelemetry/semantic-conventions/incubating'; +} from './semconv'; export class PgInstrumentation extends InstrumentationBase { private _operationDuration!: Histogram; diff --git a/plugins/node/opentelemetry-instrumentation-pg/src/semconv.ts b/plugins/node/opentelemetry-instrumentation-pg/src/semconv.ts new file mode 100644 index 0000000000..f7a2ba5624 --- /dev/null +++ b/plugins/node/opentelemetry-instrumentation-pg/src/semconv.ts @@ -0,0 +1,100 @@ +/* + * 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. + */ + +/** + * The name of the connection pool; unique within the instrumented application. In case the connection pool implementation doesn't provide a name, instrumentation **SHOULD** use a combination of parameters that would make the name unique, for example, combining attributes `server.address`, `server.port`, and `db.namespace`, formatted as `server.address:server.port/db.namespace`. Instrumentations that generate connection pool name following different patterns **SHOULD** document it. + * + * @example myDataSource + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ +export const ATTR_DB_CLIENT_CONNECTION_POOL_NAME = + 'db.client.connection.pool.name'; + +/** + * The state of a connection in the pool + * + * @example idle + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ +export const ATTR_DB_CLIENT_CONNECTION_STATE = 'db.client.connection.state'; + +/** + * The name of the database, fully qualified within the server address and port. + * + * @example customers + * @example test.users + * + * @note If a database system has multiple namespace components, they **SHOULD** be concatenated (potentially using database system specific conventions) from most general to most specific namespace component, and more specific namespaces **SHOULD NOT** be captured without the more general namespaces, to ensure that "startswith" queries for the more general namespaces will be valid. + * Semantic conventions for individual database systems **SHOULD** document what `db.namespace` means in the context of that system. + * It is **RECOMMENDED** to capture the value as provided by the application without attempting to do any case normalization. + * This attribute has stability level RELEASE CANDIDATE. + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ +export const ATTR_DB_NAMESPACE = 'db.namespace'; + +/** + * The name of the operation or command being executed. + * + * @example findAndModify + * @example HMSET + * @example SELECT + * + * @note It is **RECOMMENDED** to capture the value as provided by the application without attempting to do any case normalization. + * If the operation name is parsed from the query text, it **SHOULD** be the first operation name found in the query. + * For batch operations, if the individual operations are known to have the same operation name then that operation name **SHOULD** be used prepended by `BATCH `, otherwise `db.operation.name` **SHOULD** be `BATCH` or some other database system specific term if more applicable. + * This attribute has stability level RELEASE CANDIDATE. + * + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ +export const ATTR_DB_OPERATION_NAME = 'db.operation.name'; + +/** + * Enum value "used" for attribute {@link ATTR_DB_CLIENT_CONNECTION_STATE}. + */ +export const DB_CLIENT_CONNECTION_STATE_VALUE_USED = 'used'; + +/** + * Enum value "idle" for attribute {@link ATTR_DB_CLIENT_CONNECTION_STATE}. + */ +export const DB_CLIENT_CONNECTION_STATE_VALUE_IDLE = 'idle'; + +/** + * The number of connections that are currently in state described by the `state` attribute + * + * @experimental This metric is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ +export const METRIC_DB_CLIENT_CONNECTION_COUNT = 'db.client.connection.count'; + +/** + * The number of current pending requests for an open connection + * + * @experimental This metric is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ +export const METRIC_DB_CLIENT_CONNECTION_PENDING_REQUESTS = + 'db.client.connection.pending_requests'; + +/** + * Duration of database client operations. + * + * @note Batch operations **SHOULD** be recorded as a single operation. + * + * @experimental This metric is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. + */ +export const METRIC_DB_CLIENT_OPERATION_DURATION = + 'db.client.operation.duration'; diff --git a/plugins/node/opentelemetry-instrumentation-pg/src/utils.ts b/plugins/node/opentelemetry-instrumentation-pg/src/utils.ts index de21084a95..c4ebd05640 100644 --- a/plugins/node/opentelemetry-instrumentation-pg/src/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-pg/src/utils.ts @@ -42,7 +42,7 @@ import { ATTR_DB_CLIENT_CONNECTION_STATE, DB_CLIENT_CONNECTION_STATE_VALUE_USED, DB_CLIENT_CONNECTION_STATE_VALUE_IDLE, -} from '@opentelemetry/semantic-conventions/incubating'; +} from './semconv'; import { PgClientExtended, PostgresCallback, diff --git a/plugins/node/opentelemetry-instrumentation-pg/test/pg-pool.test.ts b/plugins/node/opentelemetry-instrumentation-pg/test/pg-pool.test.ts index f0ac1508d9..98d9a1b7c8 100644 --- a/plugins/node/opentelemetry-instrumentation-pg/test/pg-pool.test.ts +++ b/plugins/node/opentelemetry-instrumentation-pg/test/pg-pool.test.ts @@ -55,7 +55,7 @@ import { METRIC_DB_CLIENT_CONNECTION_COUNT, METRIC_DB_CLIENT_CONNECTION_PENDING_REQUESTS, METRIC_DB_CLIENT_OPERATION_DURATION, -} from '@opentelemetry/semantic-conventions/incubating'; +} from '../src/semconv'; const memoryExporter = new InMemorySpanExporter(); diff --git a/plugins/node/opentelemetry-instrumentation-pg/test/pg.test.ts b/plugins/node/opentelemetry-instrumentation-pg/test/pg.test.ts index b7169ec785..8fda8a8fb8 100644 --- a/plugins/node/opentelemetry-instrumentation-pg/test/pg.test.ts +++ b/plugins/node/opentelemetry-instrumentation-pg/test/pg.test.ts @@ -56,7 +56,7 @@ import { import { METRIC_DB_CLIENT_OPERATION_DURATION, ATTR_DB_OPERATION_NAME, -} from '@opentelemetry/semantic-conventions/incubating'; +} from '../src/semconv'; import { addSqlCommenterComment } from '@opentelemetry/sql-common'; const memoryExporter = new InMemorySpanExporter();