Skip to content

Conversation

DylanRussell
Copy link
Contributor

Description

Add environment variables to allow ChannelCredentials and Session to be injected into OTLP exporters for auto instrumentation. See #4459 for more details..

Fixes # 4459

Type of change

Please delete options that are not relevant.

  • [x ] New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Unit tests

Does This PR Require a Contrib Repo Change?

  • Yes. - Link to PR:
  • [x ] No.

Checklist:

  • [ x] Followed the style guidelines of this project
  • Changelogs have been updated
  • [ x] Unit tests have been added
  • Documentation has been updated

@DylanRussell DylanRussell requested a review from a team as a code owner July 17, 2025 20:55

from grpc import ChannelCredentials # pylint: disable=import-error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be an issue if the SDK is running in an environment without grpcio installed? I know the operator auto-instrumentation layer for Python pre-installs the HTTP exporters and not the grpc exporters to avoid extension issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's a good point ! I don't think we should require these modules (requests, grpc) for the SDK, so we have to use try/catch blocks on the imports.. I updated the PR.. Let me know what you think

@xrmx xrmx moved this to Ready for review in @xrmx's Python PR digest Aug 18, 2025
@DylanRussell
Copy link
Contributor Author

DylanRussell commented Aug 25, 2025

I'm realizing there's 3 ways to do this in the exporters:

  1. Have HTTP AND GRPC specific env vars for metrics/logs/traces.
  2. Just one set of env vars for metrics/logs/traces that encompasses HTTP / GRPC, and we pass "HTTP" or "GRPC" to the entry point as an argument...
  3. Just one set of env vars, and the entry point provider has 2 entry points (one for HTTP one for GRPC), and the user must set the right entry point name in the env var depending on if they want HTTP or GRPC..

I'm going forward with #2 since that's simplest for both the user and the entry point provider. So the function signature that gets associated w/ the entry point should look like:

def credential_provider(otlp_exporter_type: Literal["HTTP", "GRPC"]) -> Union[requests.Session, grpc.ChannelCredentials]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ready for review
Development

Successfully merging this pull request may close these issues.

6 participants