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
2 changes: 2 additions & 0 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ For notes on migrating to 2.x / 0.200.x see [the upgrade guide](doc/upgrade-to-2

### :rocket: Features

feat(configuration): parse config for rc 3 [#6304](https://github.com/open-telemetry/opentelemetry-js/pull/6304) @maryliag

### :bug: Bug Fixes

### :books: Documentation
Expand Down
132 changes: 52 additions & 80 deletions experimental/packages/configuration/src/EnvironmentConfigFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
BatchLogRecordProcessor,
initializeDefaultLoggerProviderConfiguration,
} from './models/loggerProviderModel';
import { getGrpcTlsConfig, getHttpTlsConfig } from './utils';

/**
* EnvironmentConfigProvider provides a configuration based on environment variables.
Expand Down Expand Up @@ -173,47 +174,44 @@ export function setTracerProvider(config: ConfigurationModel): void {
}
config.tracer_provider = initializeDefaultTracerProviderConfiguration();

if (config.tracer_provider.limits == null) {
config.tracer_provider.limits = {};
}
const attributeValueLengthLimit = getNumberFromEnv(
'OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT'
);
if (attributeValueLengthLimit) {
config.tracer_provider.limits.attribute_value_length_limit =
config.tracer_provider.limits!.attribute_value_length_limit =
Comment thread
maryliag marked this conversation as resolved.
attributeValueLengthLimit;
}

const attributeCountLimit = getNumberFromEnv(
'OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT'
);
if (attributeCountLimit) {
config.tracer_provider.limits.attribute_count_limit = attributeCountLimit;
config.tracer_provider.limits!.attribute_count_limit = attributeCountLimit;
}

const eventCountLimit = getNumberFromEnv('OTEL_SPAN_EVENT_COUNT_LIMIT');
if (eventCountLimit) {
config.tracer_provider.limits.event_count_limit = eventCountLimit;
config.tracer_provider.limits!.event_count_limit = eventCountLimit;
}

const linkCountLimit = getNumberFromEnv('OTEL_SPAN_LINK_COUNT_LIMIT');
if (linkCountLimit) {
config.tracer_provider.limits.link_count_limit = linkCountLimit;
config.tracer_provider.limits!.link_count_limit = linkCountLimit;
}

const eventAttributeCountLimit = getNumberFromEnv(
'OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT'
);
if (eventAttributeCountLimit) {
config.tracer_provider.limits.event_attribute_count_limit =
config.tracer_provider.limits!.event_attribute_count_limit =
eventAttributeCountLimit;
}

const linkAttributeCountLimit = getNumberFromEnv(
'OTEL_LINK_ATTRIBUTE_COUNT_LIMIT'
);
if (linkAttributeCountLimit) {
config.tracer_provider.limits.link_attribute_count_limit =
config.tracer_provider.limits!.link_attribute_count_limit =
linkAttributeCountLimit;
}

Expand Down Expand Up @@ -246,16 +244,6 @@ export function setTracerProvider(config: ConfigurationModel): void {
config.tracer_provider.processors.push({
simple: { exporter: { console: {} } },
});
} else if (exporterType === 'zipkin') {
batchInfo.exporter = {
zipkin: {
endpoint:
getStringFromEnv('OTEL_EXPORTER_ZIPKIN_ENDPOINT') ??
'http://localhost:9411/api/v2/spans',
timeout: getNumberFromEnv('OTEL_EXPORTER_ZIPKIN_TIMEOUT') ?? 10000,
},
};
config.tracer_provider.processors.push({ batch: batchInfo });
} else {
// 'otlp' and default
const protocol =
Expand Down Expand Up @@ -292,15 +280,13 @@ export function setTracerProvider(config: ConfigurationModel): void {
if (endpoint) {
batchInfo.exporter.otlp_grpc.endpoint = endpoint;
}
if (certificateFile) {
batchInfo.exporter.otlp_grpc.certificate_file = certificateFile;
}
if (clientKeyFile) {
batchInfo.exporter.otlp_grpc.client_key_file = clientKeyFile;
}
if (clientCertificateFile) {
batchInfo.exporter.otlp_grpc.client_certificate_file =
clientCertificateFile;
const tls = getGrpcTlsConfig(
certificateFile,
clientKeyFile,
clientCertificateFile
);
if (tls) {
batchInfo.exporter.otlp_grpc.tls = tls;
}
Comment thread
maryliag marked this conversation as resolved.
if (compression) {
batchInfo.exporter.otlp_grpc.compression = compression;
Expand All @@ -323,15 +309,13 @@ export function setTracerProvider(config: ConfigurationModel): void {
if (endpoint) {
batchInfo.exporter.otlp_http.endpoint = endpoint;
}
if (certificateFile) {
batchInfo.exporter.otlp_http.certificate_file = certificateFile;
}
if (clientKeyFile) {
batchInfo.exporter.otlp_http.client_key_file = clientKeyFile;
}
if (clientCertificateFile) {
batchInfo.exporter.otlp_http.client_certificate_file =
clientCertificateFile;
const tls = getHttpTlsConfig(
certificateFile,
clientKeyFile,
clientCertificateFile
);
if (tls) {
batchInfo.exporter.otlp_http.tls = tls;
}
if (compression) {
batchInfo.exporter.otlp_http.compression = compression;
Expand Down Expand Up @@ -428,16 +412,13 @@ export function setMeterProvider(config: ConfigurationModel): void {
if (endpoint) {
readerPeriodicInfo.exporter.otlp_grpc.endpoint = endpoint;
}
if (certificateFile) {
readerPeriodicInfo.exporter.otlp_grpc.certificate_file =
certificateFile;
}
if (clientKeyFile) {
readerPeriodicInfo.exporter.otlp_grpc.client_key_file = clientKeyFile;
}
if (clientCertificateFile) {
readerPeriodicInfo.exporter.otlp_grpc.client_certificate_file =
clientCertificateFile;
const tls = getGrpcTlsConfig(
certificateFile,
clientKeyFile,
clientCertificateFile
);
if (tls) {
readerPeriodicInfo.exporter.otlp_grpc.tls = tls;
}
if (compression) {
readerPeriodicInfo.exporter.otlp_grpc.compression = compression;
Expand Down Expand Up @@ -496,16 +477,13 @@ export function setMeterProvider(config: ConfigurationModel): void {
if (endpoint) {
readerPeriodicInfo.exporter.otlp_http.endpoint = endpoint;
}
if (certificateFile) {
readerPeriodicInfo.exporter.otlp_http.certificate_file =
certificateFile;
}
if (clientKeyFile) {
readerPeriodicInfo.exporter.otlp_http.client_key_file = clientKeyFile;
}
if (clientCertificateFile) {
readerPeriodicInfo.exporter.otlp_http.client_certificate_file =
clientCertificateFile;
const tls = getHttpTlsConfig(
certificateFile,
clientKeyFile,
clientCertificateFile
);
if (tls) {
readerPeriodicInfo.exporter.otlp_http.tls = tls;
}
if (compression) {
readerPeriodicInfo.exporter.otlp_http.compression = compression;
Expand Down Expand Up @@ -606,16 +584,14 @@ export function setLoggerProvider(config: ConfigurationModel): void {
'OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT'
);
if (attributeValueLengthLimit || attributeCountLimit) {
if (config.logger_provider.limits == null) {
config.logger_provider.limits = { attribute_count_limit: 128 };
}
if (attributeValueLengthLimit) {
config.logger_provider.limits.attribute_value_length_limit =
config.logger_provider.limits!.attribute_value_length_limit =
attributeValueLengthLimit;
}

if (attributeCountLimit) {
config.logger_provider.limits.attribute_count_limit = attributeCountLimit;
config.logger_provider.limits!.attribute_count_limit =
attributeCountLimit;
}
}

Expand Down Expand Up @@ -684,15 +660,13 @@ export function setLoggerProvider(config: ConfigurationModel): void {
if (endpoint) {
batchInfo.exporter.otlp_grpc.endpoint = endpoint;
}
if (certificateFile) {
batchInfo.exporter.otlp_grpc.certificate_file = certificateFile;
}
if (clientKeyFile) {
batchInfo.exporter.otlp_grpc.client_key_file = clientKeyFile;
}
if (clientCertificateFile) {
batchInfo.exporter.otlp_grpc.client_certificate_file =
clientCertificateFile;
const tls = getGrpcTlsConfig(
certificateFile,
clientKeyFile,
clientCertificateFile
);
if (tls) {
batchInfo.exporter.otlp_grpc.tls = tls;
}
if (compression) {
batchInfo.exporter.otlp_grpc.compression = compression;
Expand All @@ -715,15 +689,13 @@ export function setLoggerProvider(config: ConfigurationModel): void {
if (endpoint) {
batchInfo.exporter.otlp_http.endpoint = endpoint;
}
if (certificateFile) {
batchInfo.exporter.otlp_http.certificate_file = certificateFile;
}
if (clientKeyFile) {
batchInfo.exporter.otlp_http.client_key_file = clientKeyFile;
}
if (clientCertificateFile) {
batchInfo.exporter.otlp_http.client_certificate_file =
clientCertificateFile;
const tls = getHttpTlsConfig(
certificateFile,
clientKeyFile,
clientCertificateFile
);
if (tls) {
batchInfo.exporter.otlp_http.tls = tls;
}
if (compression) {
batchInfo.exporter.otlp_http.compression = compression;
Expand Down
Loading