open-telemetry / open-telemetry/opentelemetry-python-contrib
how can i receive metrics except trace
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with opentelemetry/instrumentation/tornado/init.py, especially _prepare, _log_exception, and _record_on_finish_metrics, then inspect the SDK context and exemplar files named in the traceback. Reproduce the failure with the auto-instrumented Tornado health endpoint and determine whether metrics-only configuration is supported. Done means metrics can be collected without spans and without the NoneType exception, or the supported configuration is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100