Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ For notes on migrating to 2.x / 0.200.x see [the upgrade guide](doc/upgrade-to-2
### :rocket: Features

* feat(instrumentation): allow error of safeExecuteInTheMiddleAsync to be async [#6032](https://github.com/open-telemetry/opentelemetry-js/pull/6032) @JPeer264
* feat(opentelemetry-config): add backups for compression, timeout, headers [#6058](https://github.com/open-telemetry/opentelemetry-js/pull/6058) @JamieDanielson

### :bug: Bug Fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,19 +240,23 @@ export function setTracerProvider(config: ConfigurationModel): void {
batch.exporter.otlp_http.client_certificate_file = clientCertificateFile;
}

const compression = getStringFromEnv(
'OTEL_EXPORTER_OTLP_TRACES_COMPRESSION'
);
const compression =
getStringFromEnv('OTEL_EXPORTER_OTLP_TRACES_COMPRESSION') ??
getStringFromEnv('OTEL_EXPORTER_OTLP_COMPRESSION');
if (compression && batch.exporter.otlp_http) {
batch.exporter.otlp_http.compression = compression;
}

const timeout = getNumberFromEnv('OTEL_EXPORTER_OTLP_TRACES_TIMEOUT');
const timeout =
getNumberFromEnv('OTEL_EXPORTER_OTLP_TRACES_TIMEOUT') ??
getNumberFromEnv('OTEL_EXPORTER_OTLP_TIMEOUT');
if (timeout && batch.exporter.otlp_http) {
batch.exporter.otlp_http.timeout = timeout;
}

const headersList = getStringFromEnv('OTEL_EXPORTER_OTLP_TRACES_HEADERS');
const headersList =
getStringFromEnv('OTEL_EXPORTER_OTLP_TRACES_HEADERS') ??
getStringFromEnv('OTEL_EXPORTER_OTLP_HEADERS');
if (headersList && batch.exporter.otlp_http) {
batch.exporter.otlp_http.headers_list = headersList;
}
Expand Down Expand Up @@ -314,19 +318,23 @@ export function setMeterProvider(config: ConfigurationModel): void {
clientCertificateFile;
}

const compression = getStringFromEnv(
'OTEL_EXPORTER_OTLP_METRICS_COMPRESSION'
);
const compression =
getStringFromEnv('OTEL_EXPORTER_OTLP_METRICS_COMPRESSION') ??
getStringFromEnv('OTEL_EXPORTER_OTLP_COMPRESSION');
if (compression) {
readerPeriodic.exporter.otlp_http.compression = compression;
}

const timeoutEx = getNumberFromEnv('OTEL_EXPORTER_OTLP_METRICS_TIMEOUT');
const timeoutEx =
getNumberFromEnv('OTEL_EXPORTER_OTLP_METRICS_TIMEOUT') ??
getNumberFromEnv('OTEL_EXPORTER_OTLP_TIMEOUT');
if (timeoutEx) {
readerPeriodic.exporter.otlp_http.timeout = timeoutEx;
}

const headersList = getStringFromEnv('OTEL_EXPORTER_OTLP_METRICS_HEADERS');
const headersList =
getStringFromEnv('OTEL_EXPORTER_OTLP_METRICS_HEADERS') ??
getStringFromEnv('OTEL_EXPORTER_OTLP_HEADERS');
if (headersList) {
readerPeriodic.exporter.otlp_http.headers_list = headersList;
}
Expand Down Expand Up @@ -478,17 +486,23 @@ export function setLoggerProvider(config: ConfigurationModel): void {
batch.exporter.otlp_http.client_certificate_file = clientCertificateFile;
}

const compression = getStringFromEnv('OTEL_EXPORTER_OTLP_LOGS_COMPRESSION');
const compression =
getStringFromEnv('OTEL_EXPORTER_OTLP_LOGS_COMPRESSION') ??
getStringFromEnv('OTEL_EXPORTER_OTLP_COMPRESSION');
if (compression && batch.exporter.otlp_http) {
batch.exporter.otlp_http.compression = compression;
}

const timeout = getNumberFromEnv('OTEL_EXPORTER_OTLP_LOGS_TIMEOUT');
const timeout =
getNumberFromEnv('OTEL_EXPORTER_OTLP_LOGS_TIMEOUT') ??
getNumberFromEnv('OTEL_EXPORTER_OTLP_TIMEOUT');
if (timeout && batch.exporter.otlp_http) {
batch.exporter.otlp_http.timeout = timeout;
}

const headersList = getStringFromEnv('OTEL_EXPORTER_OTLP_LOGS_HEADERS');
const headersList =
getStringFromEnv('OTEL_EXPORTER_OTLP_LOGS_HEADERS') ??
getStringFromEnv('OTEL_EXPORTER_OTLP_HEADERS');
if (headersList && batch.exporter.otlp_http) {
batch.exporter.otlp_http.headers_list = headersList;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1064,14 +1064,16 @@ describe('ConfigProvider', function () {
);
});

it('should use backup option for certificates', function () {
it('should use backup options for exporters', function () {
process.env.OTEL_EXPORTER_OTLP_CERTIFICATE =
'backup_certificate_file.pem';
process.env.OTEL_EXPORTER_OTLP_CLIENT_KEY = 'backup_client_key.pem';
process.env.OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE =
'backup_client_certificate.pem';
process.env.OTEL_EXPORTER_OTLP_ENDPOINT = 'http://backup.com:4318';

process.env.OTEL_EXPORTER_OTLP_COMPRESSION = 'backup_compression';
process.env.OTEL_EXPORTER_OTLP_TIMEOUT = '12000';
process.env.OTEL_EXPORTER_OTLP_HEADERS = 'backup_headers=123';
const expectedConfig: Configuration = {
...defaultConfig,
tracer_provider: {
Expand All @@ -1082,11 +1084,13 @@ describe('ConfigProvider', function () {
exporter: {
otlp_http: {
endpoint: 'http://backup.com:4318/v1/traces',
timeout: 10000,
timeout: 12000,
compression: 'backup_compression',
encoding: OtlpHttpEncoding.Protobuf,
certificate_file: 'backup_certificate_file.pem',
client_certificate_file: 'backup_client_certificate.pem',
client_key_file: 'backup_client_key.pem',
headers_list: 'backup_headers=123',
},
},
},
Expand All @@ -1105,14 +1109,16 @@ describe('ConfigProvider', function () {
exporter: {
otlp_http: {
endpoint: 'http://backup.com:4318/v1/metrics',
timeout: 10000,
timeout: 12000,
compression: 'backup_compression',
temporality_preference:
ExporterTemporalityPreference.Cumulative,
default_histogram_aggregation:
ExporterDefaultHistogramAggregation.ExplicitBucketHistogram,
certificate_file: 'backup_certificate_file.pem',
client_certificate_file: 'backup_client_certificate.pem',
client_key_file: 'backup_client_key.pem',
headers_list: 'backup_headers=123',
},
},
},
Expand All @@ -1131,11 +1137,13 @@ describe('ConfigProvider', function () {
exporter: {
otlp_http: {
endpoint: 'http://backup.com:4318/v1/logs',
timeout: 10000,
timeout: 12000,
compression: 'backup_compression',
encoding: OtlpHttpEncoding.Protobuf,
certificate_file: 'backup_certificate_file.pem',
client_certificate_file: 'backup_client_certificate.pem',
client_key_file: 'backup_client_key.pem',
headers_list: 'backup_headers=123',
},
},
},
Expand Down