Skip to content

Commit

Permalink
Merge branch 'main' into fix/container-detector-prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
blumamir authored Aug 7, 2024
2 parents 75b5f7a + efe3c92 commit 8216f74
Show file tree
Hide file tree
Showing 21 changed files with 137 additions and 86 deletions.
2 changes: 0 additions & 2 deletions .github/component_owners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ components:
detectors/node/opentelemetry-resource-detector-github: []
# Unmaintained
detectors/node/opentelemetry-resource-detector-instana:
- basti1302
- kirrg001
incubator/opentelemetry-sampler-aws-xray:
- carolabadeer
Expand Down Expand Up @@ -144,7 +143,6 @@ components:
plugins/web/opentelemetry-plugin-react-load:
- martinkuba
propagators/opentelemetry-propagator-instana:
- basti1302
- kirrg001
propagators/opentelemetry-propagator-ot-trace: []
# Unmaintained
Expand Down
10 changes: 5 additions & 5 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"detectors/node/opentelemetry-resource-detector-alibaba-cloud": "0.28.10",
"detectors/node/opentelemetry-resource-detector-alibaba-cloud": "0.29.0",
"detectors/node/opentelemetry-resource-detector-aws": "1.5.2",
"detectors/node/opentelemetry-resource-detector-azure": "0.2.9",
"detectors/node/opentelemetry-resource-detector-container": "0.3.11",
"detectors/node/opentelemetry-resource-detector-gcp": "0.29.10",
"detectors/node/opentelemetry-resource-detector-github": "0.28.2",
"detectors/node/opentelemetry-resource-detector-instana": "0.10.0",
"detectors/node/opentelemetry-resource-detector-github": "0.29.0",
"detectors/node/opentelemetry-resource-detector-instana": "0.11.0",
"metapackages/auto-configuration-propagators": "0.2.0",
"metapackages/auto-instrumentations-node": "0.49.0",
"metapackages/auto-instrumentations-node": "0.49.1",
"metapackages/auto-instrumentations-web": "0.40.0",
"packages/baggage-span-processor": "0.3.1",
"packages/opentelemetry-host-metrics": "0.35.3",
Expand All @@ -17,7 +17,7 @@
"packages/opentelemetry-sql-common": "0.40.1",
"packages/opentelemetry-test-utils": "0.40.0",
"packages/winston-transport": "0.5.0",
"plugins/node/instrumentation-amqplib": "0.40.0",
"plugins/node/instrumentation-amqplib": "0.41.0",
"plugins/node/instrumentation-cucumber": "0.8.0",
"plugins/node/instrumentation-dataloader": "0.11.0",
"plugins/node/instrumentation-fs": "0.14.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## [0.29.0](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/resource-detector-alibaba-cloud-v0.28.10...resource-detector-alibaba-cloud-v0.29.0) (2024-08-05)


### ⚠ BREAKING CHANGES

* **detector-alibaba:** change implementation to DetectorSync interface ([#2328](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2328))

### Features

* **detector-alibaba:** change implementation to DetectorSync interface ([#2328](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2328)) ([25e85c7](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/25e85c7b128f7424b51987e9f4c067e0b538fe2f))

## [0.28.10](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/resource-detector-alibaba-cloud-v0.28.9...resource-detector-alibaba-cloud-v0.28.10) (2024-06-06)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentelemetry/resource-detector-alibaba-cloud",
"version": "0.28.10",
"version": "0.29.0",
"description": "OpenTelemetry resource detector for Alibaba Cloud",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
*/

import {
Detector,
DetectorSync,
IResource,
Resource,
ResourceAttributes,
ResourceDetectionConfig,
} from '@opentelemetry/resources';
import {
Expand All @@ -31,14 +33,15 @@ import {
SEMRESATTRS_HOST_NAME,
SEMRESATTRS_HOST_TYPE,
} from '@opentelemetry/semantic-conventions';

import * as http from 'http';

/**
* The AlibabaCloudEcsDetector can be used to detect if a process is running in
* AlibabaCloud ECS and return a {@link Resource} populated with metadata about
* the ECS instance. Returns an empty Resource if detection fails.
*/
class AlibabaCloudEcsDetector implements Detector {
class AlibabaCloudEcsDetector implements DetectorSync {
/**
* See https://www.alibabacloud.com/help/doc-detail/67254.htm for
* documentation about the AlibabaCloud instance identity document.
Expand All @@ -57,7 +60,14 @@ class AlibabaCloudEcsDetector implements Detector {
*
* @param config (unused) The resource detection config
*/
async detect(_config?: ResourceDetectionConfig): Promise<Resource> {
detect(_config?: ResourceDetectionConfig): IResource {
return new Resource({}, this._getAttributes());
}

/** Gets identity and host info and returns them as attribs. Empty object if fails */
async _getAttributes(
_config?: ResourceDetectionConfig
): Promise<ResourceAttributes> {
const {
'owner-account-id': accountId,
'instance-id': instanceId,
Expand All @@ -67,7 +77,7 @@ class AlibabaCloudEcsDetector implements Detector {
} = await this._fetchIdentity();
const hostname = await this._fetchHost();

return new Resource({
return {
[SEMRESATTRS_CLOUD_PROVIDER]: CLOUDPROVIDERVALUES_ALIBABA_CLOUD,
[SEMRESATTRS_CLOUD_PLATFORM]: CLOUDPLATFORMVALUES_ALIBABA_CLOUD_ECS,
[SEMRESATTRS_CLOUD_ACCOUNT_ID]: accountId,
Expand All @@ -76,7 +86,7 @@ class AlibabaCloudEcsDetector implements Detector {
[SEMRESATTRS_HOST_ID]: instanceId,
[SEMRESATTRS_HOST_TYPE]: instanceType,
[SEMRESATTRS_HOST_NAME]: hostname,
});
};
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
* limitations under the License.
*/

export * from './AlibabaCloudEcsDetector';
export { alibabaCloudEcsDetector } from './AlibabaCloudEcsDetector';
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
* limitations under the License.
*/

export * from './detectors';
export { alibabaCloudEcsDetector } from './detectors';
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import * as nock from 'nock';
import * as assert from 'assert';
import { Resource } from '@opentelemetry/resources';
import { CLOUDPROVIDERVALUES_ALIBABA_CLOUD } from '@opentelemetry/semantic-conventions';
import { alibabaCloudEcsDetector } from '../../src';
import {
assertCloudResource,
assertHostResource,
} from '@opentelemetry/contrib-test-utils';
import { alibabaCloudEcsDetector } from '../../src';

const ALIYUN_HOST =
'http://' + alibabaCloudEcsDetector.ALIBABA_CLOUD_IDMS_ENDPOINT;
Expand Down Expand Up @@ -64,6 +64,7 @@ describe('alibabaCloudEcsDetector', () => {
.reply(200, () => mockedHostResponse);

const resource: Resource = await alibabaCloudEcsDetector.detect();
await resource.waitForAsyncAttributes?.();

scope.done();

Expand All @@ -84,56 +85,47 @@ describe('alibabaCloudEcsDetector', () => {
});

describe('with unsuccessful request', () => {
it('should throw when receiving error response code', async () => {
const expectedError = new Error('Failed to load page, status code: 404');
it('should return empty resource when receiving error response code', async () => {
const scope = nock(ALIYUN_HOST)
.persist()
.get(ALIYUN_IDENTITY_PATH)
.reply(200, () => mockedIdentityResponse)
.get(ALIYUN_HOST_PATH)
.reply(404, () => new Error());

try {
await alibabaCloudEcsDetector.detect();
assert.ok(false, 'Expected to throw');
} catch (err) {
assert.deepStrictEqual(err, expectedError);
}
const resource = await alibabaCloudEcsDetector.detect();
await resource.waitForAsyncAttributes?.();

assert.deepStrictEqual(resource.attributes, {});

scope.done();
});

it('should throw when timed out', async () => {
const expectedError = new Error('ECS metadata api request timed out.');
it('should return empty resource when timed out', async () => {
const scope = nock(ALIYUN_HOST)
.get(ALIYUN_IDENTITY_PATH)
.reply(200, () => mockedIdentityResponse)
.get(ALIYUN_HOST_PATH)
.delayConnection(2000)
.reply(200, () => mockedHostResponse);

try {
await alibabaCloudEcsDetector.detect();
assert.ok(false, 'Expected to throw');
} catch (err) {
assert.deepStrictEqual(err, expectedError);
}
const resource = await alibabaCloudEcsDetector.detect();
await resource.waitForAsyncAttributes?.();

assert.deepStrictEqual(resource.attributes, {});

scope.done();
});

it('should throw when replied with an Error', async () => {
const expectedError = new Error('NOT FOUND');
it('should return empty resource when replied with an Error', async () => {
const scope = nock(ALIYUN_HOST)
.get(ALIYUN_IDENTITY_PATH)
.replyWithError(expectedError.message);

try {
await alibabaCloudEcsDetector.detect();
assert.ok(false, 'Expected to throw');
} catch (err) {
assert.deepStrictEqual(err, expectedError);
}
.replyWithError('NOT FOUND');

const resource = await alibabaCloudEcsDetector.detect();
await resource.waitForAsyncAttributes?.();

assert.deepStrictEqual(resource.attributes, {});

scope.done();
});
Expand Down
11 changes: 11 additions & 0 deletions detectors/node/opentelemetry-resource-detector-github/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## [0.29.0](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/resource-detector-github-v0.28.2...resource-detector-github-v0.29.0) (2024-08-05)


### ⚠ BREAKING CHANGES

* **detector-github:** change implementation to DetectorSync interface ([#2336](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2336))

### Features

* **detector-github:** change implementation to DetectorSync interface ([#2336](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2336)) ([d52d421](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/d52d4218235528dcecc706867425b86bac49b1f0))

## [0.28.2](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/resource-detector-github-v0.28.1...resource-detector-github-v0.28.2) (2024-04-25)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentelemetry/resource-detector-github",
"version": "0.28.2",
"version": "0.29.0",
"description": "OpenTelemetry SDK resource detector for GitHub",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
Expand Down Expand Up @@ -54,7 +54,7 @@
"typescript": "4.4.4"
},
"dependencies": {
"@opentelemetry/resources": "^1.0.0"
"@opentelemetry/resources": "^1.10.0"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-github#readme"
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
*/

import {
Detector,
DetectorSync,
IResource,
Resource,
ResourceAttributes,
} from '@opentelemetry/resources';
Expand All @@ -30,7 +31,7 @@ import {
*
* Returns an empty Resource if detection fails.
*/
class GitHubDetector implements Detector {
class GitHubDetector implements DetectorSync {
private _attributes: ResourceAttributes = {};

/**
Expand All @@ -49,12 +50,10 @@ class GitHubDetector implements Detector {
* environment variables:
* https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables
*
* If successful it returns a promise containing a {@link Resource}
* populated with GitHub metadata. Returns a promise containing an
* empty {@link Resource} if the connection fails.
*
* If successful it returns a {@link Resource} populated with GitHub metadata.
* Returns an empty {@link Resource} if the env vars are not present.
*/
async detect(): Promise<Resource> {
detect(): IResource {
this._attributes = {};
this.addAttributeIfExists('github.workflow', process.env.GITHUB_WORKFLOW);
this.addAttributeIfExists('github.run_id', process.env.GITHUB_RUN_ID);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## [0.11.0](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/resource-detector-instana-v0.10.0...resource-detector-instana-v0.11.0) (2024-08-05)


### ⚠ BREAKING CHANGES

* **detector-alibaba:** change implementation to DetectorSync interface ([#2328](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2328))

### Features

* **detector-alibaba:** change implementation to DetectorSync interface ([#2328](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2328)) ([25e85c7](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/25e85c7b128f7424b51987e9f4c067e0b538fe2f))

## [0.10.0](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/resource-detector-instana-v0.9.0...resource-detector-instana-v0.10.0) (2024-06-06)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentelemetry/resource-detector-instana",
"version": "0.10.0",
"version": "0.11.0",
"description": "OpenTelemetry SDK resource detector for Instana",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
Expand Down Expand Up @@ -51,7 +51,7 @@
"typescript": "4.4.4"
},
"dependencies": {
"@opentelemetry/resources": "^1.0.0",
"@opentelemetry/resources": "^1.10.0",
"@opentelemetry/semantic-conventions": "^1.22.0"
},
"peerDependencies": {
Expand Down
10 changes: 10 additions & 0 deletions metapackages/auto-instrumentations-node/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## [0.49.1](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/auto-instrumentations-node-v0.49.0...auto-instrumentations-node-v0.49.1) (2024-08-05)


### Dependencies

* The following workspace dependencies were updated
* dependencies
* @opentelemetry/instrumentation-amqplib bumped from ^0.40.0 to ^0.41.0
* @opentelemetry/resource-detector-alibaba-cloud bumped from ^0.28.10 to ^0.29.0

## [0.49.0](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/auto-instrumentations-node-v0.48.0...auto-instrumentations-node-v0.49.0) (2024-07-23)


Expand Down
6 changes: 3 additions & 3 deletions metapackages/auto-instrumentations-node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentelemetry/auto-instrumentations-node",
"version": "0.49.0",
"version": "0.49.1",
"description": "Metapackage which bundles opentelemetry node core and contrib instrumentations",
"author": "OpenTelemetry Authors",
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/metapackages/auto-instrumentations-node#readme",
Expand Down Expand Up @@ -50,7 +50,7 @@
},
"dependencies": {
"@opentelemetry/instrumentation": "^0.52.0",
"@opentelemetry/instrumentation-amqplib": "^0.40.0",
"@opentelemetry/instrumentation-amqplib": "^0.41.0",
"@opentelemetry/instrumentation-aws-lambda": "^0.43.0",
"@opentelemetry/instrumentation-aws-sdk": "^0.43.1",
"@opentelemetry/instrumentation-bunyan": "^0.40.0",
Expand Down Expand Up @@ -89,7 +89,7 @@
"@opentelemetry/instrumentation-tedious": "^0.12.0",
"@opentelemetry/instrumentation-undici": "^0.4.0",
"@opentelemetry/instrumentation-winston": "^0.39.0",
"@opentelemetry/resource-detector-alibaba-cloud": "^0.28.10",
"@opentelemetry/resource-detector-alibaba-cloud": "^0.29.0",
"@opentelemetry/resource-detector-aws": "^1.5.2",
"@opentelemetry/resource-detector-azure": "^0.2.9",
"@opentelemetry/resource-detector-container": "^0.3.11",
Expand Down
Loading

0 comments on commit 8216f74

Please sign in to comment.