diff --git a/experimental/CHANGELOG.md b/experimental/CHANGELOG.md index 4d036146cfa..ba60ca127ac 100644 --- a/experimental/CHANGELOG.md +++ b/experimental/CHANGELOG.md @@ -12,6 +12,7 @@ For notes on migrating to 2.x / 0.200.x see [the upgrade guide](doc/upgrade-to-2 ### :bug: Bug Fixes +* fix(configuration): add missing config fallback defaults for consistency between file and env config [#6717](https://github.com/open-telemetry/opentelemetry-js/pull/6717) @MikeGoldsmith * fix(sdk-node): pass gRPC credentials and headers to span exporter in declarative config [#6705](https://github.com/open-telemetry/opentelemetry-js/pull/6705) @MikeGoldsmith * fix(otlp-transformer): do not attempt to skip groups [#6704](https://github.com/open-telemetry/opentelemetry-js/pull/6704) @pichlermarc diff --git a/experimental/packages/configuration/src/FileConfigFactory.ts b/experimental/packages/configuration/src/FileConfigFactory.ts index 57847148619..134b4529d19 100644 --- a/experimental/packages/configuration/src/FileConfigFactory.ts +++ b/experimental/packages/configuration/src/FileConfigFactory.ts @@ -186,20 +186,26 @@ function mergeCompositeList(data: ConfigurationModel): void { * are not encoded in the JSON schema. */ function applyBatchProcessorDefaults(data: ConfigurationModel): void { - const applyDefaults = ( - batch: BatchSpanProcessor | BatchLogRecordProcessor - ) => { + const applySpanDefaults = (batch: BatchSpanProcessor) => { if (batch.schedule_delay == null) batch.schedule_delay = 5000; if (batch.export_timeout == null) batch.export_timeout = 30000; if (batch.max_queue_size == null) batch.max_queue_size = 2048; if (batch.max_export_batch_size == null) batch.max_export_batch_size = 512; }; + // BLRP has a different schedule_delay default (1000) than BSP (5000) + const applyLogDefaults = (batch: BatchLogRecordProcessor) => { + if (batch.schedule_delay == null) batch.schedule_delay = 1000; + if (batch.export_timeout == null) batch.export_timeout = 30000; + if (batch.max_queue_size == null) batch.max_queue_size = 2048; + if (batch.max_export_batch_size == null) batch.max_export_batch_size = 512; + }; + for (const processor of data.tracer_provider?.processors ?? []) { - if (processor.batch) applyDefaults(processor.batch); + if (processor.batch) applySpanDefaults(processor.batch); } for (const processor of data.logger_provider?.processors ?? []) { - if (processor.batch) applyDefaults(processor.batch); + if (processor.batch) applyLogDefaults(processor.batch); } } @@ -235,6 +241,31 @@ function applyConfigDefaults(data: ConfigurationModel): void { } else if (data.attribute_limits.attribute_count_limit == null) { data.attribute_limits.attribute_count_limit = 128; } + + // Tracer provider limits + const tpLimits = data.tracer_provider?.limits; + if (tpLimits) { + if (tpLimits.attribute_count_limit == null) + tpLimits.attribute_count_limit = 128; + if (tpLimits.event_count_limit == null) tpLimits.event_count_limit = 128; + if (tpLimits.link_count_limit == null) tpLimits.link_count_limit = 128; + if (tpLimits.event_attribute_count_limit == null) + tpLimits.event_attribute_count_limit = 128; + if (tpLimits.link_attribute_count_limit == null) + tpLimits.link_attribute_count_limit = 128; + } + + // Logger provider limits + const lpLimits = data.logger_provider?.limits; + if (lpLimits) { + if (lpLimits.attribute_count_limit == null) + lpLimits.attribute_count_limit = 128; + } + + // Meter provider exemplar filter + if (data.meter_provider && data.meter_provider.exemplar_filter == null) { + data.meter_provider.exemplar_filter = 'trace_based'; + } } /** diff --git a/experimental/packages/configuration/src/utils.ts b/experimental/packages/configuration/src/utils.ts index 6d3adeb3426..324fe0d986c 100644 --- a/experimental/packages/configuration/src/utils.ts +++ b/experimental/packages/configuration/src/utils.ts @@ -58,6 +58,7 @@ export function getGrpcTlsConfig( export function initializeDefaultConfiguration(): ConfigurationModel { return { disabled: false, + log_level: 'info', resource: {}, attribute_limits: { attribute_count_limit: 128, diff --git a/experimental/packages/configuration/test/ConfigFactory.test.ts b/experimental/packages/configuration/test/ConfigFactory.test.ts index cbb0faa7f54..f33eadcbeb6 100644 --- a/experimental/packages/configuration/test/ConfigFactory.test.ts +++ b/experimental/packages/configuration/test/ConfigFactory.test.ts @@ -18,6 +18,7 @@ import { parseConfigFile } from '../src/FileConfigFactory'; const defaultConfig: ConfigurationModel = { disabled: false, + log_level: 'info', resource: {}, attribute_limits: { attribute_count_limit: 128, @@ -552,7 +553,7 @@ const configFromKitchenSinkFile = { }, { batch: { - schedule_delay: 5000, + schedule_delay: 1000, export_timeout: 30000, max_queue_size: 2048, max_export_batch_size: 512, @@ -575,7 +576,7 @@ const configFromKitchenSinkFile = { }, { batch: { - schedule_delay: 5000, + schedule_delay: 1000, export_timeout: 30000, max_queue_size: 2048, max_export_batch_size: 512, @@ -588,7 +589,7 @@ const configFromKitchenSinkFile = { }, { batch: { - schedule_delay: 5000, + schedule_delay: 1000, export_timeout: 30000, max_queue_size: 2048, max_export_batch_size: 512, @@ -2626,6 +2627,40 @@ describe('ConfigFactory', function () { composite: [{ tracecontext: {} }], composite_list: 'tracecontext', }, + tracer_provider: { + processors: [ + { + simple: { + exporter: { + console: {}, + }, + }, + }, + ], + limits: { + attribute_value_length_limit: 4096, + attribute_count_limit: 128, + event_count_limit: 128, + link_count_limit: 128, + event_attribute_count_limit: 128, + link_attribute_count_limit: 128, + }, + }, + meter_provider: { + readers: [ + { + periodic: { + interval: 60000, + timeout: 30000, + exporter: { + console: {}, + }, + cardinality_limits: { default: 2000 }, + }, + }, + ], + exemplar_filter: 'trace_based', + }, logger_provider: { processors: [ { @@ -2636,6 +2671,10 @@ describe('ConfigFactory', function () { }, }, ], + limits: { + attribute_value_length_limit: 4096, + attribute_count_limit: 128, + }, 'logger_configurator/development': { loggers: [ { diff --git a/experimental/packages/configuration/test/fixtures/test-for-coverage.yaml b/experimental/packages/configuration/test/fixtures/test-for-coverage.yaml index a3f8ea2a6b2..5736f06ff57 100644 --- a/experimental/packages/configuration/test/fixtures/test-for-coverage.yaml +++ b/experimental/packages/configuration/test/fixtures/test-for-coverage.yaml @@ -3,11 +3,25 @@ resource: attributes_list: propagator: composite_list: tracecontext +tracer_provider: + processors: + - simple: + exporter: + console: + limits: + attribute_value_length_limit: 4096 +meter_provider: + readers: + - periodic: + exporter: + console: logger_provider: processors: - simple: exporter: console: + limits: + attribute_value_length_limit: 4096 logger_configurator/development: loggers: - name: io.opentelemetry.contrib.*