Unify gcp resource detector#2747
Merged
jaydeluca merged 4 commits intoopen-telemetry:mainfrom Apr 10, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR successfully removes the external dependency on the GCP Resource Detection Support Library (com.google.cloud.opentelemetry:detector-resources-support:0.36.0) by inlining all the detection code directly into the gcp-resources module. This is a dependency unification effort that maintains the same public APIs and functionality.
Changes:
- Adds 11 new platform detection classes (
GcpPlatformDetector,GcpMetadataConfig,EnvironmentVariables,DetectedPlatform,AttributeKeys, and platform-specific implementations) to replace the external library functionality - Adds 4 new test support files (
TestUtils,GcpPlatformDetectorTest,GcpMetadataConfigTest,EnvVarMock) with comprehensive test coverage from the original library - Updates
GCPResourceProviderand its tests to use the new local classes instead of external imports - Updates
build.gradle.ktsto remove the external dependency and add test dependencies (mockito-inlineandwiremock-jre8)
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| gcp-resources/src/main/java/.../GcpPlatformDetector.java | New main platform detector class replacing the external library |
| gcp-resources/src/main/java/.../GcpMetadataConfig.java | New metadata configuration class for fetching GCP instance attributes |
| gcp-resources/src/main/java/.../EnvironmentVariables.java | New interface for environment variable access abstraction |
| gcp-resources/src/main/java/.../DetectedPlatform.java | New interface defining the contract for detected platforms |
| gcp-resources/src/main/java/.../AttributeKeys.java | New attribute keys constants |
| gcp-resources/src/main/java/.../Google*.java | Platform-specific implementations (GCE, GKE, GAE, Cloud Run, Cloud Functions) |
| gcp-resources/src/main/java/.../GCPResourceProvider.java | Updated to use local classes instead of external library |
| gcp-resources/src/test/java/.../GcpPlatformDetectorTest.java | New comprehensive test suite for platform detection |
| gcp-resources/src/test/java/.../GcpMetadataConfigTest.java | New test suite for metadata configuration |
| gcp-resources/src/test/java/.../TestUtils.java | New test utility for stubbing endpoints |
| gcp-resources/build.gradle.kts | Removed external dependency, added test dependencies |
gcp-resources/src/main/java/io/opentelemetry/contrib/gcp/resource/GoogleCloudRunJob.java
Outdated
Show resolved
Hide resolved
gcp-resources/src/main/java/io/opentelemetry/contrib/gcp/resource/GoogleCloudRunJob.java
Outdated
Show resolved
Hide resolved
jsuereth
approved these changes
Apr 9, 2026
jaydeluca
reviewed
Apr 9, 2026
gcp-resources/src/main/java/io/opentelemetry/contrib/gcp/resource/GcpMetadataConfig.java
Show resolved
Hide resolved
jaydeluca
reviewed
Apr 9, 2026
gcp-resources/src/test/java/io/opentelemetry/contrib/gcp/resource/GcpPlatformDetectorTest.java
Outdated
Show resolved
Hide resolved
jaydeluca
reviewed
Apr 9, 2026
gcp-resources/src/test/java/io/opentelemetry/contrib/gcp/resource/TestUtils.java
Outdated
Show resolved
Hide resolved
jaydeluca
approved these changes
Apr 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
Remove the dependency on GCP Resource Detection Support Library by inlining the detection code directly in this resource detector.
Testing:
Documentation:
There should be no user-facing change since the external APIs were not affected.