diff --git a/packages/opentelemetry-resource-detector-aws/.eslintignore b/packages/opentelemetry-resource-detector-aws/.eslintignore
deleted file mode 100644
index 378eac25d3..0000000000
--- a/packages/opentelemetry-resource-detector-aws/.eslintignore
+++ /dev/null
@@ -1 +0,0 @@
-build
diff --git a/packages/opentelemetry-resource-detector-aws/.eslintrc.js b/packages/opentelemetry-resource-detector-aws/.eslintrc.js
deleted file mode 100644
index 9dfe62f9b8..0000000000
--- a/packages/opentelemetry-resource-detector-aws/.eslintrc.js
+++ /dev/null
@@ -1,9 +0,0 @@
-module.exports = {
- "env": {
- "mocha": true,
- "commonjs": true,
- "node": true,
- "browser": true
- },
- ...require('../../eslint.config.js')
-}
diff --git a/packages/opentelemetry-resource-detector-aws/.npmignore b/packages/opentelemetry-resource-detector-aws/.npmignore
deleted file mode 100644
index 9505ba9450..0000000000
--- a/packages/opentelemetry-resource-detector-aws/.npmignore
+++ /dev/null
@@ -1,4 +0,0 @@
-/bin
-/coverage
-/doc
-/test
diff --git a/packages/opentelemetry-resource-detector-aws/LICENSE b/packages/opentelemetry-resource-detector-aws/LICENSE
deleted file mode 100644
index 6b91a297c8..0000000000
--- a/packages/opentelemetry-resource-detector-aws/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [2020] OpenTelemetry Authors
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/packages/opentelemetry-resource-detector-aws/README.md b/packages/opentelemetry-resource-detector-aws/README.md
deleted file mode 100644
index 757ba64a3d..0000000000
--- a/packages/opentelemetry-resource-detector-aws/README.md
+++ /dev/null
@@ -1,60 +0,0 @@
-# OpenTelemetry Resource Detector for AWS
-
-[![NPM Published Version][npm-img]][npm-url]
-[![dependencies][dependencies-image]][dependencies-url]
-[![devDependencies][devDependencies-image]][devDependencies-url]
-[![Apache License][license-image]][license-image]
-
-The OpenTelemetry Resource is an immutable representation of the entity producing telemetry. For example, a process producing telemetry that is running in a container on Kubernetes has a Pod name, it is in a namespace and possibly is part of a Deployment which also has a name. All three of these attributes can be included in the `Resource`.
-
-[This document][resource-semantic_conventions] defines standard attributes for resources.
-
-## Installation
-
-```bash
-npm install --save @opentelemetry/resource-detector-aws
-```
-
-## Usage
-
-```typescript
-import { detectResources } from '@opentelemetry/resources';
-import { awsEc2Detector } from '@opentelemetry/resource-detector-aws'
-const resource = await detectResources({
- detectors: [awsEc2Detector],
-})
-
-const tracerProvider = new NodeTracerProvider({ resource });
-```
-
-## Available detectors
-
-- `awsBeanstalkDetector`: Populates `service` for processes running on [AWS Elastic Beanstalk](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/Welcome.html)
-- `awsEc2Detector`: Populates `cloud` and `host` for processes running on [Amazon EC2](https://aws.amazon.com/ec2/), including abstractions such as ECS on EC2. Notably, it does not populate anything on AWS Fargate
-- `awsEcsDetector`: Populates `container` for containers running on [Amazon ECS](https://aws.amazon.com/ecs/)
-- `awsEksDetector`: Populates `container` and `k8s.cluster_name` for containers running on [Amazon EKS](https://aws.amazon.com/eks/)
- - `k8s.cluster_name` is not always available depending on the configuration of CloudWatch monitoring for the EKS cluster
-- `awsLambdaDetector`: Populates `faas` and `cloud` for functions running on [AWS Lambda](https://aws.amazon.com/lambda/)
- - `faas.id` is currently not populated as it is not provided by the runtime at startup
-
-## Useful links
-
-- For more information on OpenTelemetry, visit:
-- For more about OpenTelemetry JavaScript:
-- For help or feedback on this project, join us in [GitHub Discussions][discussions-url]
-
-## License
-
-Apache 2.0 - See [LICENSE][license-url] for more information.
-
-[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions
-[license-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/LICENSE
-[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
-[dependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js.svg?path=packages%2Fopentelemetry-resources
-[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-resources
-[devDependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js.svg?path=packages%2Fopentelemetry-resources&type=dev
-[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-resources&type=dev
-[npm-url]: https://www.npmjs.com/package/@opentelemetry/resources
-[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fresources.svg
-
-[resource-semantic_conventions]: https://github.com/open-telemetry/opentelemetry-specification/tree/master/specification/resource/semantic_conventions
diff --git a/packages/opentelemetry-resource-detector-aws/package.json b/packages/opentelemetry-resource-detector-aws/package.json
deleted file mode 100644
index d4b10bfc86..0000000000
--- a/packages/opentelemetry-resource-detector-aws/package.json
+++ /dev/null
@@ -1,63 +0,0 @@
-{
- "name": "@opentelemetry/resource-detector-aws",
- "version": "0.24.0",
- "description": "OpenTelemetry SDK resource detector for AWS",
- "main": "build/src/index.js",
- "types": "build/src/index.d.ts",
- "repository": "open-telemetry/opentelemetry-js",
- "scripts": {
- "compile": "tsc --build",
- "clean": "tsc --build --clean",
- "lint": "eslint . --ext .ts",
- "lint:fix": "eslint . --ext .ts --fix",
- "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
- "tdd": "npm run test -- --watch-extensions ts --watch",
- "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../",
- "version": "node ../../scripts/version-update.js"
- },
- "keywords": [
- "opentelemetry",
- "nodejs",
- "resources",
- "stats",
- "profiling"
- ],
- "author": "OpenTelemetry Authors",
- "license": "Apache-2.0",
- "engines": {
- "node": ">=8.0.0"
- },
- "files": [
- "build/src/**/*.js",
- "build/src/**/*.js.map",
- "build/src/**/*.d.ts",
- "doc",
- "LICENSE",
- "README.md"
- ],
- "publishConfig": {
- "access": "public"
- },
- "devDependencies": {
- "@opentelemetry/api": "^1.0.2",
- "@types/mocha": "8.2.3",
- "@types/node": "14.17.9",
- "@types/sinon": "10.0.2",
- "codecov": "3.8.3",
- "mocha": "7.2.0",
- "nock": "12.0.3",
- "nyc": "15.1.0",
- "rimraf": "3.0.2",
- "sinon": "11.1.2",
- "ts-mocha": "8.0.0",
- "typescript": "4.3.5"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.0.2"
- },
- "dependencies": {
- "@opentelemetry/core": "0.24.0",
- "@opentelemetry/resources": "0.24.0",
- "@opentelemetry/semantic-conventions": "0.24.0"
- }
-}
diff --git a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetector.ts b/packages/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetector.ts
deleted file mode 100644
index b40c830e5a..0000000000
--- a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetector.ts
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import { diag } from '@opentelemetry/api';
-import {
- Detector,
- Resource,
- ResourceDetectionConfig,
-} from '@opentelemetry/resources';
-import {
- CloudProviderValues,
- CloudPlatformValues,
- SemanticResourceAttributes,
-} from '@opentelemetry/semantic-conventions';
-import * as fs from 'fs';
-import * as util from 'util';
-
-/**
- * The AwsBeanstalkDetector can be used to detect if a process is running in AWS Elastic
- * Beanstalk and return a {@link Resource} populated with data about the beanstalk
- * plugins of AWS X-Ray. Returns an empty Resource if detection fails.
- *
- * See https://docs.amazonaws.cn/en_us/xray/latest/devguide/xray-guide.pdf
- * for more details about detecting information of Elastic Beanstalk plugins
- */
-
-const DEFAULT_BEANSTALK_CONF_PATH =
- '/var/elasticbeanstalk/xray/environment.conf';
-const WIN_OS_BEANSTALK_CONF_PATH =
- 'C:\\Program Files\\Amazon\\XRay\\environment.conf';
-
-export class AwsBeanstalkDetector implements Detector {
- BEANSTALK_CONF_PATH: string;
- private static readFileAsync = util.promisify(fs.readFile);
- private static fileAccessAsync = util.promisify(fs.access);
-
- constructor() {
- if (process.platform === 'win32') {
- this.BEANSTALK_CONF_PATH = WIN_OS_BEANSTALK_CONF_PATH;
- } else {
- this.BEANSTALK_CONF_PATH = DEFAULT_BEANSTALK_CONF_PATH;
- }
- }
-
- async detect(_config?: ResourceDetectionConfig): Promise {
- try {
- await AwsBeanstalkDetector.fileAccessAsync(
- this.BEANSTALK_CONF_PATH,
- fs.constants.R_OK
- );
-
- const rawData = await AwsBeanstalkDetector.readFileAsync(
- this.BEANSTALK_CONF_PATH,
- 'utf8'
- );
- const parsedData = JSON.parse(rawData);
-
- return new Resource({
- [SemanticResourceAttributes.CLOUD_PROVIDER]: CloudProviderValues.AWS,
- [SemanticResourceAttributes.CLOUD_PLATFORM]:
- CloudPlatformValues.AWS_ELASTIC_BEANSTALK,
- [SemanticResourceAttributes.SERVICE_NAME]:
- CloudPlatformValues.AWS_ELASTIC_BEANSTALK,
- [SemanticResourceAttributes.SERVICE_NAMESPACE]: parsedData.environment_name,
- [SemanticResourceAttributes.SERVICE_VERSION]: parsedData.version_label,
- [SemanticResourceAttributes.SERVICE_INSTANCE_ID]: parsedData.deployment_id,
- });
- } catch (e) {
- diag.debug(`AwsBeanstalkDetector failed: ${e.message}`);
- return Resource.empty();
- }
- }
-}
-
-export const awsBeanstalkDetector = new AwsBeanstalkDetector();
diff --git a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEc2Detector.ts b/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEc2Detector.ts
deleted file mode 100644
index 7be914738a..0000000000
--- a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEc2Detector.ts
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import {
- Detector,
- Resource,
- ResourceDetectionConfig,
-} from '@opentelemetry/resources';
-import {
- CloudProviderValues,
- CloudPlatformValues,
- SemanticResourceAttributes,
-} from '@opentelemetry/semantic-conventions';
-import * as http from 'http';
-
-/**
- * The AwsEc2Detector can be used to detect if a process is running in AWS EC2
- * and return a {@link Resource} populated with metadata about the EC2
- * instance. Returns an empty Resource if detection fails.
- */
-class AwsEc2Detector implements Detector {
- /**
- * See https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-identity-documents.html
- * for documentation about the AWS instance identity document
- * and standard of IMDSv2.
- */
- readonly AWS_IDMS_ENDPOINT = '169.254.169.254';
- readonly AWS_INSTANCE_TOKEN_DOCUMENT_PATH = '/latest/api/token';
- readonly AWS_INSTANCE_IDENTITY_DOCUMENT_PATH =
- '/latest/dynamic/instance-identity/document';
- readonly AWS_INSTANCE_HOST_DOCUMENT_PATH = '/latest/meta-data/hostname';
- readonly AWS_METADATA_TTL_HEADER = 'X-aws-ec2-metadata-token-ttl-seconds';
- readonly AWS_METADATA_TOKEN_HEADER = 'X-aws-ec2-metadata-token';
- readonly MILLISECOND_TIME_OUT = 1000;
-
- /**
- * Attempts to connect and obtain an AWS instance Identity document. If the
- * connection is successful it returns a promise containing a {@link Resource}
- * populated with instance metadata. Returns a promise containing an
- * empty {@link Resource} if the connection or parsing of the identity
- * document fails.
- *
- * @param config (unused) The resource detection config
- */
- async detect(_config?: ResourceDetectionConfig): Promise {
- const token = await this._fetchToken();
- const {
- accountId,
- instanceId,
- instanceType,
- region,
- availabilityZone,
- } = await this._fetchIdentity(token);
- const hostname = await this._fetchHost(token);
-
- return new Resource({
- [SemanticResourceAttributes.CLOUD_PROVIDER]: CloudProviderValues.AWS,
- [SemanticResourceAttributes.CLOUD_PLATFORM]: CloudPlatformValues.AWS_EC2,
- [SemanticResourceAttributes.CLOUD_ACCOUNT_ID]: accountId,
- [SemanticResourceAttributes.CLOUD_REGION]: region,
- [SemanticResourceAttributes.CLOUD_AVAILABILITY_ZONE]: availabilityZone,
- [SemanticResourceAttributes.HOST_ID]: instanceId,
- [SemanticResourceAttributes.HOST_TYPE]: instanceType,
- [SemanticResourceAttributes.HOST_NAME]: hostname,
- });
- }
-
- private async _fetchToken(): Promise {
- const options = {
- host: this.AWS_IDMS_ENDPOINT,
- path: this.AWS_INSTANCE_TOKEN_DOCUMENT_PATH,
- method: 'PUT',
- timeout: this.MILLISECOND_TIME_OUT,
- headers: {
- [this.AWS_METADATA_TTL_HEADER]: '60',
- },
- };
- return await this._fetchString(options);
- }
-
- private async _fetchIdentity(token: string): Promise {
- const options = {
- host: this.AWS_IDMS_ENDPOINT,
- path: this.AWS_INSTANCE_IDENTITY_DOCUMENT_PATH,
- method: 'GET',
- timeout: this.MILLISECOND_TIME_OUT,
- headers: {
- [this.AWS_METADATA_TOKEN_HEADER]: token,
- },
- };
- const identity = await this._fetchString(options);
- return JSON.parse(identity);
- }
-
- private async _fetchHost(token: string): Promise {
- const options = {
- host: this.AWS_IDMS_ENDPOINT,
- path: this.AWS_INSTANCE_HOST_DOCUMENT_PATH,
- method: 'GET',
- timeout: this.MILLISECOND_TIME_OUT,
- headers: {
- [this.AWS_METADATA_TOKEN_HEADER]: token,
- },
- };
- return await this._fetchString(options);
- }
-
- /**
- * Establishes an HTTP connection to AWS instance document url.
- * If the application is running on an EC2 instance, we should be able
- * to get back a valid JSON document. Parses that document and stores
- * the identity properties in a local map.
- */
- private async _fetchString(options: http.RequestOptions): Promise {
- return new Promise((resolve, reject) => {
- const timeoutId = setTimeout(() => {
- req.abort();
- reject(new Error('EC2 metadata api request timed out.'));
- }, 1000);
-
- const req = http.request(options, res => {
- clearTimeout(timeoutId);
- const { statusCode } = res;
- res.setEncoding('utf8');
- let rawData = '';
- res.on('data', chunk => (rawData += chunk));
- res.on('end', () => {
- if (statusCode && statusCode >= 200 && statusCode < 300) {
- try {
- resolve(rawData);
- } catch (e) {
- reject(e);
- }
- } else {
- reject(
- new Error('Failed to load page, status code: ' + statusCode)
- );
- }
- });
- });
- req.on('error', err => {
- clearTimeout(timeoutId);
- reject(err);
- });
- req.end();
- });
- }
-}
-
-export const awsEc2Detector = new AwsEc2Detector();
diff --git a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetector.ts b/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetector.ts
deleted file mode 100644
index 02d0c598bc..0000000000
--- a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetector.ts
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import { diag } from '@opentelemetry/api';
-import {
- Detector,
- Resource,
- ResourceDetectionConfig,
-} from '@opentelemetry/resources';
-import {
- CloudProviderValues,
- CloudPlatformValues,
- SemanticResourceAttributes,
-} from '@opentelemetry/semantic-conventions';
-import * as util from 'util';
-import * as fs from 'fs';
-import * as os from 'os';
-import { getEnv } from '@opentelemetry/core';
-
-/**
- * The AwsEcsDetector can be used to detect if a process is running in AWS
- * ECS and return a {@link Resource} populated with data about the ECS
- * plugins of AWS X-Ray. Returns an empty Resource if detection fails.
- */
-export class AwsEcsDetector implements Detector {
- readonly CONTAINER_ID_LENGTH = 64;
- readonly DEFAULT_CGROUP_PATH = '/proc/self/cgroup';
- private static readFileAsync = util.promisify(fs.readFile);
-
- async detect(_config?: ResourceDetectionConfig): Promise {
- const env = getEnv();
- if (!env.ECS_CONTAINER_METADATA_URI_V4 && !env.ECS_CONTAINER_METADATA_URI) {
- diag.debug('AwsEcsDetector failed: Process is not on ECS');
- return Resource.empty();
- }
-
- const hostName = os.hostname();
- const containerId = await this._getContainerId();
-
- return !hostName && !containerId
- ? Resource.empty()
- : new Resource({
- [SemanticResourceAttributes.CLOUD_PROVIDER]: CloudProviderValues.AWS,
- [SemanticResourceAttributes.CLOUD_PLATFORM]: CloudPlatformValues.AWS_ECS,
- [SemanticResourceAttributes.CONTAINER_NAME]: hostName || '',
- [SemanticResourceAttributes.CONTAINER_ID]: containerId || '',
- });
- }
-
- /**
- * Read container ID from cgroup file
- * In ECS, even if we fail to find target file
- * or target file does not contain container ID
- * we do not throw an error but throw warning message
- * and then return null string
- */
- private async _getContainerId(): Promise {
- try {
- const rawData = await AwsEcsDetector.readFileAsync(
- this.DEFAULT_CGROUP_PATH,
- 'utf8'
- );
- const splitData = rawData.trim().split('\n');
- for (const str of splitData) {
- if (str.length > this.CONTAINER_ID_LENGTH) {
- return str.substring(str.length - this.CONTAINER_ID_LENGTH);
- }
- }
- } catch (e) {
- diag.warn(`AwsEcsDetector failed to read container ID: ${e.message}`);
- }
- return undefined;
- }
-}
-
-export const awsEcsDetector = new AwsEcsDetector();
diff --git a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEksDetector.ts b/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEksDetector.ts
deleted file mode 100644
index 39c041427a..0000000000
--- a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEksDetector.ts
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import {
- Detector,
- Resource,
- ResourceDetectionConfig,
-} from '@opentelemetry/resources';
-import {
- CloudProviderValues,
- CloudPlatformValues,
- SemanticResourceAttributes,
-} from '@opentelemetry/semantic-conventions';
-import * as https from 'https';
-import * as fs from 'fs';
-import * as util from 'util';
-import { diag } from '@opentelemetry/api';
-
-/**
- * The AwsEksDetector can be used to detect if a process is running in AWS Elastic
- * Kubernetes and return a {@link Resource} populated with data about the Kubernetes
- * plugins of AWS X-Ray. Returns an empty Resource if detection fails.
- *
- * See https://docs.amazonaws.cn/en_us/xray/latest/devguide/xray-guide.pdf
- * for more details about detecting information for Elastic Kubernetes plugins
- */
-
-export class AwsEksDetector implements Detector {
- readonly K8S_SVC_URL = 'kubernetes.default.svc';
- readonly K8S_TOKEN_PATH =
- '/var/run/secrets/kubernetes.io/serviceaccount/token';
- readonly K8S_CERT_PATH =
- '/var/run/secrets/kubernetes.io/serviceaccount/ca.crt';
- readonly AUTH_CONFIGMAP_PATH =
- '/api/v1/namespaces/kube-system/configmaps/aws-auth';
- readonly CW_CONFIGMAP_PATH =
- '/api/v1/namespaces/amazon-cloudwatch/configmaps/cluster-info';
- readonly CONTAINER_ID_LENGTH = 64;
- readonly DEFAULT_CGROUP_PATH = '/proc/self/cgroup';
- readonly TIMEOUT_MS = 2000;
- readonly UTF8_UNICODE = 'utf8';
-
- private static readFileAsync = util.promisify(fs.readFile);
- private static fileAccessAsync = util.promisify(fs.access);
-
- /**
- * The AwsEksDetector can be used to detect if a process is running on Amazon
- * Elastic Kubernetes and returns a promise containing a {@link Resource}
- * populated with instance metadata. Returns a promise containing an
- * empty {@link Resource} if the connection to kubernetes process
- * or aws config maps fails
- * @param config The resource detection config
- */
- async detect(_config?: ResourceDetectionConfig): Promise {
- try {
- await AwsEksDetector.fileAccessAsync(this.K8S_TOKEN_PATH);
- const k8scert = await AwsEksDetector.readFileAsync(this.K8S_CERT_PATH);
-
- if (!(await this._isEks(k8scert))) {
- return Resource.empty();
- }
-
- const containerId = await this._getContainerId();
- const clusterName = await this._getClusterName(k8scert);
-
- return !containerId && !clusterName
- ? Resource.empty()
- : new Resource({
- [SemanticResourceAttributes.CLOUD_PROVIDER]: CloudProviderValues.AWS,
- [SemanticResourceAttributes.CLOUD_PLATFORM]: CloudPlatformValues.AWS_EKS,
- [SemanticResourceAttributes.K8S_CLUSTER_NAME]: clusterName || '',
- [SemanticResourceAttributes.CONTAINER_ID]: containerId || '',
- });
- } catch (e) {
- diag.warn('Process is not running on K8S', e);
- return Resource.empty();
- }
- }
-
- /**
- * Attempts to make a connection to AWS Config map which will
- * determine whether the process is running on an EKS
- * process if the config map is empty or not
- */
- private async _isEks(cert: Buffer): Promise {
- const options = {
- ca: cert,
- headers: {
- Authorization: await this._getK8sCredHeader(),
- },
- hostname: this.K8S_SVC_URL,
- method: 'GET',
- path: this.AUTH_CONFIGMAP_PATH,
- timeout: this.TIMEOUT_MS,
- };
- return !!(await this._fetchString(options));
- }
-
- /**
- * Attempts to make a connection to Amazon Cloudwatch
- * Config Maps to grab cluster name
- */
- private async _getClusterName(cert: Buffer): Promise {
- const options = {
- ca: cert,
- headers: {
- Authorization: await this._getK8sCredHeader(),
- },
- host: this.K8S_SVC_URL,
- method: 'GET',
- path: this.CW_CONFIGMAP_PATH,
- timeout: this.TIMEOUT_MS,
- };
- const response = await this._fetchString(options);
- try {
- return JSON.parse(response).data['cluster.name'];
- } catch (e) {
- diag.warn('Cannot get cluster name on EKS', e);
- }
- return '';
- }
- /**
- * Reads the Kubernetes token path and returns kubernetes
- * credential header
- */
- private async _getK8sCredHeader(): Promise {
- try {
- const content = await AwsEksDetector.readFileAsync(
- this.K8S_TOKEN_PATH,
- this.UTF8_UNICODE
- );
- return 'Bearer ' + content;
- } catch (e) {
- diag.warn('Unable to read Kubernetes client token.', e);
- }
- return '';
- }
-
- /**
- * Read container ID from cgroup file generated from docker which lists the full
- * untruncated docker container ID at the end of each line.
- *
- * The predefined structure of calling /proc/self/cgroup when in a docker container has the structure:
- *
- * #:xxxxxx:/
- *
- * or
- *
- * #:xxxxxx:/docker/64characterID
- *
- * This function takes advantage of that fact by just reading the 64-character ID from the end of the
- * first line. In EKS, even if we fail to find target file or target file does
- * not contain container ID we do not throw an error but throw warning message
- * and then return null string
- */
- private async _getContainerId(): Promise {
- try {
- const rawData = await AwsEksDetector.readFileAsync(
- this.DEFAULT_CGROUP_PATH,
- this.UTF8_UNICODE
- );
- const splitData = rawData.trim().split('\n');
- for (const str of splitData) {
- if (str.length > this.CONTAINER_ID_LENGTH) {
- return str.substring(str.length - this.CONTAINER_ID_LENGTH);
- }
- }
- } catch (e) {
- diag.warn(`AwsEksDetector failed to read container ID: ${e.message}`);
- }
- return undefined;
- }
-
- /**
- * Establishes an HTTP connection to AWS instance document url.
- * If the application is running on an EKS instance, we should be able
- * to get back a valid JSON document. Parses that document and stores
- * the identity properties in a local map.
- */
- private async _fetchString(options: https.RequestOptions): Promise {
- return await new Promise((resolve, reject) => {
- const timeoutId = setTimeout(() => {
- req.abort();
- reject(new Error('EKS metadata api request timed out.'));
- }, 2000);
-
- const req = https.request(options, res => {
- clearTimeout(timeoutId);
- const { statusCode } = res;
- res.setEncoding(this.UTF8_UNICODE);
- let rawData = '';
- res.on('data', chunk => (rawData += chunk));
- res.on('end', () => {
- if (statusCode && statusCode >= 200 && statusCode < 300) {
- try {
- resolve(rawData);
- } catch (e) {
- reject(e);
- }
- } else {
- reject(
- new Error('Failed to load page, status code: ' + statusCode)
- );
- }
- });
- });
- req.on('error', err => {
- clearTimeout(timeoutId);
- reject(err);
- });
- req.end();
- });
- }
-}
-
-export const awsEksDetector = new AwsEksDetector();
diff --git a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsLambdaDetector.ts b/packages/opentelemetry-resource-detector-aws/src/detectors/AwsLambdaDetector.ts
deleted file mode 100644
index 5c8156d260..0000000000
--- a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsLambdaDetector.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import {
- Detector,
- Resource,
- ResourceDetectionConfig,
-} from '@opentelemetry/resources';
-import {
- CloudProviderValues,
- SemanticResourceAttributes,
-} from '@opentelemetry/semantic-conventions';
-
-/**
- * The AwsLambdaDetector can be used to detect if a process is running in AWS Lambda
- * and return a {@link Resource} populated with data about the environment.
- * Returns an empty Resource if detection fails.
- */
-export class AwsLambdaDetector implements Detector {
- async detect(_config?: ResourceDetectionConfig): Promise {
- const functionName = process.env.AWS_LAMBDA_FUNCTION_NAME;
- if (!functionName) {
- return Resource.empty();
- }
-
- const functionVersion = process.env.AWS_LAMBDA_FUNCTION_VERSION;
- const region = process.env.AWS_REGION;
-
- const attributes = {
- [SemanticResourceAttributes.CLOUD_PROVIDER]: String(CloudProviderValues.AWS),
- };
- if (region) {
- attributes[SemanticResourceAttributes.CLOUD_REGION] = region;
- }
-
- if (functionName) {
- attributes[SemanticResourceAttributes.FAAS_NAME] = functionName;
- }
- if (functionVersion) {
- attributes[SemanticResourceAttributes.FAAS_VERSION] = functionVersion;
- }
-
- return new Resource(attributes);
- }
-}
-
-export const awsLambdaDetector = new AwsLambdaDetector();
diff --git a/packages/opentelemetry-resource-detector-aws/src/detectors/index.ts b/packages/opentelemetry-resource-detector-aws/src/detectors/index.ts
deleted file mode 100644
index b475e4a208..0000000000
--- a/packages/opentelemetry-resource-detector-aws/src/detectors/index.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export * from './AwsEc2Detector';
-export * from './AwsBeanstalkDetector';
-export * from './AwsEcsDetector';
-export * from './AwsEksDetector';
-export * from './AwsLambdaDetector';
diff --git a/packages/opentelemetry-resource-detector-aws/src/index.ts b/packages/opentelemetry-resource-detector-aws/src/index.ts
deleted file mode 100644
index 0acba8788c..0000000000
--- a/packages/opentelemetry-resource-detector-aws/src/index.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export * from './detectors';
diff --git a/packages/opentelemetry-resource-detector-aws/src/version.ts b/packages/opentelemetry-resource-detector-aws/src/version.ts
deleted file mode 100644
index 2902e7d262..0000000000
--- a/packages/opentelemetry-resource-detector-aws/src/version.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// this is autogenerated file, see scripts/version-update.js
-export const VERSION = '0.24.0';
diff --git a/packages/opentelemetry-resource-detector-aws/test/detectors/AwsBeanstalkDetector.test.ts b/packages/opentelemetry-resource-detector-aws/test/detectors/AwsBeanstalkDetector.test.ts
deleted file mode 100644
index 08ccc7269a..0000000000
--- a/packages/opentelemetry-resource-detector-aws/test/detectors/AwsBeanstalkDetector.test.ts
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import * as assert from 'assert';
-import * as sinon from 'sinon';
-import { awsBeanstalkDetector, AwsBeanstalkDetector } from '../../src';
-import {
- assertEmptyResource,
- assertServiceResource,
-} from '@opentelemetry/resources/test/util/resource-assertions';
-import { CloudPlatformValues } from '@opentelemetry/semantic-conventions';
-
-describe('BeanstalkResourceDetector', () => {
- const err = new Error('failed to read config file');
- const data = {
- version_label: 'app-5a56-170119_190650-stage-170119_190650',
- deployment_id: '32',
- environment_name: 'scorekeep',
- };
- const noisyData = {
- noise: 'noise',
- version_label: 'app-5a56-170119_190650-stage-170119_190650',
- deployment_id: '32',
- environment_name: 'scorekeep',
- };
-
- let readStub, fileStub;
-
- afterEach(() => {
- sinon.restore();
- });
-
- it('should successfully return resource data', async () => {
- fileStub = sinon
- .stub(AwsBeanstalkDetector, 'fileAccessAsync' as any)
- .resolves();
- readStub = sinon
- .stub(AwsBeanstalkDetector, 'readFileAsync' as any)
- .resolves(JSON.stringify(data));
- sinon.stub(JSON, 'parse').returns(data);
-
- const resource = await awsBeanstalkDetector.detect();
-
- sinon.assert.calledOnce(fileStub);
- sinon.assert.calledOnce(readStub);
- assert.ok(resource);
- assertServiceResource(resource, {
- name: CloudPlatformValues.AWS_ELASTIC_BEANSTALK,
- namespace: 'scorekeep',
- version: 'app-5a56-170119_190650-stage-170119_190650',
- instanceId: '32',
- });
- });
-
- it('should successfully return resource data with noise', async () => {
- fileStub = sinon
- .stub(AwsBeanstalkDetector, 'fileAccessAsync' as any)
- .resolves();
- readStub = sinon
- .stub(AwsBeanstalkDetector, 'readFileAsync' as any)
- .resolves(JSON.stringify(noisyData));
- sinon.stub(JSON, 'parse').returns(noisyData);
-
- const resource = await awsBeanstalkDetector.detect();
-
- sinon.assert.calledOnce(fileStub);
- sinon.assert.calledOnce(readStub);
- assert.ok(resource);
- assertServiceResource(resource, {
- name: CloudPlatformValues.AWS_ELASTIC_BEANSTALK,
- namespace: 'scorekeep',
- version: 'app-5a56-170119_190650-stage-170119_190650',
- instanceId: '32',
- });
- });
-
- it('should return empty resource when failing to read file', async () => {
- fileStub = sinon
- .stub(AwsBeanstalkDetector, 'fileAccessAsync' as any)
- .resolves();
- readStub = sinon
- .stub(AwsBeanstalkDetector, 'readFileAsync' as any)
- .rejects(err);
-
- const resource = await awsBeanstalkDetector.detect();
-
- sinon.assert.calledOnce(fileStub);
- sinon.assert.calledOnce(readStub);
- assert.ok(resource);
- assertEmptyResource(resource);
- });
-
- it('should return empty resource when config file does not exist', async () => {
- fileStub = sinon
- .stub(AwsBeanstalkDetector, 'fileAccessAsync' as any)
- .rejects(err);
- readStub = sinon
- .stub(AwsBeanstalkDetector, 'readFileAsync' as any)
- .resolves(JSON.stringify(data));
-
- const resource = await awsBeanstalkDetector.detect();
-
- sinon.assert.calledOnce(fileStub);
- sinon.assert.notCalled(readStub);
- assert.ok(resource);
- assertEmptyResource(resource);
- });
-});
diff --git a/packages/opentelemetry-resource-detector-aws/test/detectors/AwsEc2Detector.test.ts b/packages/opentelemetry-resource-detector-aws/test/detectors/AwsEc2Detector.test.ts
deleted file mode 100644
index 982228ed97..0000000000
--- a/packages/opentelemetry-resource-detector-aws/test/detectors/AwsEc2Detector.test.ts
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import * as nock from 'nock';
-import * as assert from 'assert';
-import { Resource } from '@opentelemetry/resources';
-import { awsEc2Detector } from '../../src';
-import {
- assertCloudResource,
- assertHostResource,
-} from '@opentelemetry/resources/test/util/resource-assertions';
-
-const AWS_HOST = 'http://' + awsEc2Detector.AWS_IDMS_ENDPOINT;
-const AWS_TOKEN_PATH = awsEc2Detector.AWS_INSTANCE_TOKEN_DOCUMENT_PATH;
-const AWS_IDENTITY_PATH = awsEc2Detector.AWS_INSTANCE_IDENTITY_DOCUMENT_PATH;
-const AWS_HOST_PATH = awsEc2Detector.AWS_INSTANCE_HOST_DOCUMENT_PATH;
-const AWS_METADATA_TTL_HEADER = awsEc2Detector.AWS_METADATA_TTL_HEADER;
-const AWS_METADATA_TOKEN_HEADER = awsEc2Detector.AWS_METADATA_TOKEN_HEADER;
-
-const mockedTokenResponse = 'my-token';
-const mockedIdentityResponse = {
- instanceId: 'my-instance-id',
- instanceType: 'my-instance-type',
- accountId: 'my-account-id',
- region: 'my-region',
- availabilityZone: 'my-zone',
-};
-const mockedHostResponse = 'my-hostname';
-
-describe('awsEc2Detector', () => {
- beforeEach(() => {
- nock.disableNetConnect();
- nock.cleanAll();
- });
-
- afterEach(() => {
- nock.enableNetConnect();
- });
-
- describe('with successful request', () => {
- it('should return aws_ec2_instance resource', async () => {
- const scope = nock(AWS_HOST)
- .persist()
- .put(AWS_TOKEN_PATH)
- .matchHeader(AWS_METADATA_TTL_HEADER, '60')
- .reply(200, () => mockedTokenResponse)
- .get(AWS_IDENTITY_PATH)
- .matchHeader(AWS_METADATA_TOKEN_HEADER, mockedTokenResponse)
- .reply(200, () => mockedIdentityResponse)
- .get(AWS_HOST_PATH)
- .matchHeader(AWS_METADATA_TOKEN_HEADER, mockedTokenResponse)
- .reply(200, () => mockedHostResponse);
-
- const resource: Resource = await awsEc2Detector.detect();
-
- scope.done();
-
- assert.ok(resource);
-
- assertCloudResource(resource, {
- provider: 'aws',
- accountId: 'my-account-id',
- region: 'my-region',
- zone: 'my-zone',
- });
- assertHostResource(resource, {
- id: 'my-instance-id',
- hostType: 'my-instance-type',
- name: 'my-hostname',
- hostName: 'my-hostname',
- });
- });
- });
-
- describe('with unsuccessful request', () => {
- it('should throw when receiving error response code', async () => {
- const expectedError = new Error('Failed to load page, status code: 404');
- const scope = nock(AWS_HOST)
- .persist()
- .put(AWS_TOKEN_PATH)
- .matchHeader(AWS_METADATA_TTL_HEADER, '60')
- .reply(200, () => mockedTokenResponse)
- .get(AWS_IDENTITY_PATH)
- .matchHeader(AWS_METADATA_TOKEN_HEADER, mockedTokenResponse)
- .reply(200, () => mockedIdentityResponse)
- .get(AWS_HOST_PATH)
- .matchHeader(AWS_METADATA_TOKEN_HEADER, mockedTokenResponse)
- .reply(404, () => new Error());
-
- try {
- await awsEc2Detector.detect();
- assert.ok(false, 'Expected to throw');
- } catch (err) {
- assert.deepStrictEqual(err, expectedError);
- }
-
- scope.done();
- });
-
- it('should throw when timed out', async () => {
- const expectedError = new Error('EC2 metadata api request timed out.');
- const scope = nock(AWS_HOST)
- .put(AWS_TOKEN_PATH)
- .matchHeader(AWS_METADATA_TTL_HEADER, '60')
- .reply(200, () => mockedTokenResponse)
- .get(AWS_IDENTITY_PATH)
- .matchHeader(AWS_METADATA_TOKEN_HEADER, mockedTokenResponse)
- .reply(200, () => mockedIdentityResponse)
- .get(AWS_HOST_PATH)
- .matchHeader(AWS_METADATA_TOKEN_HEADER, mockedTokenResponse)
- .delayConnection(2000)
- .reply(200, () => mockedHostResponse);
-
- try {
- await awsEc2Detector.detect();
- assert.ok(false, 'Expected to throw');
- } catch (err) {
- assert.deepStrictEqual(err, expectedError);
- }
-
- scope.done();
- });
-
- it('should throw when replied with an Error', async () => {
- const expectedError = new Error('NOT FOUND');
- const scope = nock(AWS_HOST)
- .put(AWS_TOKEN_PATH)
- .matchHeader(AWS_METADATA_TTL_HEADER, '60')
- .reply(200, () => mockedTokenResponse)
- .get(AWS_IDENTITY_PATH)
- .matchHeader(AWS_METADATA_TOKEN_HEADER, mockedTokenResponse)
- .replyWithError(expectedError.message);
-
- try {
- await awsEc2Detector.detect();
- assert.ok(false, 'Expected to throw');
- } catch (err) {
- assert.deepStrictEqual(err, expectedError);
- }
-
- scope.done();
- });
- });
-});
diff --git a/packages/opentelemetry-resource-detector-aws/test/detectors/AwsEcsDetector.test.ts b/packages/opentelemetry-resource-detector-aws/test/detectors/AwsEcsDetector.test.ts
deleted file mode 100644
index edfaebe4cd..0000000000
--- a/packages/opentelemetry-resource-detector-aws/test/detectors/AwsEcsDetector.test.ts
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import * as assert from 'assert';
-import * as sinon from 'sinon';
-import {
- awsEcsDetector,
- AwsEcsDetector,
-} from '../../src/detectors/AwsEcsDetector';
-import {
- assertEmptyResource,
- assertContainerResource,
-} from '@opentelemetry/resources/test/util/resource-assertions';
-import * as os from 'os';
-
-describe('BeanstalkResourceDetector', () => {
- const errorMsg = {
- fileNotFoundError: new Error('cannot find cgroup file'),
- };
-
- const correctCgroupData =
- 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm';
- const unexpectedCgroupdata =
- 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb';
- const noisyCgroupData = `\n\n\n abcdefghijklmnopqrstuvwxyz \n ${correctCgroupData}`;
- const multiValidCgroupData = `${unexpectedCgroupdata}\n${correctCgroupData}\nbcd${unexpectedCgroupdata}`;
- const hostNameData = 'abcd.test.testing.com';
-
- let readStub;
-
- beforeEach(() => {
- process.env.ECS_CONTAINER_METADATA_URI_V4 = '';
- process.env.ECS_CONTAINER_METADATA_URI = '';
- });
-
- afterEach(() => {
- sinon.restore();
- });
-
- it('should successfully return resource data', async () => {
- process.env.ECS_CONTAINER_METADATA_URI_V4 = 'ecs_metadata_v4_uri';
- sinon.stub(os, 'hostname').returns(hostNameData);
- readStub = sinon
- .stub(AwsEcsDetector, 'readFileAsync' as any)
- .resolves(correctCgroupData);
-
- const resource = await awsEcsDetector.detect();
-
- sinon.assert.calledOnce(readStub);
- assert.ok(resource);
- assertContainerResource(resource, {
- name: 'abcd.test.testing.com',
- id: 'bcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm',
- });
- });
-
- it('should successfully return resource data with noisy cgroup file', async () => {
- process.env.ECS_CONTAINER_METADATA_URI = 'ecs_metadata_v3_uri';
- sinon.stub(os, 'hostname').returns(hostNameData);
- readStub = sinon
- .stub(AwsEcsDetector, 'readFileAsync' as any)
- .resolves(noisyCgroupData);
-
- const resource = await awsEcsDetector.detect();
-
- sinon.assert.calledOnce(readStub);
- assert.ok(resource);
- assertContainerResource(resource, {
- name: 'abcd.test.testing.com',
- id: 'bcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm',
- });
- });
-
- it('should always return first valid line of data', async () => {
- process.env.ECS_CONTAINER_METADATA_URI = 'ecs_metadata_v3_uri';
- sinon.stub(os, 'hostname').returns(hostNameData);
- readStub = sinon
- .stub(AwsEcsDetector, 'readFileAsync' as any)
- .resolves(multiValidCgroupData);
-
- const resource = await awsEcsDetector.detect();
-
- sinon.assert.calledOnce(readStub);
- assert.ok(resource);
- assertContainerResource(resource, {
- name: 'abcd.test.testing.com',
- id: 'bcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm',
- });
- });
-
- it('should empty resource without accessing files', async () => {
- sinon.stub(os, 'hostname').returns(hostNameData);
- readStub = sinon
- .stub(AwsEcsDetector, 'readFileAsync' as any)
- .resolves(correctCgroupData);
-
- const resource = await awsEcsDetector.detect();
-
- sinon.assert.notCalled(readStub);
- assert.ok(resource);
- assertEmptyResource(resource);
- });
-
- it('should return resource only with hostname attribute without cgroup file', async () => {
- process.env.ECS_CONTAINER_METADATA_URI_V4 = 'ecs_metadata_v4_uri';
- sinon.stub(os, 'hostname').returns(hostNameData);
- readStub = sinon
- .stub(AwsEcsDetector, 'readFileAsync' as any)
- .rejects(errorMsg.fileNotFoundError);
-
- const resource = await awsEcsDetector.detect();
-
- sinon.assert.calledOnce(readStub);
- assert.ok(resource);
- assertContainerResource(resource, {
- name: 'abcd.test.testing.com',
- });
- });
-
- it('should return resource only with hostname attribute when cgroup file does not contain valid container ID', async () => {
- process.env.ECS_CONTAINER_METADATA_URI_V4 = 'ecs_metadata_v4_uri';
- sinon.stub(os, 'hostname').returns(hostNameData);
- readStub = sinon.stub(AwsEcsDetector, 'readFileAsync' as any).resolves('');
-
- const resource = await awsEcsDetector.detect();
-
- sinon.assert.calledOnce(readStub);
- assert.ok(resource);
- assertContainerResource(resource, {
- name: 'abcd.test.testing.com',
- });
- });
-
- it('should return resource only with container ID attribute without hostname', async () => {
- process.env.ECS_CONTAINER_METADATA_URI_V4 = 'ecs_metadata_v4_uri';
- sinon.stub(os, 'hostname').returns('');
- readStub = sinon
- .stub(AwsEcsDetector, 'readFileAsync' as any)
- .resolves(correctCgroupData);
-
- const resource = await awsEcsDetector.detect();
-
- sinon.assert.calledOnce(readStub);
- assert.ok(resource);
- assertContainerResource(resource, {
- id: 'bcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm',
- });
- });
-
- it('should return empty resource when both hostname and container ID are invalid', async () => {
- process.env.ECS_CONTAINER_METADATA_URI_V4 = 'ecs_metadata_v4_uri';
- sinon.stub(os, 'hostname').returns('');
- readStub = sinon
- .stub(AwsEcsDetector, 'readFileAsync' as any)
- .rejects(errorMsg.fileNotFoundError);
-
- const resource = await awsEcsDetector.detect();
-
- sinon.assert.calledOnce(readStub);
- assert.ok(resource);
- assertEmptyResource(resource);
- });
-});
diff --git a/packages/opentelemetry-resource-detector-aws/test/detectors/AwsEksDetector.test.ts b/packages/opentelemetry-resource-detector-aws/test/detectors/AwsEksDetector.test.ts
deleted file mode 100644
index 06dc603824..0000000000
--- a/packages/opentelemetry-resource-detector-aws/test/detectors/AwsEksDetector.test.ts
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import * as nock from 'nock';
-import * as sinon from 'sinon';
-import * as assert from 'assert';
-import { Resource } from '@opentelemetry/resources';
-import { awsEksDetector, AwsEksDetector } from '../../src';
-import {
- assertK8sResource,
- assertContainerResource,
- assertEmptyResource,
-} from '@opentelemetry/resources/test/util/resource-assertions';
-
-const K8S_SVC_URL = awsEksDetector.K8S_SVC_URL;
-const AUTH_CONFIGMAP_PATH = awsEksDetector.AUTH_CONFIGMAP_PATH;
-const CW_CONFIGMAP_PATH = awsEksDetector.CW_CONFIGMAP_PATH;
-
-describe('awsEksDetector', () => {
- const errorMsg = {
- fileNotFoundError: new Error('cannot find cgroup file'),
- };
-
- const correctCgroupData =
- 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm';
- const mockedClusterResponse = '{"data":{"cluster.name":"my-cluster"}}';
- const mockedAwsAuth = 'my-auth';
- const k8s_token = 'Bearer 31ada4fd-adec-460c-809a-9e56ceb75269';
- let readStub, fileStub, getCredStub;
-
- beforeEach(() => {
- nock.disableNetConnect();
- nock.cleanAll();
- });
-
- afterEach(() => {
- sinon.restore();
- nock.enableNetConnect();
- });
-
- describe('on successful request', () => {
- it('should return an aws_eks_instance_resource', async () => {
- fileStub = sinon
- .stub(AwsEksDetector, 'fileAccessAsync' as any)
- .resolves();
- readStub = sinon
- .stub(AwsEksDetector, 'readFileAsync' as any)
- .resolves(correctCgroupData);
- getCredStub = sinon
- .stub(awsEksDetector, '_getK8sCredHeader' as any)
- .resolves(k8s_token);
- const scope = nock('https://' + K8S_SVC_URL)
- .persist()
- .get(AUTH_CONFIGMAP_PATH)
- .matchHeader('Authorization', k8s_token)
- .reply(200, () => mockedAwsAuth)
- .get(CW_CONFIGMAP_PATH)
- .matchHeader('Authorization', k8s_token)
- .reply(200, () => mockedClusterResponse);
-
- const resource: Resource = await awsEksDetector.detect();
-
- scope.done();
-
- sinon.assert.calledOnce(fileStub);
- sinon.assert.calledTwice(readStub);
- sinon.assert.calledTwice(getCredStub);
-
- assert.ok(resource);
- assertK8sResource(resource, {
- clusterName: 'my-cluster',
- });
- assertContainerResource(resource, {
- id: 'bcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm',
- });
- });
-
- it('should return a resource with clusterName attribute without cgroup file', async () => {
- fileStub = sinon
- .stub(AwsEksDetector, 'fileAccessAsync' as any)
- .resolves();
- readStub = sinon
- .stub(AwsEksDetector, 'readFileAsync' as any)
- .onSecondCall()
- .rejects(errorMsg.fileNotFoundError);
- getCredStub = sinon
- .stub(awsEksDetector, '_getK8sCredHeader' as any)
- .resolves(k8s_token);
- const scope = nock('https://' + K8S_SVC_URL)
- .persist()
- .get(AUTH_CONFIGMAP_PATH)
- .matchHeader('Authorization', k8s_token)
- .reply(200, () => mockedAwsAuth)
- .get(CW_CONFIGMAP_PATH)
- .matchHeader('Authorization', k8s_token)
- .reply(200, () => mockedClusterResponse);
-
- const resource: Resource = await awsEksDetector.detect();
-
- scope.done();
-
- assert.ok(resource);
- assertK8sResource(resource, {
- clusterName: 'my-cluster',
- });
- });
-
- it('should return a resource with container ID attribute without a clusterName', async () => {
- fileStub = sinon
- .stub(AwsEksDetector, 'fileAccessAsync' as any)
- .resolves();
- readStub = sinon
- .stub(AwsEksDetector, 'readFileAsync' as any)
- .resolves(correctCgroupData);
- getCredStub = sinon
- .stub(awsEksDetector, '_getK8sCredHeader' as any)
- .resolves(k8s_token);
- const scope = nock('https://' + K8S_SVC_URL)
- .persist()
- .get(AUTH_CONFIGMAP_PATH)
- .matchHeader('Authorization', k8s_token)
- .reply(200, () => mockedAwsAuth)
- .get(CW_CONFIGMAP_PATH)
- .matchHeader('Authorization', k8s_token)
- .reply(200, () => '');
-
- const resource: Resource = await awsEksDetector.detect();
-
- scope.done();
-
- assert.ok(resource);
- assertContainerResource(resource, {
- id: 'bcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm',
- });
- });
-
- it('should return a resource with clusterName attribute when cgroup file does not contain valid Container ID', async () => {
- fileStub = sinon
- .stub(AwsEksDetector, 'fileAccessAsync' as any)
- .resolves();
- readStub = sinon
- .stub(AwsEksDetector, 'readFileAsync' as any)
- .onSecondCall()
- .resolves('');
- getCredStub = sinon
- .stub(awsEksDetector, '_getK8sCredHeader' as any)
- .resolves(k8s_token);
- const scope = nock('https://' + K8S_SVC_URL)
- .persist()
- .get(AUTH_CONFIGMAP_PATH)
- .matchHeader('Authorization', k8s_token)
- .reply(200, () => mockedAwsAuth)
- .get(CW_CONFIGMAP_PATH)
- .matchHeader('Authorization', k8s_token)
- .reply(200, () => mockedClusterResponse);
-
- const resource: Resource = await awsEksDetector.detect();
-
- scope.done();
-
- assert.ok(resource);
- assert.ok(resource);
- assertK8sResource(resource, {
- clusterName: 'my-cluster',
- });
- });
-
- it('should return an empty resource when not running on Eks', async () => {
- fileStub = sinon
- .stub(AwsEksDetector, 'fileAccessAsync' as any)
- .resolves('');
- readStub = sinon
- .stub(AwsEksDetector, 'readFileAsync' as any)
- .resolves(correctCgroupData);
- getCredStub = sinon
- .stub(awsEksDetector, '_getK8sCredHeader' as any)
- .resolves(k8s_token);
- const scope = nock('https://' + K8S_SVC_URL)
- .persist()
- .get(AUTH_CONFIGMAP_PATH)
- .matchHeader('Authorization', k8s_token)
- .reply(200, () => '');
-
- const resource: Resource = await awsEksDetector.detect();
-
- scope.done();
-
- assert.ok(resource);
- assertEmptyResource(resource);
- });
-
- it('should return an empty resource when k8s token file does not exist', async () => {
- const errorMsg = {
- fileNotFoundError: new Error('cannot file k8s token file'),
- };
- fileStub = sinon
- .stub(AwsEksDetector, 'fileAccessAsync' as any)
- .rejects(errorMsg.fileNotFoundError);
-
- const resource: Resource = await awsEksDetector.detect();
-
- assert.ok(resource);
- assertEmptyResource(resource);
- });
-
- it('should return an empty resource when containerId and clusterName are invalid', async () => {
- fileStub = sinon
- .stub(AwsEksDetector, 'fileAccessAsync' as any)
- .resolves('');
- readStub = sinon
- .stub(AwsEksDetector, 'readFileAsync' as any)
- .onSecondCall()
- .rejects(errorMsg.fileNotFoundError);
-
- getCredStub = sinon
- .stub(awsEksDetector, '_getK8sCredHeader' as any)
- .resolves(k8s_token);
- const scope = nock('https://' + K8S_SVC_URL)
- .persist()
- .get(AUTH_CONFIGMAP_PATH)
- .matchHeader('Authorization', k8s_token)
- .reply(200, () => mockedAwsAuth)
- .get(CW_CONFIGMAP_PATH)
- .matchHeader('Authorization', k8s_token)
- .reply(200, () => '');
-
- const resource: Resource = await awsEksDetector.detect();
-
- scope.isDone();
-
- assert.ok(resource);
- assertEmptyResource(resource);
- });
- });
-
- describe('on unsuccesful request', () => {
- it('should return an empty resource when timed out', async () => {
- fileStub = sinon
- .stub(AwsEksDetector, 'fileAccessAsync' as any)
- .resolves();
- readStub = sinon
- .stub(AwsEksDetector, 'readFileAsync' as any)
- .resolves(correctCgroupData);
- getCredStub = sinon
- .stub(awsEksDetector, '_getK8sCredHeader' as any)
- .resolves(k8s_token);
- const scope = nock('https://' + K8S_SVC_URL)
- .persist()
- .get(AUTH_CONFIGMAP_PATH)
- .matchHeader('Authorization', k8s_token)
- .delayConnection(2500)
- .reply(200, () => mockedAwsAuth);
-
- const resource: Resource = await awsEksDetector.detect();
- scope.done();
-
- assert.ok(resource);
- assertEmptyResource(resource);
- }).timeout(awsEksDetector.TIMEOUT_MS + 100);
-
- it('should return an empty resource when receiving error response code', async () => {
- fileStub = sinon
- .stub(AwsEksDetector, 'fileAccessAsync' as any)
- .resolves();
- readStub = sinon
- .stub(AwsEksDetector, 'readFileAsync' as any)
- .resolves(correctCgroupData);
- getCredStub = sinon
- .stub(awsEksDetector, '_getK8sCredHeader' as any)
- .resolves(k8s_token);
- const scope = nock('https://' + K8S_SVC_URL)
- .persist()
- .get(AUTH_CONFIGMAP_PATH)
- .matchHeader('Authorization', k8s_token)
- .reply(404, () => new Error());
-
- const resource: Resource = await awsEksDetector.detect();
- scope.done();
-
- assert.ok(resource);
- assertEmptyResource(resource);
- });
- });
-});
diff --git a/packages/opentelemetry-resource-detector-aws/test/detectors/AwsLambdaDetector.test.ts b/packages/opentelemetry-resource-detector-aws/test/detectors/AwsLambdaDetector.test.ts
deleted file mode 100644
index 0487a0b708..0000000000
--- a/packages/opentelemetry-resource-detector-aws/test/detectors/AwsLambdaDetector.test.ts
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import * as assert from 'assert';
-import {
- assertCloudResource,
- assertEmptyResource,
-} from '@opentelemetry/resources/test/util/resource-assertions';
-
-import { awsLambdaDetector } from '../../src';
-
-describe('awsLambdaDetector', () => {
- let oldEnv: NodeJS.ProcessEnv;
-
- beforeEach(() => {
- oldEnv = { ...process.env };
- });
-
- afterEach(() => {
- process.env = oldEnv;
- });
-
- describe('on lambda', () => {
- it('fills resource', async () => {
- process.env.AWS_LAMBDA_FUNCTION_NAME = 'name';
- process.env.AWS_LAMBDA_FUNCTION_VERSION = 'v1';
- process.env.AWS_REGION = 'us-east-1';
-
- const resource = await awsLambdaDetector.detect();
-
- assertCloudResource(resource, {
- provider: 'aws',
- region: 'us-east-1',
- });
-
- assert.strictEqual(resource.attributes['faas.name'], 'name');
- assert.strictEqual(resource.attributes['faas.version'], 'v1');
- });
- });
-
- describe('not on lambda', () => {
- it('returns empty resource', async () => {
- process.env.AWS_LAMBDA_FUNCTION_VERSION = 'v1';
- process.env.AWS_REGION = 'us-east-1';
-
- const resource = await awsLambdaDetector.detect();
-
- assertEmptyResource(resource);
- });
- });
-});
diff --git a/packages/opentelemetry-resource-detector-aws/tsconfig.json b/packages/opentelemetry-resource-detector-aws/tsconfig.json
deleted file mode 100644
index b16c7037b4..0000000000
--- a/packages/opentelemetry-resource-detector-aws/tsconfig.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "extends": "../../tsconfig.base.json",
- "compilerOptions": {
- "rootDir": ".",
- "outDir": "build"
- },
- "include": [
- "src/**/*.ts",
- "test/**/*.ts"
- ],
- "references": [
- {
- "path": "../opentelemetry-core"
- },
- {
- "path": "../opentelemetry-resources"
- },
- {
- "path": "../opentelemetry-semantic-conventions"
- }
- ]
-}
diff --git a/packages/opentelemetry-resource-detector-gcp/.eslintignore b/packages/opentelemetry-resource-detector-gcp/.eslintignore
deleted file mode 100644
index 378eac25d3..0000000000
--- a/packages/opentelemetry-resource-detector-gcp/.eslintignore
+++ /dev/null
@@ -1 +0,0 @@
-build
diff --git a/packages/opentelemetry-resource-detector-gcp/.eslintrc.js b/packages/opentelemetry-resource-detector-gcp/.eslintrc.js
deleted file mode 100644
index 9dfe62f9b8..0000000000
--- a/packages/opentelemetry-resource-detector-gcp/.eslintrc.js
+++ /dev/null
@@ -1,9 +0,0 @@
-module.exports = {
- "env": {
- "mocha": true,
- "commonjs": true,
- "node": true,
- "browser": true
- },
- ...require('../../eslint.config.js')
-}
diff --git a/packages/opentelemetry-resource-detector-gcp/.npmignore b/packages/opentelemetry-resource-detector-gcp/.npmignore
deleted file mode 100644
index 9505ba9450..0000000000
--- a/packages/opentelemetry-resource-detector-gcp/.npmignore
+++ /dev/null
@@ -1,4 +0,0 @@
-/bin
-/coverage
-/doc
-/test
diff --git a/packages/opentelemetry-resource-detector-gcp/LICENSE b/packages/opentelemetry-resource-detector-gcp/LICENSE
deleted file mode 100644
index 6b91a297c8..0000000000
--- a/packages/opentelemetry-resource-detector-gcp/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [2020] OpenTelemetry Authors
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/packages/opentelemetry-resource-detector-gcp/README.md b/packages/opentelemetry-resource-detector-gcp/README.md
deleted file mode 100644
index 820991afd3..0000000000
--- a/packages/opentelemetry-resource-detector-gcp/README.md
+++ /dev/null
@@ -1,52 +0,0 @@
-# OpenTelemetry Resource Detector for GCP
-
-[![NPM Published Version][npm-img]][npm-url]
-[![dependencies][dependencies-image]][dependencies-url]
-[![devDependencies][devDependencies-image]][devDependencies-url]
-[![Apache License][license-image]][license-image]
-
-The OpenTelemetry Resource is an immutable representation of the entity producing telemetry. For example, a process producing telemetry that is running in a container on Kubernetes has a Pod name, it is in a namespace and possibly is part of a Deployment which also has a name. All three of these attributes can be included in the `Resource`.
-
-[This document][resource-semantic_conventions] defines standard attributes for resources.
-
-## Installation
-
-The GCP resource detector requires Node.JS 10+ due to a dependency on [`gcp-metadata`](https://www.npmjs.com/package/gcp-metadata) which uses features only available in Node.JS 10+.
-
-```bash
-npm install --save @opentelemetry/resource-detector-gcp
-```
-
-## Usage
-
-```typescript
-import { detectResources } from '@opentelemetry/resources';
-import { gcpDetector } from '@opentelemetry/resource-detector-gcp'
-const resource = await detectResources({
- detectors: [gcpDetector],
-})
-
-const tracerProvider = new NodeTracerProvider({ resource });
-```
-
-## Useful links
-
-- For more information on OpenTelemetry, visit:
-- For more about OpenTelemetry JavaScript:
-- For help or feedback on this project, join us in [GitHub Discussions][discussions-url]
-
-## License
-
-Apache 2.0 - See [LICENSE][license-url] for more information.
-
-[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions
-[license-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/LICENSE
-[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
-[dependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js.svg?path=packages%2Fopentelemetry-resources
-[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-resources
-[devDependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js.svg?path=packages%2Fopentelemetry-resources&type=dev
-[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-resources&type=dev
-[npm-url]: https://www.npmjs.com/package/@opentelemetry/resources
-[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fresources.svg
-
-[resource-semantic_conventions]: https://github.com/open-telemetry/opentelemetry-specification/tree/master/specification/resource/semantic_conventions
diff --git a/packages/opentelemetry-resource-detector-gcp/package.json b/packages/opentelemetry-resource-detector-gcp/package.json
deleted file mode 100644
index d105677006..0000000000
--- a/packages/opentelemetry-resource-detector-gcp/package.json
+++ /dev/null
@@ -1,64 +0,0 @@
-{
- "name": "@opentelemetry/resource-detector-gcp",
- "version": "0.24.0",
- "description": "OpenTelemetry SDK resource detector for GCP",
- "main": "build/src/index.js",
- "types": "build/src/index.d.ts",
- "repository": "open-telemetry/opentelemetry-js",
- "scripts": {
- "compile": "tsc --build",
- "clean": "tsc --build --clean",
- "lint": "eslint . --ext .ts",
- "lint:fix": "eslint . --ext .ts --fix",
- "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
- "tdd": "npm run test -- --watch-extensions ts --watch",
- "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../",
- "version": "node ../../scripts/version-update.js"
- },
- "keywords": [
- "opentelemetry",
- "nodejs",
- "resources",
- "stats",
- "profiling"
- ],
- "author": "OpenTelemetry Authors",
- "license": "Apache-2.0",
- "engines": {
- "node": ">=10.0.0"
- },
- "files": [
- "build/src/**/*.js",
- "build/src/**/*.js.map",
- "build/src/**/*.d.ts",
- "doc",
- "LICENSE",
- "README.md"
- ],
- "publishConfig": {
- "access": "public"
- },
- "devDependencies": {
- "@opentelemetry/api": "^1.0.2",
- "@opentelemetry/core": "0.24.0",
- "@types/mocha": "8.2.3",
- "@types/node": "14.17.9",
- "@types/semver": "7.3.8",
- "codecov": "3.8.3",
- "mocha": "7.2.0",
- "nock": "12.0.3",
- "nyc": "15.1.0",
- "rimraf": "3.0.2",
- "ts-mocha": "8.0.0",
- "typescript": "4.3.5"
- },
- "peerDependencies": {
- "@opentelemetry/api": "^1.0.2"
- },
- "dependencies": {
- "@opentelemetry/resources": "0.24.0",
- "@opentelemetry/semantic-conventions": "0.24.0",
- "gcp-metadata": "^4.1.4",
- "semver": "7.3.5"
- }
-}
diff --git a/packages/opentelemetry-resource-detector-gcp/src/detectors/GcpDetector.ts b/packages/opentelemetry-resource-detector-gcp/src/detectors/GcpDetector.ts
deleted file mode 100644
index e2b8c62e46..0000000000
--- a/packages/opentelemetry-resource-detector-gcp/src/detectors/GcpDetector.ts
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import * as semver from 'semver';
-import * as gcpMetadata from 'gcp-metadata';
-import { diag } from '@opentelemetry/api';
-import {
- Detector,
- ResourceDetectionConfig,
- Resource,
- ResourceAttributes,
-} from '@opentelemetry/resources';
-import { getEnv } from '@opentelemetry/core';
-import {
- CloudProviderValues,
- SemanticResourceAttributes,
-} from '@opentelemetry/semantic-conventions';
-
-/**
- * The GcpDetector can be used to detect if a process is running in the Google
- * Cloud Platofrm and return a {@link Resource} populated with metadata about
- * the instance. Returns an empty Resource if detection fails.
- */
-class GcpDetector implements Detector {
- /**
- * Attempts to connect and obtain instance configuration data from the GCP metadata service.
- * If the connection is succesful it returns a promise containing a {@link Resource}
- * populated with instance metadata. Returns a promise containing an
- * empty {@link Resource} if the connection or parsing of the metadata fails.
- *
- * @param config The resource detection config
- */
- async detect(_config?: ResourceDetectionConfig): Promise {
- if (
- !semver.satisfies(process.version, '>=10') ||
- !(await gcpMetadata.isAvailable())
- ) {
- diag.debug('GcpDetector failed: GCP Metadata unavailable.');
- return Resource.empty();
- }
-
- const [projectId, instanceId, zoneId, clusterName] = await Promise.all([
- this._getProjectId(),
- this._getInstanceId(),
- this._getZone(),
- this._getClusterName(),
- ]);
-
- const attributes: ResourceAttributes = {};
- attributes[SemanticResourceAttributes.CLOUD_ACCOUNT_ID] = projectId;
- attributes[SemanticResourceAttributes.HOST_ID] = instanceId;
- attributes[SemanticResourceAttributes.CLOUD_AVAILABILITY_ZONE] = zoneId;
- attributes[SemanticResourceAttributes.CLOUD_PROVIDER] =
- CloudProviderValues.GCP;
-
- if (getEnv().KUBERNETES_SERVICE_HOST)
- this._addK8sAttributes(attributes, clusterName);
-
- return new Resource(attributes);
- }
-
- /** Add resource attributes for K8s */
- private _addK8sAttributes(
- attributes: ResourceAttributes,
- clusterName: string
- ): void {
- const env = getEnv();
-
- attributes[SemanticResourceAttributes.K8S_CLUSTER_NAME] = clusterName;
- attributes[SemanticResourceAttributes.K8S_NAMESPACE_NAME] = env.NAMESPACE;
- attributes[SemanticResourceAttributes.K8S_POD_NAME] = env.HOSTNAME;
- attributes[SemanticResourceAttributes.CONTAINER_NAME] = env.CONTAINER_NAME;
- }
-
- /** Gets project id from GCP project metadata. */
- private async _getProjectId(): Promise {
- try {
- return await gcpMetadata.project('project-id');
- } catch {
- return '';
- }
- }
-
- /** Gets instance id from GCP instance metadata. */
- private async _getInstanceId(): Promise {
- try {
- const id = await gcpMetadata.instance('id');
- return id.toString();
- } catch {
- return '';
- }
- }
-
- /** Gets zone from GCP instance metadata. */
- private async _getZone(): Promise {
- try {
- const zoneId = await gcpMetadata.instance('zone');
- if (zoneId) {
- return zoneId.split('/').pop();
- }
- return '';
- } catch {
- return '';
- }
- }
-
- /** Gets cluster name from GCP instance metadata. */
- private async _getClusterName(): Promise {
- try {
- return await gcpMetadata.instance('attributes/cluster-name');
- } catch {
- return '';
- }
- }
-}
-
-export const gcpDetector = new GcpDetector();
diff --git a/packages/opentelemetry-resource-detector-gcp/src/detectors/index.ts b/packages/opentelemetry-resource-detector-gcp/src/detectors/index.ts
deleted file mode 100644
index 9e856721bc..0000000000
--- a/packages/opentelemetry-resource-detector-gcp/src/detectors/index.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export * from './GcpDetector';
diff --git a/packages/opentelemetry-resource-detector-gcp/src/index.ts b/packages/opentelemetry-resource-detector-gcp/src/index.ts
deleted file mode 100644
index f281d4fdcd..0000000000
--- a/packages/opentelemetry-resource-detector-gcp/src/index.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export * from './detectors';
-
-// Internal - used for tests only
-export { resetIsAvailableCache } from 'gcp-metadata';
diff --git a/packages/opentelemetry-resource-detector-gcp/src/version.ts b/packages/opentelemetry-resource-detector-gcp/src/version.ts
deleted file mode 100644
index 2902e7d262..0000000000
--- a/packages/opentelemetry-resource-detector-gcp/src/version.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// this is autogenerated file, see scripts/version-update.js
-export const VERSION = '0.24.0';
diff --git a/packages/opentelemetry-resource-detector-gcp/test/detectors/GcpDetector.test.ts b/packages/opentelemetry-resource-detector-gcp/test/detectors/GcpDetector.test.ts
deleted file mode 100644
index 297e17692c..0000000000
--- a/packages/opentelemetry-resource-detector-gcp/test/detectors/GcpDetector.test.ts
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import {
- BASE_PATH,
- HEADER_NAME,
- HEADER_VALUE,
- HOST_ADDRESS,
- SECONDARY_HOST_ADDRESS,
- resetIsAvailableCache,
-} from 'gcp-metadata';
-import * as nock from 'nock';
-import * as semver from 'semver';
-import { gcpDetector } from '../../src';
-import {
- assertCloudResource,
- assertHostResource,
- assertK8sResource,
- assertContainerResource,
- assertEmptyResource,
-} from '@opentelemetry/resources/test/util/resource-assertions';
-import { Resource } from '@opentelemetry/resources';
-
-const HEADERS = {
- [HEADER_NAME.toLowerCase()]: HEADER_VALUE,
-};
-const INSTANCE_PATH = BASE_PATH + '/instance';
-const INSTANCE_ID_PATH = BASE_PATH + '/instance/id';
-const PROJECT_ID_PATH = BASE_PATH + '/project/project-id';
-const ZONE_PATH = BASE_PATH + '/instance/zone';
-const CLUSTER_NAME_PATH = BASE_PATH + '/instance/attributes/cluster-name';
-
-(semver.satisfies(process.version, '>=10') ? describe : describe.skip)(
- 'gcpDetector',
- () => {
- describe('.detect', () => {
- before(() => {
- nock.disableNetConnect();
- });
-
- after(() => {
- nock.enableNetConnect();
- delete process.env.KUBERNETES_SERVICE_HOST;
- delete process.env.NAMESPACE;
- delete process.env.CONTAINER_NAME;
- delete process.env.HOSTNAME;
- });
-
- beforeEach(() => {
- resetIsAvailableCache();
- nock.cleanAll();
- delete process.env.KUBERNETES_SERVICE_HOST;
- delete process.env.NAMESPACE;
- delete process.env.CONTAINER_NAME;
- delete process.env.HOSTNAME;
- });
-
- it('should return resource with GCP metadata', async () => {
- const scope = nock(HOST_ADDRESS)
- .get(INSTANCE_PATH)
- .reply(200, {}, HEADERS)
- .get(INSTANCE_ID_PATH)
- .reply(200, () => 4520031799277581759, HEADERS)
- .get(PROJECT_ID_PATH)
- .reply(200, () => 'my-project-id', HEADERS)
- .get(ZONE_PATH)
- .reply(200, () => 'project/zone/my-zone', HEADERS)
- .get(CLUSTER_NAME_PATH)
- .reply(404);
- const secondaryScope = nock(SECONDARY_HOST_ADDRESS)
- .get(INSTANCE_PATH)
- .reply(200, {}, HEADERS);
- const resource: Resource = await gcpDetector.detect();
- secondaryScope.done();
- scope.done();
-
- assertCloudResource(resource, {
- provider: 'gcp',
- accountId: 'my-project-id',
- zone: 'my-zone',
- });
- assertHostResource(resource, { id: '4520031799277582000' });
- });
-
- it('should populate K8s attributes when KUBERNETES_SERVICE_HOST is set', async () => {
- process.env.KUBERNETES_SERVICE_HOST = 'my-host';
- process.env.NAMESPACE = 'my-namespace';
- process.env.HOSTNAME = 'my-hostname';
- process.env.CONTAINER_NAME = 'my-container-name';
- const scope = nock(HOST_ADDRESS)
- .get(INSTANCE_PATH)
- .reply(200, {}, HEADERS)
- .get(INSTANCE_ID_PATH)
- .reply(200, () => 4520031799277581759, HEADERS)
- .get(CLUSTER_NAME_PATH)
- .reply(200, () => 'my-cluster', HEADERS)
- .get(PROJECT_ID_PATH)
- .reply(200, () => 'my-project-id', HEADERS)
- .get(ZONE_PATH)
- .reply(200, () => 'project/zone/my-zone', HEADERS);
- const secondaryScope = nock(SECONDARY_HOST_ADDRESS)
- .get(INSTANCE_PATH)
- .reply(200, {}, HEADERS);
- const resource = await gcpDetector.detect();
- secondaryScope.done();
- scope.done();
-
- assertCloudResource(resource, {
- provider: 'gcp',
- accountId: 'my-project-id',
- zone: 'my-zone',
- });
- assertK8sResource(resource, {
- clusterName: 'my-cluster',
- podName: 'my-hostname',
- namespaceName: 'my-namespace',
- });
- assertContainerResource(resource, { name: 'my-container-name' });
- });
-
- it('should return resource and empty data for non-available metadata attributes', async () => {
- const scope = nock(HOST_ADDRESS)
- .get(INSTANCE_PATH)
- .reply(200, {}, HEADERS)
- .get(PROJECT_ID_PATH)
- .reply(200, () => 'my-project-id', HEADERS)
- .get(ZONE_PATH)
- .reply(413)
- .get(INSTANCE_ID_PATH)
- .reply(400, undefined, HEADERS)
- .get(CLUSTER_NAME_PATH)
- .reply(413);
- const secondaryScope = nock(SECONDARY_HOST_ADDRESS)
- .get(INSTANCE_PATH)
- .reply(200, {}, HEADERS);
- const resource = await gcpDetector.detect();
- secondaryScope.done();
- scope.done();
-
- assertCloudResource(resource, {
- provider: 'gcp',
- accountId: 'my-project-id',
- zone: '',
- });
- });
-
- it('returns empty resource if not detected', async () => {
- const resource = await gcpDetector.detect();
- assertEmptyResource(resource);
- });
- });
- }
-);
diff --git a/packages/opentelemetry-resource-detector-gcp/tsconfig.json b/packages/opentelemetry-resource-detector-gcp/tsconfig.json
deleted file mode 100644
index b16c7037b4..0000000000
--- a/packages/opentelemetry-resource-detector-gcp/tsconfig.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "extends": "../../tsconfig.base.json",
- "compilerOptions": {
- "rootDir": ".",
- "outDir": "build"
- },
- "include": [
- "src/**/*.ts",
- "test/**/*.ts"
- ],
- "references": [
- {
- "path": "../opentelemetry-core"
- },
- {
- "path": "../opentelemetry-resources"
- },
- {
- "path": "../opentelemetry-semantic-conventions"
- }
- ]
-}
diff --git a/packages/opentelemetry-sdk-node/tsconfig.json b/packages/opentelemetry-sdk-node/tsconfig.json
index 61b56129ba..8fc62b28e2 100644
--- a/packages/opentelemetry-sdk-node/tsconfig.json
+++ b/packages/opentelemetry-sdk-node/tsconfig.json
@@ -21,12 +21,6 @@
{
"path": "../opentelemetry-instrumentation"
},
- {
- "path": "../opentelemetry-resource-detector-aws"
- },
- {
- "path": "../opentelemetry-resource-detector-gcp"
- },
{
"path": "../opentelemetry-resources"
},
diff --git a/tsconfig.json b/tsconfig.json
index 77def32559..5d981fde42 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -23,8 +23,6 @@
"packages/opentelemetry-node",
"packages/opentelemetry-propagator-b3",
"packages/opentelemetry-propagator-jaeger",
- "packages/opentelemetry-resource-detector-aws",
- "packages/opentelemetry-resource-detector-gcp",
"packages/opentelemetry-resources",
"packages/opentelemetry-sdk-node",
"packages/opentelemetry-semantic-conventions",
@@ -106,12 +104,6 @@
{
"path": "packages/opentelemetry-propagator-jaeger"
},
- {
- "path": "packages/opentelemetry-resource-detector-aws"
- },
- {
- "path": "packages/opentelemetry-resource-detector-gcp"
- },
{
"path": "packages/opentelemetry-resources"
},