Skip to content

feat(gcp-auth): support 'none' option in GOOGLE_OTEL_AUTH_TARGET_SIGNALS#2899

Merged
jaydeluca merged 5 commits into
open-telemetry:mainfrom
stankiewicz:gcp_auth
Jun 12, 2026
Merged

feat(gcp-auth): support 'none' option in GOOGLE_OTEL_AUTH_TARGET_SIGNALS#2899
jaydeluca merged 5 commits into
open-telemetry:mainfrom
stankiewicz:gcp_auth

Conversation

@stankiewicz

@stankiewicz stankiewicz commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Description

This PR introduces a new none option for the GOOGLE_OTEL_AUTH_TARGET_SIGNALS environment variable (and google.otel.auth.target.signals system 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:

  1. Disables authentication (no authorization headers are added) for all signals.
  2. Suppresses the warning logs (e.g., "GCP Authentication Extension is not configured for signal type...") that would otherwise appear when signals are not targeted, ensuring a silent and intentional disablement.

Documentation in README.md and ConfigurableOption Javadoc has been updated to reflect this new option.

Testing

  • Added a new parameterized test case in GcpAuthAutoConfigurationCustomizerProviderTest to verify that none correctly prevents modification of both traces and metrics exporters, and that warnings are suppressed.

@stankiewicz
stankiewicz requested a review from a team as a code owner June 2, 2026 15:09
Copilot AI review requested due to automatic review settings June 2, 2026 15:09
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jun 2, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

@github-actions
github-actions Bot requested review from jsuereth and psx95 June 2, 2026 15:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (only telemetry.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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

@psx95 psx95 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@stankiewicz stankiewicz changed the title Limit targeting of exporters in GCP Auth Extension to GCP endpoints feat(gcp-auth): support 'none' option in GOOGLE_OTEL_AUTH_TARGET_SIGNALS Jun 8, 2026
@stankiewicz

Copy link
Copy Markdown
Contributor Author

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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
 ...
 }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 psx95 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Add information about how none behaves here as well.

@psx95
psx95 self-requested a review June 11, 2026 16:47
@psx95

psx95 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Hold off on merging till the pending comment is addressed. GitHub does not allow revoking approval for some reason.

@psx95

psx95 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Hold off on merging till the pending comment is addressed. GitHub does not allow revoking approval for some reason.

Ready to merge now.

@jaydeluca
jaydeluca added this pull request to the merge queue Jun 12, 2026
Merged via the queue into open-telemetry:main with commit 6b0e5b4 Jun 12, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants