Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(auto-instrumentation-node): add azure detector #2101

Merged
merged 3 commits into from Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions metapackages/auto-instrumentations-node/README.md
Expand Up @@ -65,6 +65,7 @@ By default, all SDK resource detectors are used, but you can use the environment
- `container`
- `alibaba`
- `aws`
- `azure`
- `gcp`
- `all` - enable all resource detectors
- `none` - disable resource detection
Expand Down
1 change: 1 addition & 0 deletions metapackages/auto-instrumentations-node/package.json
Expand Up @@ -89,6 +89,7 @@
"@opentelemetry/instrumentation-winston": "^0.37.0",
"@opentelemetry/resource-detector-alibaba-cloud": "^0.28.9",
"@opentelemetry/resource-detector-aws": "^1.4.2",
"@opentelemetry/resource-detector-azure": "^0.2.6",
"@opentelemetry/resource-detector-container": "^0.3.9",
"@opentelemetry/resource-detector-gcp": "^0.29.9",
"@opentelemetry/resources": "^1.12.0",
Expand Down
12 changes: 11 additions & 1 deletion metapackages/auto-instrumentations-node/src/utils.ts
Expand Up @@ -73,6 +73,11 @@ import {
osDetectorSync,
processDetectorSync,
} from '@opentelemetry/resources';
import {
azureAppServiceDetector,
azureFunctionsDetector,
azureVmDetector,
} from '@opentelemetry/resource-detector-azure';

const RESOURCE_DETECTOR_CONTAINER = 'container';
const RESOURCE_DETECTOR_ENVIRONMENT = 'env';
Expand All @@ -81,6 +86,7 @@ const RESOURCE_DETECTOR_OS = 'os';
const RESOURCE_DETECTOR_PROCESS = 'process';
const RESOURCE_DETECTOR_ALIBABA = 'alibaba';
const RESOURCE_DETECTOR_AWS = 'aws';
const RESOURCE_DETECTOR_AZURE = 'azure';
const RESOURCE_DETECTOR_GCP = 'gcp';

const InstrumentationMap = {
Expand Down Expand Up @@ -196,7 +202,7 @@ function getEnabledInstrumentationsFromEnv() {
export function getResourceDetectorsFromEnv(): Array<Detector | DetectorSync> {
const resourceDetectors = new Map<
string,
Detector | DetectorSync | Detector[]
Detector | DetectorSync | Detector[] | DetectorSync[]
>([
[RESOURCE_DETECTOR_CONTAINER, containerDetector],
[RESOURCE_DETECTOR_ENVIRONMENT, envDetectorSync],
Expand All @@ -215,6 +221,10 @@ export function getResourceDetectorsFromEnv(): Array<Detector | DetectorSync> {
awsLambdaDetector,
],
],
[
RESOURCE_DETECTOR_AZURE,
[azureAppServiceDetector, azureFunctionsDetector, azureVmDetector],
],
]);

const resourceDetectorsFromEnv =
Expand Down
4 changes: 2 additions & 2 deletions metapackages/auto-instrumentations-node/test/utils.test.ts
Expand Up @@ -114,13 +114,13 @@ describe('utils', () => {

describe('getResourceDetectorsFromEnv', () => {
it('should return all resource detectors by default', () => {
assert.equal(getResourceDetectorsFromEnv().length, 12);
assert.equal(getResourceDetectorsFromEnv().length, 15);
});

it('should return all resource detectors when OTEL_NODE_RESOURCE_DETECTORS contains "all"', () => {
process.env.OTEL_NODE_RESOURCE_DETECTORS = 'all';

assert.equal(getResourceDetectorsFromEnv().length, 12);
assert.equal(getResourceDetectorsFromEnv().length, 15);

delete process.env.OTEL_NODE_RESOURCE_DETECTORS;
});
Expand Down
2 changes: 2 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.