opentelemetry-python-contrib icon indicating copy to clipboard operation
opentelemetry-python-contrib copied to clipboard

Allow access to grpc channel api with the client interceptor

Open ianmcnally opened this issue 2 years ago • 5 comments
trafficstars

This would close #1697. The interceptor channel as is breaks access to channel private attributes, like Channel._channel. To allow it, I wrapped the incoming channel with a getattr that tries Channel._channel if it isn't present in Channel.

Description

It's described in #1697 , but the gist is:

I'm using GrpcInstrumentorClient (https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/grpc/grpc.html#usage-client) version 0.30b1 in a python (3.7) flask application. When closing the channel, using a custom wrapper around channel, calls to the grpc.Channel._channel API fail.

Fixes #1697

Type of change

Please delete options that are not relevant.

  • [x] Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Instrument with GrpcInstrumentorClient().instrument() In a grpc middleware, or anywhere with access to the grpc channel object, call a method on channel._channel, like channel._channel.check_connectivity_state()

  • [x] Test A

Does This PR Require a Core Repo Change?

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

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

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

ianmcnally avatar Mar 10 '23 16:03 ianmcnally