Skip to content

Commit

Permalink
gRPC client instrumentation docs fixes (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
alertedsnake authored Dec 11, 2020
1 parent 11a06db commit be463c5
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import grpc
from opentelemetry import trace
from opentelemetry.instrumentation.grpc import GrpcInstrumentorClient, client_interceptor
from opentelemetry.instrumentation.grpc import GrpcInstrumentorClient
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
ConsoleSpanExporter,
Expand All @@ -51,8 +51,9 @@
metrics.set_meter_provider(MeterProvider())
# Optional - export GRPC specific metrics (latency, bytes in/out, errors) by passing an exporter
instrumentor = GrpcInstrumentorClient(exporter=ConsoleMetricsExporter(), interval=10)
instrumentor.instrument()
instrumentor = GrpcInstrumentorClient().instrument(
exporter = ConsoleMetricsExporter(),
interval = 10)
def run():
with grpc.insecure_channel("localhost:50051") as channel:
Expand Down Expand Up @@ -175,6 +176,16 @@ def _uninstrument(self, **kwargs):


class GrpcInstrumentorClient(BaseInstrumentor):
"""
Globally instrument the grpc client
Usage::
grpc_client_instrumentor = GrpcInstrumentorClient()
grpc.client_instrumentor.instrument()
"""

def _instrument(self, **kwargs):
exporter = kwargs.get("exporter", None)
interval = kwargs.get("interval", 30)
Expand Down

0 comments on commit be463c5

Please sign in to comment.