feat(gcp-auth): support 'none' option in GOOGLE_OTEL_AUTH_TARGET_SIGNALS#2899
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates GCP auth auto-configuration to only treat signals as “targeted” when the OTLP endpoint is a Google Cloud Telemetry endpoint, and adjusts tests to match the new targeting behavior.
Changes:
- Add endpoint-based eligibility check in
isSignalTargeted(onlytelemetry.googleapis.com/telemetry.mtls.googleapis.com). - Refactor test cases to reuse a shared OTel properties map and update expected outcomes for non-Google endpoints.
- Add/adjust parameterized test coverage for mixed/invalid configured target signals.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
gcp-auth-extension/src/main/java/io/opentelemetry/contrib/gcp/auth/GcpAuthAutoConfigurationCustomizerProvider.java |
Adds endpoint gating so auth customization only applies when exporting to Google telemetry endpoints. |
gcp-auth-extension/src/test/java/io/opentelemetry/contrib/gcp/auth/GcpAuthAutoConfigurationCustomizerProviderTest.java |
Updates/extends test cases to reflect the new endpoint-based targeting behavior and reuses shared OTel properties. |
psx95
left a comment
There was a problem hiding this comment.
Hi @stankiewicz, thanks for the PR! Based on our discussions, I think adding a adding a none option in the existing GOOGLE_OTEL_AUTH_TARGET_SIGNALS property makes more sense and is less of a disruptive change for your particular use case.
done! |
Eagerly loading GoogleCredentials.getApplicationDefault() inside the customize method throws a GoogleAuthException during OpenTelemetry SDK initialization if GCP Application Default Credentials are not configured, even if GCP authentication is disabled or not targeting GCP endpoints. This change defers the loading of credentials using a lazy Supplier so that they are only retrieved when a GCP-targeted signal is actually processed. Also restored the check in customizeResource to verify if any signal is targeted for GCP authentication before attempting to customize the resource, preventing ConfigurationException when GCP project ID is missing but GCP auth is disabled. Fixed Java 8 compatibility and static analysis (Error Prone, NullAway) warnings/errors.
| } | ||
|
|
||
| // Checks if the auth extension is configured to target the passed signal for authentication. | ||
| private static boolean isSignalTargeted(String checkSignal, ConfigProperties configProperties) { |
There was a problem hiding this comment.
This entire thing could be simplified by updating isSignalTargeted to consider none:
private static boolean isSignalTargeted(String checkSignal, ConfigProperties configProperties) {
String userSpecifiedTargetedSignals =
ConfigurableOption.GOOGLE_OTEL_AUTH_TARGET_SIGNALS.getConfiguredValueWithFallback(
configProperties, () -> SIGNAL_TYPE_ALL);
List<String> targetedSignals =
stream(userSpecifiedTargetedSignals.split(",")).map(String::trim).collect(toList());
if (targetedSignals.contains(SIGNAL_TYPE_NONE)) {
return false;
}
return targetedSignals.contains(checkSignal) || targetedSignals.contains(SIGNAL_TYPE_ALL);
}Now, isSignalTargeted will return false if it finds none specified by the user. This would prevent adding the additional if statement in customize methods and eliminate the need for hasSignal method.
(Out of scope for this PR):
As a follow-up the signals that could actually be checked (METRICS, TRACES) or accepted by this method should be converted to specific enums and isSignalTargeted should be updated to something like:
private static boolean isSignalTargeted(TelemetryTarget checkTelemetryTarget, ConfigProperties configProperties) {
...
}There was a problem hiding this comment.
Update this to:
String[] params = {SIGNAL_TYPE_METRICS, SIGNAL_TYPE_NONE, SIGNAL_TARGET_WARNING_FIX_SUGGESTION};
...
"GCP Authentication Extension is not configured for signal type: {0} or is configured with signal type: {1}. {2}",| .build()), | ||
| Arguments.of( | ||
| TargetSignalBehavior.builder() | ||
| .setConfiguredTargetSignals("none") |
There was a problem hiding this comment.
The extension allows setting up multiple signal types at once, add more test case with conflicting signal types like -
- "metrics", "traces", "none"
- "all", "none"
- "metrics, none"
The expected behavior is that if the user sets none, every other signal type gets ignored.
| * <li>{@code metrics} - Enables authentication for metric exports. | ||
| * <li>{@code traces} - Enables authentication for trace exports. | ||
| * <li>{@code all} - Enables authentication for all exports. | ||
| * <li>{@code none} - Disables authentication for all exports. |
There was a problem hiding this comment.
Document the behavior for none:
Disables authentication for all exports. If set alongside other signal types, it takes precedence and all other signal types will be ignored.
Also update README to reflect this behavior.
psx95
left a comment
There was a problem hiding this comment.
LGTM, pending one nit. Thanks for following up on the PR! 💯
| comma-separated list of OpenTelemetry signals for which this authentication | ||
| extension should be active. | ||
| Valid values are `metrics`, `traces`, and `all`. | ||
| Valid values are `metrics`, `traces`, `all`, and `none`. |
There was a problem hiding this comment.
nit: Add information about how none behaves here as well.
|
Hold off on merging till the pending comment is addressed. GitHub does not allow revoking approval for some reason. |
Ready to merge now. |
Description
This PR introduces a new
noneoption for theGOOGLE_OTEL_AUTH_TARGET_SIGNALSenvironment variable (andgoogle.otel.auth.target.signalssystem property) in the GCP Authentication Extension.Previously, there was no explicit way to completely disable the extension if it was loaded. This change allows users to explicitly set the target signals to
none, which:Documentation in
README.mdandConfigurableOptionJavadoc has been updated to reflect this new option.Testing
GcpAuthAutoConfigurationCustomizerProviderTestto verify thatnonecorrectly prevents modification of both traces and metrics exporters, and that warnings are suppressed.