Skip to content

How can I configure OpenTelemetry to ​​disable Span creation​​ and ​​only collect Metrics​​ (without Traces or Logs)? #4757

@lfj

Description

@lfj

Describe your environment

OS: linux
Python version: Python 3.11

How can I configure OpenTelemetry to ​​disable Span creation​​ and ​​only collect Metrics​​ (without Traces or Logs)?

What happened?

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/tornado/web.py", line 1839, in _handle_request_exception
self.log_exception(*sys.exc_info())
File "/otel-auto-instrumentation/wrapt/wrappers.py", line 670, in call
return self._self_wrapper(self.wrapped, self._self_instance,
File "/otel-auto-instrumentation/opentelemetry/instrumentation/tornado/init.py", line 442, in _log_exception
_record_on_finish_metrics(server_histograms, handler, error)
File "/otel-auto-instrumentation/opentelemetry/instrumentation/tornado/init.py", line 635, in _record_on_finish_metrics
server_histograms[MetricInstruments.HTTP_SERVER_RESPONSE_SIZE].record(
File "/otel-auto-instrumentation/opentelemetry/sdk/metrics/_internal/instrument.py", line 264, in record
self._measurement_consumer.consume_measurement(
File "/otel-auto-instrumentation/opentelemetry/sdk/metrics/_internal/measurement_consumer.py", line 82, in consume_measurement
self._sdk_config.exemplar_filter.should_sample(
File "/otel-auto-instrumentation/opentelemetry/sdk/metrics/_internal/exemplar/exemplar_filter.py", line 131, in should_sample
span = trace.get_current_span(context)
File "/otel-auto-instrumentation/opentelemetry/trace/propagation/init.py", line 48, in get_current_span
span = get_value(_SPAN_KEY, context=context)
File "/otel-auto-instrumentation/opentelemetry/context/init.py", line 97, in get_value
return context.get(key) if context is not None else get_current().get(key)
AttributeError: 'NoneType' object has no attribute 'get'
500 GET /health (10.231.248.38) 1.15ms
Uncaught exception in write_error
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/tornado/web.py", line 1767, in _execute
result = self.prepare()
File "/otel-auto-instrumentation/wrapt/wrappers.py", line 670, in call
return self._self_wrapper(self.wrapped, self._self_instance,
File "/otel-auto-instrumentation/opentelemetry/instrumentation/tornado/init.py", line 413, in _prepare
ctx = _start_span(tracer, handler)
File "/otel-auto-instrumentation/opentelemetry/instrumentation/tornado/init.py", line 522, in _start_span
span, token = _start_internal_or_server_span(
File "/otel-auto-instrumentation/opentelemetry/instrumentation/utils.py", line 147, in _start_internal_or_server_span
span = tracer.start_span(
File "/otel-auto-instrumentation/opentelemetry/sdk/trace/init.py", line 1118, in start_span
parent_span_context = trace_api.get_current_span(
File "/otel-auto-instrumentation/opentelemetry/trace/propagation/init.py", line 48, in get_current_span
span = get_value(_SPAN_KEY, context=context)
File "/otel-auto-instrumentation/opentelemetry/context/init.py", line 97, in get_value
return context.get(key) if context is not None else get_current().get(key)
AttributeError: 'NoneType' object has no attribute 'get'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/tornado/web.py", line 1298, in send_error
self.write_error(status_code, **kwargs)
File "/usr/local/lib/python3.10/site-packages/tornado/web.py", line 1323, in write_error
self.finish(
File "/usr/local/lib/python3.10/site-packages/tornado/web.py", line 1242, in finish
self.on_finish()
File "/otel-auto-instrumentation/wrapt/wrappers.py", line 670, in call
return self._self_wrapper(self.wrapped, self._self_instance,
File "/otel-auto-instrumentation/opentelemetry/instrumentation/tornado/init.py", line 423, in _on_finish
_record_on_finish_metrics(server_histograms, handler)
File "/otel-auto-instrumentation/opentelemetry/instrumentation/tornado/init.py", line 635, in _record_on_finish_metrics
server_histograms[MetricInstruments.HTTP_SERVER_RESPONSE_SIZE].record(
File "/otel-auto-instrumentation/opentelemetry/sdk/metrics/_internal/instrument.py", line 264, in record
self._measurement_consumer.consume_measurement(
File "/otel-auto-instrumentation/opentelemetry/sdk/metrics/_internal/measurement_consumer.py", line 82, in consume_measurement
self._sdk_config.exemplar_filter.should_sample(
File "/otel-auto-instrumentation/opentelemetry/sdk/metrics/_internal/exemplar/exemplar_filter.py", line 131, in should_sample
span = trace.get_current_span(context)
File "/otel-auto-instrumentation/opentelemetry/trace/propagation/init.py", line 48, in get_current_span
span = get_value(_SPAN_KEY, context=context)
File "/otel-auto-instrumentation/opentelemetry/context/init.py", line 97, in get_value
return context.get(key) if context is not None else get_current().get(key)
AttributeError: 'NoneType' object has no attribute 'get'
Exception in callback _HandlerDelegate.execute..(<Task finishe...ibute 'get'")>) at /usr/local/lib/python3.10/site-packages/tornado/web.py:2438
handle: <Handle _HandlerDelegate.execute..(<Task finishe...ibute 'get'")>) at /usr/local/lib/python3.10/site-packages/tornado/web.py:2438>
Traceback (most recent call last):
File "/usr/local/lib/python3.10/asyncio/events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "/usr/local/lib/python3.10/site-packages/tornado/web.py", line 2438, in
fut.add_done_callback(lambda f: f.result())
File "/otel-auto-instrumentation/opentelemetry/instrumentation/asyncio/init.py", line 314, in trace_coroutine
self.record_process(start, attr, span, exception)
File "/otel-auto-instrumentation/opentelemetry/instrumentation/asyncio/init.py", line 358, in record_process
self.process_duration_histogram.record(duration, attr)
File "/otel-auto-instrumentation/opentelemetry/sdk/metrics/_internal/instrument.py", line 264, in record
self._measurement_consumer.consume_measurement(
File "/otel-auto-instrumentation/opentelemetry/sdk/metrics/_internal/measurement_consumer.py", line 82, in consume_measurement
self._sdk_config.exemplar_filter.should_sample(
File "/otel-auto-instrumentation/opentelemetry/sdk/metrics/_internal/exemplar/exemplar_filter.py", line 131, in should_sample
span = trace.get_current_span(context)
File "/otel-auto-instrumentation/opentelemetry/trace/propagation/init.py", line 48, in get_current_span
span = get_value(_SPAN_KEY, context=context)
File "/otel-auto-instrumentation/opentelemetry/context/init.py", line 97, in get_value
return context.get(key) if context is not None else get_current().get(key)
AttributeError: 'NoneType' object has no attribute 'get'
Error in exception logger
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/tornado/web.py", line 1767, in _execute
result = self.prepare()
File "/otel-auto-instrumentation/wrapt/wrappers.py", line 670, in call
return self._self_wrapper(self.wrapped, self._self_instance,
File "/otel-auto-instrumentation/opentelemetry/instrumentation/tornado/init.py", line 413, in _prepare
ctx = _start_span(tracer, handler)
File "/otel-auto-instrumentation/opentelemetry/instrumentation/tornado/init.py", line 522, in _start_span
span, token = _start_internal_or_server_span(
File "/otel-auto-instrumentation/opentelemetry/instrumentation/utils.py", line 147, in _start_internal_or_server_span
span = tracer.start_span(
File "/otel-auto-instrumentation/opentelemetry/sdk/trace/init.py", line 1118, in start_span
parent_span_context = trace_api.get_current_span(
File "/otel-auto-instrumentation/opentelemetry/trace/propagation/init.py", line 48, in get_current_span
span = get_value(_SPAN_KEY, context=context)
File "/otel-auto-instrumentation/opentelemetry/context/init.py", line 97, in get_value
return context.get(key) if context is not None else get_current().get(key)
AttributeError: 'NoneType' object has no attribute 'get'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/tornado/web.py", line 1839, in _handle_request_exception
self.log_exception(*sys.exc_info())
File "/otel-auto-instrumentation/wrapt/wrappers.py", line 670, in call
return self._self_wrapper(self.wrapped, self._self_instance,
File "/otel-auto-instrumentation/opentelemetry/instrumentation/tornado/init.py", line 442, in _log_exception
_record_on_finish_metrics(server_histograms, handler, error)
File "/otel-auto-instrumentation/opentelemetry/instrumentation/tornado/init.py", line 635, in _record_on_finish_metrics
server_histograms[MetricInstruments.HTTP_SERVER_RESPONSE_SIZE].record(
File "/otel-auto-instrumentation/opentelemetry/sdk/metrics/_internal/instrument.py", line 264, in record
self._measurement_consumer.consume_measurement(
File "/otel-auto-instrumentation/opentelemetry/sdk/metrics/_internal/measurement_consumer.py", line 82, in consume_measurement
self._sdk_config.exemplar_filter.should_sample(
File "/otel-auto-instrumentation/opentelemetry/sdk/metrics/_internal/exemplar/exemplar_filter.py", line 131, in should_sample
span = trace.get_current_span(context)
File "/otel-auto-instrumentation/opentelemetry/trace/propagation/init.py", line 48, in get_current_span
span = get_value(_SPAN_KEY, context=context)
File "/otel-auto-instrumentation/opentelemetry/context/init.py", line 97, in get_value
return context.get(key) if context is not None else get_current().get(key)
AttributeError: 'NoneType' object has no attribute 'get'

Steps to Reproduce

none

Expected Result

none

Actual Result

none

Additional context

none

Would you like to implement a fix?

None

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions