From e7d26a4c2dfc05b587d92fb5e64c99447bd05f65 Mon Sep 17 00:00:00 2001 From: Michael Stella Date: Tue, 13 Apr 2021 18:22:43 -0400 Subject: [PATCH] Update gRPCContext wrapper class (#420) There are a few cases where one needs to dig into `grpc.ServicerContext` objects, and these fields were missing from our wrapper, which can cause issues with implmementation. --- CHANGELOG.md | 2 ++ .../src/opentelemetry/instrumentation/grpc/_server.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07e271e715..7fdfff350a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#387](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/387)) - Update redis instrumentation to follow semantic conventions ([#403](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/403)) +- Update gRPC instrumentation to better wrap server context + ([#420](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/420)) ### Added - `opentelemetry-instrumentation-urllib3` Add urllib3 instrumentation diff --git a/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_server.py b/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_server.py index 5321964a19..39ff47f278 100644 --- a/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_server.py +++ b/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_server.py @@ -71,6 +71,9 @@ def __init__(self, servicer_context, active_span): self.details = None super().__init__() + def __getattr__(self, attr): + return getattr(self._servicer_context, attr) + def is_active(self, *args, **kwargs): return self._servicer_context.is_active(*args, **kwargs)