Skip to content

Commit

Permalink
Remove debug logging statements
Browse files Browse the repository at this point in the history
  • Loading branch information
psx95 committed May 1, 2024
1 parent f0f2b19 commit 62c0c8a
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions samples/otlptrace/example-grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@
"""
This is a sample script that exports OTLP traces encoded as protobufs via gRPC.
"""
logging.basicConfig(
format="%(asctime)s %(levelname)-8s %(message)s",
level=logging.DEBUG,
datefmt="%Y-%m-%d %H:%M:%S",
)

class AutoRefreshAuthMetadataPlugin(AuthMetadataPlugin):
"""
A `gRPC AuthMetadataPlugin`_ that refreshes credentials and inserts them into
Expand All @@ -46,13 +40,10 @@ def __init__(self, credentials, request, default_host=None):
super().__init__(credentials, request, default_host)

def __call__(self, context, callback):
logging.info("Inserting credentials")
if self._credentials.expired:
logging.info("credentials expired, refresing")
if self._credentials.expired:
self._credentials.refresh(self._request)

auth_headers = [("authorization", f"Bearer {self._credentials.token}")]
logging.info(f"Adding headers {auth_headers}")
callback(auth_headers, None)

credentials, project_id = google.auth.default()
Expand All @@ -66,8 +57,6 @@ def __call__(self, context, callback):
channel_creds = grpc.composite_channel_credentials(grpc.ssl_channel_credentials(),
grpc.metadata_call_credentials(auth_metadata_plugin))

logging.info("Channel creds %s", channel_creds._credentials)

trace_provider = TracerProvider(resource=resource)
processor = BatchSpanProcessor(OTLPSpanExporter(credentials=channel_creds, insecure=False, headers={
"x-goog-user-project": credentials.quota_project_id,
Expand All @@ -77,7 +66,7 @@ def __call__(self, context, callback):
tracer = trace.get_tracer("my.tracer.name")

def do_work():
with tracer.start_as_current_span("span-name") as span:
with tracer.start_as_current_span("span-grpc") as span:
# do some work that 'span' will track
print("doing some work...")
# When the 'with' block goes out of scope, 'span' is closed for you
Expand Down

0 comments on commit 62c0c8a

Please sign in to comment.