From a01a5d8cb0746d016fe6e1d80a30f2a9e19a494f Mon Sep 17 00:00:00 2001 From: tamirdavid1 Date: Tue, 7 Jan 2025 15:56:45 +0200 Subject: [PATCH] fix: avoid errors in py app in case no destination configured --- initializer/components.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/initializer/components.py b/initializer/components.py index 3dda436..b63e94d 100644 --- a/initializer/components.py +++ b/initializer/components.py @@ -60,7 +60,9 @@ def initialize_components(trace_exporters = None, metric_exporters = None, log_e .merge(Resource.create(auto_resource)) odigos_sampler = initialize_traces_if_enabled(trace_exporters, resource, span_processor) - client.sampler = odigos_sampler + if odigos_sampler is not None : + client.sampler = odigos_sampler + initialize_metrics_if_enabled(metric_exporters, resource) initialize_logging_if_enabled(log_exporters, resource) @@ -105,7 +107,9 @@ def initialize_traces_if_enabled(trace_exporters, resource, span_processor = Non if span_processor is not None: provider.add_span_processor(span_processor) - return odigos_sampler + return odigos_sampler + + return None def initialize_metrics_if_enabled(metric_exporters, resource): metrics_enabled = os.getenv(sdk_config.OTEL_METRICS_EXPORTER, "none").strip().lower()