Skip to content

Commit 5dc2508

Browse files
committed
pr review
1 parent 19e2fb5 commit 5dc2508

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

gcp-auth-extension/src/main/java/io/opentelemetry/contrib/gcp/auth/GcpAuthAutoConfigurationCustomizerProvider.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import com.google.auth.oauth2.GoogleCredentials;
99
import com.google.auto.service.AutoService;
10+
import com.google.common.annotations.VisibleForTesting;
1011
import io.opentelemetry.api.common.AttributeKey;
1112
import io.opentelemetry.api.common.Attributes;
1213
import io.opentelemetry.contrib.gcp.auth.GoogleAuthException.Reason;
@@ -124,7 +125,7 @@ public int order() {
124125

125126
private static SpanExporter customizeSpanExporter(
126127
SpanExporter exporter, GoogleCredentials credentials, ConfigProperties configProperties) {
127-
if (shouldConfigureExporter(
128+
if (shouldCustomizeExporter(
128129
SIGNAL_TYPE_TRACES, SIGNAL_TARGET_WARNING_FIX_SUGGESTION, configProperties)) {
129130
return addAuthorizationHeaders(exporter, credentials, configProperties);
130131
}
@@ -133,14 +134,25 @@ private static SpanExporter customizeSpanExporter(
133134

134135
private static MetricExporter customizeMetricExporter(
135136
MetricExporter exporter, GoogleCredentials credentials, ConfigProperties configProperties) {
136-
if (shouldConfigureExporter(
137+
if (shouldCustomizeExporter(
137138
SIGNAL_TYPE_METRICS, SIGNAL_TARGET_WARNING_FIX_SUGGESTION, configProperties)) {
138139
return addAuthorizationHeaders(exporter, credentials, configProperties);
139140
}
140141
return exporter;
141142
}
142143

143-
static boolean shouldConfigureExporter(
144+
/**
145+
* Utility method to check whether OTLP exporters should be customized for the given target
146+
* signal.
147+
*
148+
* @param signal The target signal to check against. Could be one of {@value SIGNAL_TYPE_TRACES},
149+
* {@value SIGNAL_TYPE_METRICS} or {@value SIGNAL_TYPE_ALL}.
150+
* @param fixSuggestion A warning to alert the user that auth extension is not configured for the
151+
* provided target signal.
152+
* @param configProperties The {@link ConfigProperties} object used to configure the extension.
153+
* @return A boolean indicating whether the OTLP exporters should be customized or not.
154+
*/
155+
static boolean shouldCustomizeExporter(
144156
String signal, String fixSuggestion, ConfigProperties configProperties) {
145157
if (isSignalTargeted(signal, configProperties)) {
146158
return true;

gcp-auth-extension/src/main/java/io/opentelemetry/contrib/gcp/auth/GcpAuthDeclarativeConfigurationCustomizerProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import static io.opentelemetry.contrib.gcp.auth.GcpAuthAutoConfigurationCustomizerProvider.SIGNAL_TYPE_METRICS;
99
import static io.opentelemetry.contrib.gcp.auth.GcpAuthAutoConfigurationCustomizerProvider.SIGNAL_TYPE_TRACES;
10-
import static io.opentelemetry.contrib.gcp.auth.GcpAuthAutoConfigurationCustomizerProvider.shouldConfigureExporter;
10+
import static io.opentelemetry.contrib.gcp.auth.GcpAuthAutoConfigurationCustomizerProvider.shouldCustomizeExporter;
1111

1212
import com.google.auth.oauth2.GoogleCredentials;
1313
import com.google.auto.service.AutoService;
@@ -86,7 +86,7 @@ private static void customizeMeter(
8686
return;
8787
}
8888

89-
if (shouldConfigureExporter(
89+
if (shouldCustomizeExporter(
9090
SIGNAL_TYPE_METRICS, SIGNAL_TARGET_WARNING_YAML_FIX_SUGGESTION, configProperties)) {
9191
for (MetricReaderModel reader : meterProvider.getReaders()) {
9292
if (reader.getPeriodic() != null) {
@@ -122,7 +122,7 @@ private static void customizeTracer(
122122
return;
123123
}
124124

125-
if (shouldConfigureExporter(
125+
if (shouldCustomizeExporter(
126126
SIGNAL_TYPE_TRACES, SIGNAL_TARGET_WARNING_YAML_FIX_SUGGESTION, configProperties)) {
127127
for (SpanProcessorModel processor : tracerProvider.getProcessors()) {
128128
BatchSpanProcessorModel batch = processor.getBatch();

0 commit comments

Comments
 (0)