Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn off Statsbeat when proxy is used or any exception from the server #2221

Merged
merged 17 commits into from
Apr 13, 2022
Prev Previous commit
Next Next commit
Address feedback
  • Loading branch information
heyams committed Apr 7, 2022
commit e53cd2fc5341de1fbf5a5a956c6dcd1edee090cd
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,12 @@ private static AppIdSupplier start(Instrumentation instrumentation) {
}

// initialize StatsbeatModule and don't start Statsbeat when proxy is used
String proxyHost = config.proxy.host;
if (proxyHost == null || proxyHost.isEmpty()) {
String configProxyHost = config.proxy.host;
String systemPropertyProxyHost = System.getProperty("https.proxyHost");
if (configProxyHost == null
|| configProxyHost.isEmpty()
|| systemPropertyProxyHost == null
|| systemPropertyProxyHost.isEmpty()) {
statsbeatModule.start(telemetryClient, config);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,9 @@ private Consumer<HttpResponse> responseHandler(
}
},
exception -> {
operationLogger.recordFailure("exception retrieving response body", exception);
if (!isStatsbeat) {
operationLogger.recordFailure("exception retrieving response body", exception);
}
onFailure.accept(false);
});
}
Expand All @@ -362,11 +364,11 @@ private Consumer<Throwable> errorHandler(
String instrumentationKey, Consumer<Boolean> onFailure, OperationLogger operationLogger) {

return error -> {
if (isStatsbeat && error instanceof Exception) {
if (isStatsbeat) {
heyams marked this conversation as resolved.
Show resolved Hide resolved
// when sending a Statsbeat request and server returns an Exception, it's
// likely that it's using AMPLS or other private endpoints. In that case, we use the
// kill-switch to turn off Statsbeat.
// TODO (heya) track Statsbeat exception count via a new Statsbeat metric
// TODO (heya) track Statsbeat request exception count via a new Statsbeat metric
statsbeatModule.shutdown();
onFailure.accept(false);
return;
Expand Down