Skip to content

Commit 2a8b56f

Browse files
committed
Merge branch 'main' of github.com:open-telemetry/opentelemetry-js-contrib into fix-connection-string-in-pool
2 parents 7774f9b + fd547c8 commit 2a8b56f

File tree

92 files changed

+2383
-1833
lines changed

Some content is hidden

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

92 files changed

+2383
-1833
lines changed

.github/component_owners.yml

Lines changed: 3 additions & 2 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: []
@@ -108,8 +109,8 @@ components:
108109
# Unmaintained
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/SemanticResourceAttributes.ts

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

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

Lines changed: 29 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
*

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

Lines changed: 77 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,29 @@ import * as sinon from 'sinon';
2020
import { awsEcsDetector, AwsEcsDetectorSync } from '../../src';
2121
import {
2222
assertEmptyResource,
23-
assertCloudResource,
2423
assertContainerResource,
2524
} from '@opentelemetry/contrib-test-utils';
2625
import { Resource } from '@opentelemetry/resources';
2726
import {
28-
SEMRESATTRS_CLOUD_PLATFORM,
29-
SEMRESATTRS_AWS_ECS_CONTAINER_ARN,
30-
SEMRESATTRS_AWS_ECS_CLUSTER_ARN,
31-
SEMRESATTRS_AWS_ECS_LAUNCHTYPE,
32-
SEMRESATTRS_AWS_ECS_TASK_ARN,
33-
SEMRESATTRS_AWS_ECS_TASK_REVISION,
34-
SEMRESATTRS_AWS_ECS_TASK_FAMILY,
35-
SEMRESATTRS_AWS_LOG_GROUP_NAMES,
36-
SEMRESATTRS_AWS_LOG_GROUP_ARNS,
37-
SEMRESATTRS_AWS_LOG_STREAM_NAMES,
38-
SEMRESATTRS_AWS_LOG_STREAM_ARNS,
39-
CLOUDPROVIDERVALUES_AWS,
40-
CLOUDPLATFORMVALUES_AWS_ECS,
41-
} from '@opentelemetry/semantic-conventions';
42-
// Patch until the OpenTelemetry SDK is updated to ship this attribute
43-
import { SemanticResourceAttributes as AdditionalSemanticResourceAttributes } from '../../src/detectors/SemanticResourceAttributes';
27+
ATTR_AWS_ECS_CLUSTER_ARN,
28+
ATTR_AWS_ECS_CONTAINER_ARN,
29+
ATTR_AWS_ECS_LAUNCHTYPE,
30+
ATTR_AWS_ECS_TASK_ARN,
31+
ATTR_AWS_ECS_TASK_FAMILY,
32+
ATTR_AWS_ECS_TASK_REVISION,
33+
ATTR_AWS_LOG_GROUP_ARNS,
34+
ATTR_AWS_LOG_GROUP_NAMES,
35+
ATTR_AWS_LOG_STREAM_ARNS,
36+
ATTR_AWS_LOG_STREAM_NAMES,
37+
ATTR_CLOUD_ACCOUNT_ID,
38+
ATTR_CLOUD_AVAILABILITY_ZONE,
39+
ATTR_CLOUD_PLATFORM,
40+
ATTR_CLOUD_PROVIDER,
41+
ATTR_CLOUD_REGION,
42+
ATTR_CLOUD_RESOURCE_ID,
43+
CLOUD_PROVIDER_VALUE_AWS,
44+
CLOUD_PLATFORM_VALUE_AWS_ECS,
45+
} from '../../src/semconv';
4446
import { readFileSync } from 'fs';
4547
import * as os from 'os';
4648
import { join } from 'path';
@@ -65,70 +67,96 @@ const assertEcsResource = (
6567
resource: Resource,
6668
validations: EcsResourceAttributes
6769
) => {
68-
assertCloudResource(resource, {
69-
provider: CLOUDPROVIDERVALUES_AWS,
70-
accountId: validations.accountId,
71-
region: validations.region,
72-
zone: validations.zone,
73-
});
7470
assert.strictEqual(
75-
resource.attributes[SEMRESATTRS_CLOUD_PLATFORM],
76-
CLOUDPLATFORMVALUES_AWS_ECS
71+
resource.attributes[ATTR_CLOUD_PROVIDER],
72+
CLOUD_PROVIDER_VALUE_AWS
73+
);
74+
assert.strictEqual(
75+
resource.attributes[ATTR_CLOUD_PLATFORM],
76+
CLOUD_PLATFORM_VALUE_AWS_ECS
7777
);
78-
if (validations.containerArn)
78+
if (validations.accountId) {
79+
assert.strictEqual(
80+
resource.attributes[ATTR_CLOUD_ACCOUNT_ID],
81+
validations.accountId
82+
);
83+
}
84+
if (validations.region) {
85+
assert.strictEqual(
86+
resource.attributes[ATTR_CLOUD_REGION],
87+
validations.region
88+
);
89+
}
90+
if (validations.zone) {
7991
assert.strictEqual(
80-
resource.attributes[SEMRESATTRS_AWS_ECS_CONTAINER_ARN],
92+
resource.attributes[ATTR_CLOUD_AVAILABILITY_ZONE],
93+
validations.zone
94+
);
95+
}
96+
if (validations.containerArn) {
97+
assert.strictEqual(
98+
resource.attributes[ATTR_AWS_ECS_CONTAINER_ARN],
8199
validations.containerArn
82100
);
83-
assert.strictEqual(
84-
resource.attributes[AdditionalSemanticResourceAttributes.CLOUD_RESOURCE_ID],
85-
validations.containerArn
86-
);
87-
if (validations.clusterArn)
88101
assert.strictEqual(
89-
resource.attributes[SEMRESATTRS_AWS_ECS_CLUSTER_ARN],
102+
resource.attributes[ATTR_CLOUD_RESOURCE_ID],
103+
validations.containerArn
104+
);
105+
}
106+
if (validations.clusterArn) {
107+
assert.strictEqual(
108+
resource.attributes[ATTR_AWS_ECS_CLUSTER_ARN],
90109
validations.clusterArn
91110
);
92-
if (validations.launchType)
111+
}
112+
if (validations.launchType) {
93113
assert.strictEqual(
94-
resource.attributes[SEMRESATTRS_AWS_ECS_LAUNCHTYPE],
114+
resource.attributes[ATTR_AWS_ECS_LAUNCHTYPE],
95115
validations.launchType
96116
);
97-
if (validations.taskArn)
117+
}
118+
if (validations.taskArn) {
98119
assert.strictEqual(
99-
resource.attributes[SEMRESATTRS_AWS_ECS_TASK_ARN],
120+
resource.attributes[ATTR_AWS_ECS_TASK_ARN],
100121
validations.taskArn
101122
);
102-
if (validations.taskFamily)
123+
}
124+
if (validations.taskFamily) {
103125
assert.strictEqual(
104-
resource.attributes[SEMRESATTRS_AWS_ECS_TASK_FAMILY],
126+
resource.attributes[ATTR_AWS_ECS_TASK_FAMILY],
105127
validations.taskFamily
106128
);
107-
if (validations.taskRevision)
129+
}
130+
if (validations.taskRevision) {
108131
assert.strictEqual(
109-
resource.attributes[SEMRESATTRS_AWS_ECS_TASK_REVISION],
132+
resource.attributes[ATTR_AWS_ECS_TASK_REVISION],
110133
validations.taskRevision
111134
);
112-
if (validations.logGroupNames)
135+
}
136+
if (validations.logGroupNames) {
113137
assert.deepEqual(
114-
resource.attributes[SEMRESATTRS_AWS_LOG_GROUP_NAMES],
138+
resource.attributes[ATTR_AWS_LOG_GROUP_NAMES],
115139
validations.logGroupNames
116140
);
117-
if (validations.logGroupArns)
141+
}
142+
if (validations.logGroupArns) {
118143
assert.deepEqual(
119-
resource.attributes[SEMRESATTRS_AWS_LOG_GROUP_ARNS],
144+
resource.attributes[ATTR_AWS_LOG_GROUP_ARNS],
120145
validations.logGroupArns
121146
);
122-
if (validations.logStreamNames)
147+
}
148+
if (validations.logStreamNames) {
123149
assert.deepEqual(
124-
resource.attributes[SEMRESATTRS_AWS_LOG_STREAM_NAMES],
150+
resource.attributes[ATTR_AWS_LOG_STREAM_NAMES],
125151
validations.logStreamNames
126152
);
127-
if (validations.logStreamArns)
153+
}
154+
if (validations.logStreamArns) {
128155
assert.deepEqual(
129-
resource.attributes[SEMRESATTRS_AWS_LOG_STREAM_ARNS],
156+
resource.attributes[ATTR_AWS_LOG_STREAM_ARNS],
130157
validations.logStreamArns
131158
);
159+
}
132160
};
133161

134162
describe('AwsEcsResourceDetector', () => {

0 commit comments

Comments
 (0)