diff --git a/gcp-observability/src/main/java/io/grpc/gcp/observability/GcpObservability.java b/gcp-observability/src/main/java/io/grpc/gcp/observability/GcpObservability.java index e2a0c443cf0f..aa5641f6fcfa 100644 --- a/gcp-observability/src/main/java/io/grpc/gcp/observability/GcpObservability.java +++ b/gcp-observability/src/main/java/io/grpc/gcp/observability/GcpObservability.java @@ -42,6 +42,7 @@ import io.opencensus.exporter.trace.stackdriver.StackdriverTraceExporter; import io.opencensus.trace.Tracing; import io.opencensus.trace.config.TraceConfig; +import java.io.IOException; import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; @@ -64,7 +65,7 @@ public final class GcpObservability implements AutoCloseable { * * @throws ProviderNotFoundException if no underlying channel/server provider is available. */ - public static synchronized GcpObservability grpcInit() throws Exception { + public static synchronized GcpObservability grpcInit() throws IOException { if (instance == null) { GlobalLoggingTags globalLoggingTags = new GlobalLoggingTags(); ObservabilityConfigImpl observabilityConfig = ObservabilityConfigImpl.getInstance(); @@ -95,7 +96,7 @@ static GcpObservability grpcInit( ObservabilityConfig config, InternalLoggingChannelInterceptor.Factory channelInterceptorFactory, InternalLoggingServerInterceptor.Factory serverInterceptorFactory) - throws Exception { + throws IOException { if (instance == null) { instance = new GcpObservability(sink, config, channelInterceptorFactory, serverInterceptorFactory); @@ -149,7 +150,7 @@ private void setProducer( } } - private void registerStackDriverExporter(String projectId) throws Exception { + private void registerStackDriverExporter(String projectId) throws IOException { if (config.isEnableCloudMonitoring()) { RpcViews.registerAllGrpcViews(); StackdriverStatsConfiguration.Builder statsConfigurationBuilder = @@ -159,8 +160,8 @@ private void registerStackDriverExporter(String projectId) throws Exception { } try { StackdriverStatsExporter.createAndRegister(statsConfigurationBuilder.build()); - } catch (Exception e) { - throw new Exception("Failed to register Stackdriver stats exporter, " + e.getMessage()); + } catch (IOException e) { + throw new IOException("Failed to register Stackdriver stats exporter, " + e.getMessage()); } metricsEnabled = true; } @@ -176,8 +177,8 @@ private void registerStackDriverExporter(String projectId) throws Exception { } try { StackdriverTraceExporter.createAndRegister(traceConfigurationBuilder.build()); - } catch (Exception e) { - throw new Exception("Failed to register Stackdriver trace exporter, " + e.getMessage()); + } catch (IOException e) { + throw new IOException("Failed to register Stackdriver trace exporter, " + e.getMessage()); } tracesEnabled = true; }