Fix local clusters (#318)

This commit is contained in:
Daniel Sanche 2020-04-08 20:29:21 -07:00 committed by GitHub
parent f1a8e88f9b
commit 1cf78ea7d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -22,6 +22,7 @@ import time
import grpc
from jinja2 import Environment, FileSystemLoader, select_autoescape, TemplateError
from google.api_core.exceptions import GoogleAPICallError
from google.auth.exceptions import DefaultCredentialsError
import demo_pb2
import demo_pb2_grpc
@ -189,7 +190,7 @@ if __name__ == '__main__':
project_id=os.environ.get('GCP_PROJECT_ID'),
transport=AsyncTransport)
tracer_interceptor = server_interceptor.OpenCensusServerInterceptor(sampler, exporter)
except KeyError:
except (KeyError, DefaultCredentialsError):
logger.info("Tracing disabled.")
tracer_interceptor = server_interceptor.OpenCensusServerInterceptor()

View file

@ -22,6 +22,7 @@ from concurrent import futures
import googleclouddebugger
import googlecloudprofiler
from google.auth.exceptions import DefaultCredentialsError
import grpc
from opencensus.trace.exporters import print_exporter
from opencensus.trace.exporters import stackdriver_exporter
@ -108,7 +109,7 @@ if __name__ == "__main__":
project_id=os.environ.get('GCP_PROJECT_ID'),
transport=AsyncTransport)
tracer_interceptor = server_interceptor.OpenCensusServerInterceptor(sampler, exporter)
except KeyError:
except (KeyError, DefaultCredentialsError):
logger.info("Tracing disabled.")
tracer_interceptor = server_interceptor.OpenCensusServerInterceptor()