Skip to content

Commit

Permalink
Merge branch 'main' into feat/instrumentation-pg/use-sem-conv-with-ca…
Browse files Browse the repository at this point in the history
…ret-version
  • Loading branch information
trentm authored Jan 17, 2025
2 parents 67a4217 + 4cf7e6f commit c71d3ba
Show file tree
Hide file tree
Showing 14 changed files with 112 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down Expand Up @@ -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 {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 || '',
});
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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],
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c71d3ba

Please sign in to comment.