Skip to content

Commit 396fb65

Browse files
authored
Merge branch 'main' into patch-1
2 parents ede2a2c + ce62d8c commit 396fb65

File tree

24 files changed

+440
-264
lines changed

24 files changed

+440
-264
lines changed

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/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: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,27 @@ 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';
@@ -185,7 +184,7 @@ export class AwsEcsDetectorSync implements DetectorSync {
185184

186185
[ATTR_CLOUD_ACCOUNT_ID]: accountId,
187186
[ATTR_CLOUD_REGION]: region,
188-
[AdditionalSemanticResourceAttributes.CLOUD_RESOURCE_ID]: containerArn,
187+
[ATTR_CLOUD_RESOURCE_ID]: containerArn,
189188
};
190189

191190
// 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)