Skip to content

Commit 93fffad

Browse files
authored
Update README regarding Env Vars, Reorder Env Detector in Env Var logic (#69)
*Issue #, if available:* *Description of changes:* 1. Add `General Recommendations` table for ADOT JS Env Vars. 2. If user sets the `OTEL_NODE_RESOURCE_DETECTORS` Env Var, ensure that `env` is at the end of the list if not added by user. (see related [#53](#53)) *Testing:* - See [README in branch here](https://github.com/aws-observability/aws-otel-js-instrumentation/tree/readme-env-var-update/aws-distro-opentelemetry-node-autoinstrumentation). By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent 593f6d8 commit 93fffad

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

aws-distro-opentelemetry-node-autoinstrumentation/README.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,21 @@ node --require '@aws/aws-distro-opentelemetry-node-autoinstrumentation/register'
1515
## Sample Environment Variables for Application Signals
1616

1717
```shell
18-
export OTEL_AWS_APPLICATION_SIGNALS_ENABLED=true \
19-
export OTEL_AWS_APPLICATION_SIGNALS_EXPORTER_ENDPOINT=http://localhost:4316/v1/metrics \
20-
export OTEL_PROPAGATORS=xray,tracecontext,b3,b3multi \
21-
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf \
22-
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:4316/v1/traces \
23-
export OTEL_TRACES_EXPORTER=console,otlp \
24-
export OTEL_TRACES_SAMPLER=xray \
25-
export OTEL_TRACES_SAMPLER_ARG=endpoint=http://localhost:2000,polling_interval=300 \
26-
export OTEL_RESOURCE_ATTRIBUTES=service.name=test-adot-sdk-ec2-service-name \
27-
export OTEL_NODE_DISABLED_INSTRUMENTATIONS=fs
18+
export OTEL_RESOURCE_ATTRIBUTES=service.name=example-application-service-name
19+
export OTEL_AWS_APPLICATION_SIGNALS_ENABLED=true
20+
export OTEL_AWS_APPLICATION_SIGNALS_EXPORTER_ENDPOINT=http://localhost:4316/v1/metrics
21+
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
22+
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:4316/v1/traces
23+
export OTEL_TRACES_EXPORTER=console,otlp
24+
export OTEL_TRACES_SAMPLER=xray
25+
export OTEL_TRACES_SAMPLER_ARG=endpoint=http://localhost:2000,polling_interval=300
2826
```
27+
28+
### General Recommendations
29+
30+
| Environment Variable | Description | Example |
31+
| -------------------- | ----------- | ------- |
32+
| `OTEL_EXPORTER_OTLP_PROTOCOL` | Leave unset so that ADOT JS will use a recommended OTLP protocol | `http/protobuf` |
33+
| `OTEL_PROPAGATORS` | Leave unset so that ADOT JS will use a recommended list of propagators | `xray,tracecontext,b3,b3multi` |
34+
| `OTEL_NODE_DISABLED_INSTRUMENTATIONS` | Leave unset so that ADOT JS will disable a recommended list of instrumentations | `fs,dns` |
35+
| `OTEL_NODE_RESOURCE_DETECTORS` | Leave unset so that ADOT JS will use a recommended list of Resource Detectors. If set, `env` should be at the end of the list | `aws,env` |

aws-distro-opentelemetry-node-autoinstrumentation/src/aws-opentelemetry-configurator.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ export class AwsOpentelemetryConfigurator {
122122
defaultDetectors = getResourceDetectorsFromEnv();
123123
// Add Env/AWS Resource Detectors if not present
124124
const resourceDetectorsFromEnv: string[] = process.env.OTEL_NODE_RESOURCE_DETECTORS.split(',');
125-
if (!resourceDetectorsFromEnv.includes('env')) {
126-
defaultDetectors.push(envDetectorSync);
127-
}
128125
if (!resourceDetectorsFromEnv.includes('aws')) {
129126
defaultDetectors.push(awsEc2Detector, awsEcsDetector, awsEksDetector);
130127
}
128+
if (!resourceDetectorsFromEnv.includes('env')) {
129+
defaultDetectors.push(envDetectorSync);
130+
}
131131
} else {
132132
/*
133133
* envDetectorSync is used as opposed to envDetector (async), so it is guaranteed that the

0 commit comments

Comments
 (0)