open-telemetry / open-telemetry/opentelemetry-python

Make it possible to intercept the gRPC channel for OTLP based export

Open
#4,802 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature-request
Dominant language
Python
Stars
2.6k
Forks
1k
Avg merge
4d 15h
Merged PRs (30d)
19

Description

Is your feature request related to a problem?

I'm having trouble with a particular use of OTLP export, and it would have been helpful to be able to use gRPC channel interceptors as a debugging tool.

https://grpc-interceptor.readthedocs.io/en/latest/#client-interceptors

However, there is no way to pass down an interceptor into the OTLP gRPC exporter code.

Describe the solution you'd like

In the code here:
https://github.com/open-telemetry/opentelemetry-python/blob/main/exporter/opentelemetry-exporter-otlp-proto-grpc/src/opentelemetry/exporter/otlp/proto/grpc/exporter.py

A sketch of the logic might be something like:

+ def _default_interceptor(channel):
+  return channel

class OTLPExporterMixin(
   ...
   channel_options=...,
+ channel_interceptor=None):
+ channel_interceptor = channel_interceptor or _default_interceptor
...
+ self._channel = channel_interceptor(self._channel)
self._client = self._stub(self._channel)  # type: ignore [reportCallIssue]
...

Along with exposing access to channel_interceptor in the __init__ methods of the consuming classes (e.g. OTLPSpanExporter, OTLPMetricExporter, etc.)

Describe alternatives you've considered

No response

Additional Context

No response

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with exporter/opentelemetry-exporter-otlp-proto-grpc/src/opentelemetry/exporter/otlp/proto/grpc/exporter.py and trace how the channel is created and passed to the stub. Then inspect the init methods of consuming exporters such as OTLPSpanExporter and OTLPMetricExporter. Done means callers can provide a channel interceptor through those exporters and the interceptor is applied before the client stub is created.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
observability-sre
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.