Skip to content

Commit

Permalink
throw IO Exception instead of generic Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
DNVindhya committed Jun 29, 2022
1 parent a04b802 commit 88efda3
Showing 1 changed file with 8 additions and 7 deletions.
Expand Up @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 =
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit 88efda3

Please sign in to comment.