From 1cf78ea7d878bdd04ed97fbb97d6a83563329bf8 Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Wed, 8 Apr 2020 20:29:21 -0700 Subject: [PATCH] Fix local clusters (#318) --- src/emailservice/email_server.py | 3 ++- src/recommendationservice/recommendation_server.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/emailservice/email_server.py b/src/emailservice/email_server.py index e283ca4..9380ebb 100644 --- a/src/emailservice/email_server.py +++ b/src/emailservice/email_server.py @@ -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() diff --git a/src/recommendationservice/recommendation_server.py b/src/recommendationservice/recommendation_server.py index ac4cda9..1219555 100644 --- a/src/recommendationservice/recommendation_server.py +++ b/src/recommendationservice/recommendation_server.py @@ -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()