Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
bokuweb authored Feb 8, 2025
2 parents ede2a2c + ce62d8c commit 396fb65
Show file tree
Hide file tree
Showing 24 changed files with 440 additions and 264 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ features for unmaintained components. At least one sponsor is needed to lift the
adding the requested feature. Sponsors are expected to provide reviews for that feature and be responsive on the issue.

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

A component which is unmaintained may be deprecated if there is a problem that is not fixed in a timely manner.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

import { Detector, IResource } from '@opentelemetry/resources';

import { awsEcsDetectorSync } from './AwsEcsDetectorSync';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,27 @@ import {
ResourceAttributes,
} from '@opentelemetry/resources';
import {
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_CONTAINER_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_GROUP_NAMES,
ATTR_AWS_LOG_STREAM_ARNS,
ATTR_AWS_LOG_STREAM_NAMES,
ATTR_CLOUD_ACCOUNT_ID,
ATTR_CLOUD_AVAILABILITY_ZONE,
ATTR_CLOUD_PLATFORM,
ATTR_CLOUD_PROVIDER,
ATTR_CLOUD_REGION,
ATTR_CLOUD_RESOURCE_ID,
ATTR_CONTAINER_ID,
ATTR_CONTAINER_NAME,
CLOUD_PROVIDER_VALUE_AWS,
CLOUD_PLATFORM_VALUE_AWS_ECS,
} from '../semconv';
// Patch until the OpenTelemetry SDK is updated to ship this attribute
import { SemanticResourceAttributes as AdditionalSemanticResourceAttributes } from './SemanticResourceAttributes';
import * as http from 'http';
import * as util from 'util';
import * as fs from 'fs';
Expand Down Expand Up @@ -185,7 +184,7 @@ export class AwsEcsDetectorSync implements DetectorSync {

[ATTR_CLOUD_ACCOUNT_ID]: accountId,
[ATTR_CLOUD_REGION]: region,
[AdditionalSemanticResourceAttributes.CLOUD_RESOURCE_ID]: containerArn,
[ATTR_CLOUD_RESOURCE_ID]: containerArn,
};

// The availability zone is not available in all Fargate runtimes
Expand Down

This file was deleted.

29 changes: 29 additions & 0 deletions detectors/node/opentelemetry-resource-detector-aws/src/semconv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,35 @@ export const ATTR_CLOUD_PROVIDER = 'cloud.provider';
*/
export const ATTR_CLOUD_REGION = 'cloud.region';

/**
* 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)
*
* @example arn:aws:lambda:REGION:ACCOUNT_ID:function:my-function
* @example //run.googleapis.com/projects/PROJECT_ID/locations/LOCATION_ID/services/SERVICE_ID
* @example /subscriptions/<SUBSCRIPTION_GUID>/resourceGroups/<RG>/providers/Microsoft.Web/sites/<FUNCAPP>/functions/<FUNC>
*
* @note On some cloud providers, it may not be possible to determine the full ID at startup,
* so it may be necessary to set `cloud.resource_id` as a span attribute instead.
*
* The exact value to use for `cloud.resource_id` depends on the cloud provider.
* The following well-known definitions **MUST** be used if you set this attribute and they apply:
*
* - **AWS Lambda:** The function [ARN](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html).
* Take care not to use the "invoked ARN" directly but replace any
* [alias suffix](https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html)
* with the resolved function version, as the same runtime instance may be invocable with
* multiple different aliases.
* - **GCP:** The [URI of the resource](https://cloud.google.com/iam/docs/full-resource-names)
* - **Azure:** The [Fully Qualified Resource ID](https://docs.microsoft.com/rest/api/resources/resources/get-by-id) of the invoked function,
* *not* the function app, having the form
* `/subscriptions/<SUBSCRIPTION_GUID>/resourceGroups/<RG>/providers/Microsoft.Web/sites/<FUNCAPP>/functions/<FUNC>`.
* This means that a span attribute **MUST** be used, as an Azure function app can host multiple functions that would usually share
* a TracerProvider.
*
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
*/
export const ATTR_CLOUD_RESOURCE_ID = 'cloud.resource_id';

/**
* 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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,29 @@ import * as sinon from 'sinon';
import { awsEcsDetector, AwsEcsDetectorSync } from '../../src';
import {
assertEmptyResource,
assertCloudResource,
assertContainerResource,
} from '@opentelemetry/contrib-test-utils';
import { Resource } from '@opentelemetry/resources';
import {
SEMRESATTRS_CLOUD_PLATFORM,
SEMRESATTRS_AWS_ECS_CONTAINER_ARN,
SEMRESATTRS_AWS_ECS_CLUSTER_ARN,
SEMRESATTRS_AWS_ECS_LAUNCHTYPE,
SEMRESATTRS_AWS_ECS_TASK_ARN,
SEMRESATTRS_AWS_ECS_TASK_REVISION,
SEMRESATTRS_AWS_ECS_TASK_FAMILY,
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';
// Patch until the OpenTelemetry SDK is updated to ship this attribute
import { SemanticResourceAttributes as AdditionalSemanticResourceAttributes } from '../../src/detectors/SemanticResourceAttributes';
ATTR_AWS_ECS_CLUSTER_ARN,
ATTR_AWS_ECS_CONTAINER_ARN,
ATTR_AWS_ECS_LAUNCHTYPE,
ATTR_AWS_ECS_TASK_ARN,
ATTR_AWS_ECS_TASK_FAMILY,
ATTR_AWS_ECS_TASK_REVISION,
ATTR_AWS_LOG_GROUP_ARNS,
ATTR_AWS_LOG_GROUP_NAMES,
ATTR_AWS_LOG_STREAM_ARNS,
ATTR_AWS_LOG_STREAM_NAMES,
ATTR_CLOUD_ACCOUNT_ID,
ATTR_CLOUD_AVAILABILITY_ZONE,
ATTR_CLOUD_PLATFORM,
ATTR_CLOUD_PROVIDER,
ATTR_CLOUD_REGION,
ATTR_CLOUD_RESOURCE_ID,
CLOUD_PROVIDER_VALUE_AWS,
CLOUD_PLATFORM_VALUE_AWS_ECS,
} from '../../src/semconv';
import { readFileSync } from 'fs';
import * as os from 'os';
import { join } from 'path';
Expand All @@ -65,70 +67,96 @@ const assertEcsResource = (
resource: Resource,
validations: EcsResourceAttributes
) => {
assertCloudResource(resource, {
provider: CLOUDPROVIDERVALUES_AWS,
accountId: validations.accountId,
region: validations.region,
zone: validations.zone,
});
assert.strictEqual(
resource.attributes[SEMRESATTRS_CLOUD_PLATFORM],
CLOUDPLATFORMVALUES_AWS_ECS
resource.attributes[ATTR_CLOUD_PROVIDER],
CLOUD_PROVIDER_VALUE_AWS
);
assert.strictEqual(
resource.attributes[ATTR_CLOUD_PLATFORM],
CLOUD_PLATFORM_VALUE_AWS_ECS
);
if (validations.containerArn)
if (validations.accountId) {
assert.strictEqual(
resource.attributes[ATTR_CLOUD_ACCOUNT_ID],
validations.accountId
);
}
if (validations.region) {
assert.strictEqual(
resource.attributes[ATTR_CLOUD_REGION],
validations.region
);
}
if (validations.zone) {
assert.strictEqual(
resource.attributes[SEMRESATTRS_AWS_ECS_CONTAINER_ARN],
resource.attributes[ATTR_CLOUD_AVAILABILITY_ZONE],
validations.zone
);
}
if (validations.containerArn) {
assert.strictEqual(
resource.attributes[ATTR_AWS_ECS_CONTAINER_ARN],
validations.containerArn
);
assert.strictEqual(
resource.attributes[AdditionalSemanticResourceAttributes.CLOUD_RESOURCE_ID],
validations.containerArn
);
if (validations.clusterArn)
assert.strictEqual(
resource.attributes[SEMRESATTRS_AWS_ECS_CLUSTER_ARN],
resource.attributes[ATTR_CLOUD_RESOURCE_ID],
validations.containerArn
);
}
if (validations.clusterArn) {
assert.strictEqual(
resource.attributes[ATTR_AWS_ECS_CLUSTER_ARN],
validations.clusterArn
);
if (validations.launchType)
}
if (validations.launchType) {
assert.strictEqual(
resource.attributes[SEMRESATTRS_AWS_ECS_LAUNCHTYPE],
resource.attributes[ATTR_AWS_ECS_LAUNCHTYPE],
validations.launchType
);
if (validations.taskArn)
}
if (validations.taskArn) {
assert.strictEqual(
resource.attributes[SEMRESATTRS_AWS_ECS_TASK_ARN],
resource.attributes[ATTR_AWS_ECS_TASK_ARN],
validations.taskArn
);
if (validations.taskFamily)
}
if (validations.taskFamily) {
assert.strictEqual(
resource.attributes[SEMRESATTRS_AWS_ECS_TASK_FAMILY],
resource.attributes[ATTR_AWS_ECS_TASK_FAMILY],
validations.taskFamily
);
if (validations.taskRevision)
}
if (validations.taskRevision) {
assert.strictEqual(
resource.attributes[SEMRESATTRS_AWS_ECS_TASK_REVISION],
resource.attributes[ATTR_AWS_ECS_TASK_REVISION],
validations.taskRevision
);
if (validations.logGroupNames)
}
if (validations.logGroupNames) {
assert.deepEqual(
resource.attributes[SEMRESATTRS_AWS_LOG_GROUP_NAMES],
resource.attributes[ATTR_AWS_LOG_GROUP_NAMES],
validations.logGroupNames
);
if (validations.logGroupArns)
}
if (validations.logGroupArns) {
assert.deepEqual(
resource.attributes[SEMRESATTRS_AWS_LOG_GROUP_ARNS],
resource.attributes[ATTR_AWS_LOG_GROUP_ARNS],
validations.logGroupArns
);
if (validations.logStreamNames)
}
if (validations.logStreamNames) {
assert.deepEqual(
resource.attributes[SEMRESATTRS_AWS_LOG_STREAM_NAMES],
resource.attributes[ATTR_AWS_LOG_STREAM_NAMES],
validations.logStreamNames
);
if (validations.logStreamArns)
}
if (validations.logStreamArns) {
assert.deepEqual(
resource.attributes[SEMRESATTRS_AWS_LOG_STREAM_ARNS],
resource.attributes[ATTR_AWS_LOG_STREAM_ARNS],
validations.logStreamArns
);
}
};

describe('AwsEcsResourceDetector', () => {
Expand Down
Loading

0 comments on commit 396fb65

Please sign in to comment.