mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-08-01 17:34:38 +08:00
gRPC client instrumentation docs fixes (#245)
This commit is contained in:
@ -26,7 +26,7 @@ Usage Client
|
|||||||
import grpc
|
import grpc
|
||||||
|
|
||||||
from opentelemetry import trace
|
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 import TracerProvider
|
||||||
from opentelemetry.sdk.trace.export import (
|
from opentelemetry.sdk.trace.export import (
|
||||||
ConsoleSpanExporter,
|
ConsoleSpanExporter,
|
||||||
@ -51,8 +51,9 @@ Usage Client
|
|||||||
metrics.set_meter_provider(MeterProvider())
|
metrics.set_meter_provider(MeterProvider())
|
||||||
|
|
||||||
# Optional - export GRPC specific metrics (latency, bytes in/out, errors) by passing an exporter
|
# Optional - export GRPC specific metrics (latency, bytes in/out, errors) by passing an exporter
|
||||||
instrumentor = GrpcInstrumentorClient(exporter=ConsoleMetricsExporter(), interval=10)
|
instrumentor = GrpcInstrumentorClient().instrument(
|
||||||
instrumentor.instrument()
|
exporter = ConsoleMetricsExporter(),
|
||||||
|
interval = 10)
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
with grpc.insecure_channel("localhost:50051") as channel:
|
with grpc.insecure_channel("localhost:50051") as channel:
|
||||||
@ -175,6 +176,16 @@ class GrpcInstrumentorServer(BaseInstrumentor):
|
|||||||
|
|
||||||
|
|
||||||
class GrpcInstrumentorClient(BaseInstrumentor):
|
class GrpcInstrumentorClient(BaseInstrumentor):
|
||||||
|
"""
|
||||||
|
Globally instrument the grpc client
|
||||||
|
|
||||||
|
Usage::
|
||||||
|
|
||||||
|
grpc_client_instrumentor = GrpcInstrumentorClient()
|
||||||
|
grpc.client_instrumentor.instrument()
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
def _instrument(self, **kwargs):
|
def _instrument(self, **kwargs):
|
||||||
exporter = kwargs.get("exporter", None)
|
exporter = kwargs.get("exporter", None)
|
||||||
interval = kwargs.get("interval", 30)
|
interval = kwargs.get("interval", 30)
|
||||||
|
Reference in New Issue
Block a user