Skip to content

how can i receive metrics except trace #3778

@lfj

Description

@lfj

Describe your environment

OS: linux
Python version: 3.10
Package version: (e.g., 0.46.0)
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'
500 GET /health (10.231.248.6) 2.72ms

What happened?

I used the auto-instrumentation approach to integrate OpenTelemetry into a Python project, but encountered this issue above. Our goal is to collect only metrics data without generating any spans. Is there a way to achieve this? Can it be done through environment variables?

Steps to Reproduce

empty

Expected Result

empty

Actual Result

empty

Additional context

empty

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