Skip to content

Commit e1698e1

Browse files
committed
Merge branch 'main' of github.com:open-telemetry/opentelemetry-js-contrib
2 parents bf73ff5 + 8a5c214 commit e1698e1

File tree

95 files changed

+2613
-1988
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+2613
-1988
lines changed

.github/component_owners.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ components:
8787
plugins/node/opentelemetry-instrumentation-express:
8888
- JamieDanielson
8989
- pkanal
90+
- raphael-theriault-swi
9091
plugins/node/opentelemetry-instrumentation-fastify: []
9192
# Unmaintained
9293
plugins/node/opentelemetry-instrumentation-generic-pool: []
@@ -104,12 +105,12 @@ components:
104105
# Unmaintained
105106
plugins/node/opentelemetry-instrumentation-memcached: []
106107
# Unmaintained
107-
plugins/node/opentelemetry-instrumentation-mongodb: []
108-
# Unmaintained
108+
plugins/node/opentelemetry-instrumentation-mongodb:
109+
- onurtemizkan
109110
plugins/node/opentelemetry-instrumentation-mysql: []
110111
# Unmaintained
111-
plugins/node/opentelemetry-instrumentation-mysql2: []
112-
# Unmaintained
112+
plugins/node/opentelemetry-instrumentation-mysql2:
113+
- raphael-theriault-swi
113114
plugins/node/opentelemetry-instrumentation-nestjs-core: []
114115
# Unmaintained
115116
plugins/node/opentelemetry-instrumentation-net:

.github/workflows/unit-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
runs-on: ubuntu-latest
4545
services:
4646
memcached:
47-
image: memcached:1.6.34-alpine
47+
image: memcached:1.6.36-alpine
4848
ports:
4949
- 11211:11211
5050
mongo:

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ features for unmaintained components. At least one sponsor is needed to lift the
238238
adding the requested feature. Sponsors are expected to provide reviews for that feature and be responsive on the issue.
239239

240240
Components marked as unmaintained still receive semantic conventions updates and bugfixes where possible.
241-
[@open-telemetry/javascript-triagers](https://github.com/orgs/open-telemetry/teams/javascript-triagers) may add the
241+
[@open-telemetry/javascript-contrib-triagers](https://github.com/orgs/open-telemetry/teams/javascript-contrib-triagers) may add the
242242
`type:semconv-update` or `bug` label to mark them as exempt from being auto-closed within two weeks.
243243

244244
A component which is unmaintained may be deprecated if there is a problem that is not fixed in a timely manner.

detectors/node/opentelemetry-resource-detector-aws/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"@opentelemetry/api": "^1.0.0",
4545
"@opentelemetry/contrib-test-utils": "^0.45.0",
4646
"@opentelemetry/instrumentation-fs": "^0.19.0",
47-
"@opentelemetry/instrumentation-http": "^0.57.0",
47+
"@opentelemetry/instrumentation-http": "^0.57.1",
4848
"@types/mocha": "8.2.3",
4949
"@types/node": "18.18.14",
5050
"@types/sinon": "10.0.20",

detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetector.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616

1717
import { Detector, IResource } from '@opentelemetry/resources';
18-
1918
import { awsEcsDetectorSync } from './AwsEcsDetectorSync';
2019

2120
/**

detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetectorSync.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,31 @@ import {
2323
ResourceAttributes,
2424
} from '@opentelemetry/resources';
2525
import {
26-
ATTR_CLOUD_PROVIDER,
27-
ATTR_CLOUD_PLATFORM,
28-
ATTR_CONTAINER_ID,
29-
ATTR_CONTAINER_NAME,
30-
ATTR_AWS_ECS_CONTAINER_ARN,
3126
ATTR_AWS_ECS_CLUSTER_ARN,
27+
ATTR_AWS_ECS_CONTAINER_ARN,
3228
ATTR_AWS_ECS_LAUNCHTYPE,
3329
ATTR_AWS_ECS_TASK_ARN,
3430
ATTR_AWS_ECS_TASK_FAMILY,
3531
ATTR_AWS_ECS_TASK_REVISION,
36-
ATTR_CLOUD_ACCOUNT_ID,
37-
ATTR_CLOUD_REGION,
38-
ATTR_CLOUD_AVAILABILITY_ZONE,
39-
ATTR_AWS_LOG_GROUP_NAMES,
4032
ATTR_AWS_LOG_GROUP_ARNS,
41-
ATTR_AWS_LOG_STREAM_NAMES,
33+
ATTR_AWS_LOG_GROUP_NAMES,
4234
ATTR_AWS_LOG_STREAM_ARNS,
35+
ATTR_AWS_LOG_STREAM_NAMES,
36+
ATTR_CLOUD_ACCOUNT_ID,
37+
ATTR_CLOUD_AVAILABILITY_ZONE,
38+
ATTR_CLOUD_PLATFORM,
39+
ATTR_CLOUD_PROVIDER,
40+
ATTR_CLOUD_REGION,
41+
ATTR_CLOUD_RESOURCE_ID,
42+
ATTR_CONTAINER_ID,
43+
ATTR_CONTAINER_NAME,
4344
CLOUD_PROVIDER_VALUE_AWS,
4445
CLOUD_PLATFORM_VALUE_AWS_ECS,
4546
} from '../semconv';
46-
// Patch until the OpenTelemetry SDK is updated to ship this attribute
47-
import { SemanticResourceAttributes as AdditionalSemanticResourceAttributes } from './SemanticResourceAttributes';
4847
import * as http from 'http';
4948
import * as util from 'util';
5049
import * as fs from 'fs';
5150
import * as os from 'os';
52-
import { getEnv } from '@opentelemetry/core';
5351

5452
const HTTP_TIMEOUT_IN_MS = 1000;
5553

@@ -78,8 +76,10 @@ export class AwsEcsDetectorSync implements DetectorSync {
7876
}
7977

8078
private async _getAttributes(): Promise<ResourceAttributes> {
81-
const env = getEnv();
82-
if (!env.ECS_CONTAINER_METADATA_URI_V4 && !env.ECS_CONTAINER_METADATA_URI) {
79+
if (
80+
!process.env.ECS_CONTAINER_METADATA_URI_V4 &&
81+
!process.env.ECS_CONTAINER_METADATA_URI
82+
) {
8383
diag.debug('AwsEcsDetector failed: Process is not on ECS');
8484
return {};
8585
}
@@ -90,7 +90,7 @@ export class AwsEcsDetectorSync implements DetectorSync {
9090
[ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_AWS_ECS,
9191
}).merge(await AwsEcsDetectorSync._getContainerIdAndHostnameResource());
9292

93-
const metadataUrl = getEnv().ECS_CONTAINER_METADATA_URI_V4;
93+
const metadataUrl = process.env.ECS_CONTAINER_METADATA_URI_V4;
9494
if (metadataUrl) {
9595
const [containerMetadata, taskMetadata] = await Promise.all([
9696
AwsEcsDetectorSync._getUrlAsJson(metadataUrl),
@@ -185,7 +185,7 @@ export class AwsEcsDetectorSync implements DetectorSync {
185185

186186
[ATTR_CLOUD_ACCOUNT_ID]: accountId,
187187
[ATTR_CLOUD_REGION]: region,
188-
[AdditionalSemanticResourceAttributes.CLOUD_RESOURCE_ID]: containerArn,
188+
[ATTR_CLOUD_RESOURCE_ID]: containerArn,
189189
};
190190

191191
// The availability zone is not available in all Fargate runtimes

detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsLambdaDetectorSync.ts

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@ import {
2222
ResourceDetectionConfig,
2323
} from '@opentelemetry/resources';
2424
import {
25-
ATTR_CLOUD_PROVIDER,
25+
ATTR_AWS_LOG_GROUP_NAMES,
2626
ATTR_CLOUD_PLATFORM,
27+
ATTR_CLOUD_PROVIDER,
2728
ATTR_CLOUD_REGION,
28-
ATTR_FAAS_VERSION,
29+
ATTR_FAAS_INSTANCE,
2930
ATTR_FAAS_NAME,
31+
ATTR_FAAS_MAX_MEMORY,
32+
ATTR_FAAS_VERSION,
3033
CLOUD_PROVIDER_VALUE_AWS,
3134
CLOUD_PLATFORM_VALUE_AWS_LAMBDA,
3235
} from '../semconv';
@@ -38,27 +41,37 @@ import {
3841
*/
3942
export class AwsLambdaDetectorSync implements DetectorSync {
4043
detect(_config?: ResourceDetectionConfig): IResource {
41-
const functionName = process.env.AWS_LAMBDA_FUNCTION_NAME;
42-
if (!functionName) {
44+
// Check if running inside AWS Lambda environment
45+
const executionEnv = process.env.AWS_EXECUTION_ENV;
46+
if (!executionEnv?.startsWith('AWS_Lambda_')) {
4347
return Resource.empty();
4448
}
4549

46-
const functionVersion = process.env.AWS_LAMBDA_FUNCTION_VERSION;
50+
// These environment variables are guaranteed to be present in Lambda environment
51+
// https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-runtime
4752
const region = process.env.AWS_REGION;
53+
const functionName = process.env.AWS_LAMBDA_FUNCTION_NAME;
54+
const functionVersion = process.env.AWS_LAMBDA_FUNCTION_VERSION;
55+
const memorySize = process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE;
56+
57+
// These environment variables are not available in Lambda SnapStart functions
58+
const logGroupName = process.env.AWS_LAMBDA_LOG_GROUP_NAME;
59+
const logStreamName = process.env.AWS_LAMBDA_LOG_STREAM_NAME;
4860

4961
const attributes: ResourceAttributes = {
50-
[ATTR_CLOUD_PROVIDER]: String(CLOUD_PROVIDER_VALUE_AWS),
51-
[ATTR_CLOUD_PLATFORM]: String(CLOUD_PLATFORM_VALUE_AWS_LAMBDA),
62+
[ATTR_CLOUD_PROVIDER]: CLOUD_PROVIDER_VALUE_AWS,
63+
[ATTR_CLOUD_PLATFORM]: CLOUD_PLATFORM_VALUE_AWS_LAMBDA,
64+
[ATTR_CLOUD_REGION]: region,
65+
[ATTR_FAAS_NAME]: functionName,
66+
[ATTR_FAAS_VERSION]: functionVersion,
67+
[ATTR_FAAS_MAX_MEMORY]: parseInt(memorySize!) * 1024 * 1024,
5268
};
53-
if (region) {
54-
attributes[ATTR_CLOUD_REGION] = region;
55-
}
5669

57-
if (functionName) {
58-
attributes[ATTR_FAAS_NAME] = functionName;
70+
if (logGroupName) {
71+
attributes[ATTR_AWS_LOG_GROUP_NAMES] = [logGroupName];
5972
}
60-
if (functionVersion) {
61-
attributes[ATTR_FAAS_VERSION] = functionVersion;
73+
if (logStreamName) {
74+
attributes[ATTR_FAAS_INSTANCE] = logStreamName;
6275
}
6376

6477
return new Resource(attributes);

detectors/node/opentelemetry-resource-detector-aws/src/detectors/SemanticResourceAttributes.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

detectors/node/opentelemetry-resource-detector-aws/src/semconv.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,35 @@ export const ATTR_CLOUD_PROVIDER = 'cloud.provider';
165165
*/
166166
export const ATTR_CLOUD_REGION = 'cloud.region';
167167

168+
/**
169+
* Cloud provider-specific native identifier of the monitored cloud resource (e.g. an [ARN](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html) on AWS, a [fully qualified resource ID](https://learn.microsoft.com/rest/api/resources/resources/get-by-id) on Azure, a [full resource name](https://cloud.google.com/apis/design/resource_names#full_resource_name) on GCP)
170+
*
171+
* @example arn:aws:lambda:REGION:ACCOUNT_ID:function:my-function
172+
* @example //run.googleapis.com/projects/PROJECT_ID/locations/LOCATION_ID/services/SERVICE_ID
173+
* @example /subscriptions/<SUBSCRIPTION_GUID>/resourceGroups/<RG>/providers/Microsoft.Web/sites/<FUNCAPP>/functions/<FUNC>
174+
*
175+
* @note On some cloud providers, it may not be possible to determine the full ID at startup,
176+
* so it may be necessary to set `cloud.resource_id` as a span attribute instead.
177+
*
178+
* The exact value to use for `cloud.resource_id` depends on the cloud provider.
179+
* The following well-known definitions **MUST** be used if you set this attribute and they apply:
180+
*
181+
* - **AWS Lambda:** The function [ARN](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html).
182+
* Take care not to use the "invoked ARN" directly but replace any
183+
* [alias suffix](https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html)
184+
* with the resolved function version, as the same runtime instance may be invocable with
185+
* multiple different aliases.
186+
* - **GCP:** The [URI of the resource](https://cloud.google.com/iam/docs/full-resource-names)
187+
* - **Azure:** The [Fully Qualified Resource ID](https://docs.microsoft.com/rest/api/resources/resources/get-by-id) of the invoked function,
188+
* *not* the function app, having the form
189+
* `/subscriptions/<SUBSCRIPTION_GUID>/resourceGroups/<RG>/providers/Microsoft.Web/sites/<FUNCAPP>/functions/<FUNC>`.
190+
* This means that a span attribute **MUST** be used, as an Azure function app can host multiple functions that would usually share
191+
* a TracerProvider.
192+
*
193+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
194+
*/
195+
export const ATTR_CLOUD_RESOURCE_ID = 'cloud.resource_id';
196+
168197
/**
169198
* 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.
170199
*
@@ -210,6 +239,28 @@ export const ATTR_CONTAINER_NAME = 'container.name';
210239
*/
211240
export const ATTR_FAAS_NAME = 'faas.name';
212241

242+
/**
243+
* The execution environment ID as a string, that will be potentially reused for other invocations to the same function/function version.
244+
*
245+
* @example 2021/06/28/[$LATEST]2f399eb14537447da05ab2a2e39309de
246+
*
247+
* @note * **AWS Lambda:** Use the (full) log stream name.
248+
*
249+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
250+
*/
251+
export const ATTR_FAAS_INSTANCE = 'faas.instance';
252+
253+
/**
254+
* The amount of memory available to the serverless function converted to Bytes.
255+
*
256+
* @example 134217728
257+
*
258+
* @note It's recommended to set this attribute since e.g. too little memory can easily stop a Java AWS Lambda function from working correctly. On AWS Lambda, the environment variable `AWS_LAMBDA_FUNCTION_MEMORY_SIZE` provides this information (which must be multiplied by 1,048,576).
259+
*
260+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
261+
*/
262+
export const ATTR_FAAS_MAX_MEMORY = 'faas.max_memory';
263+
213264
/**
214265
* The immutable version of the function being executed.
215266
*

0 commit comments

Comments
 (0)