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

fix: add missing platform and cloud provider values #1857

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

anupamdalmia10
Copy link

Add missing cloud.platform value to AWS Lambda, GCP Compute Engine, GCP Cloud Run, GCP GKE resource detectors and add cloud.provider to GCP GKE resource detector.

Add PR number
Copy link
Contributor

@dashpole dashpole left a comment

Choose a reason for hiding this comment

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

lgtm for GCP detectors

@anupamdalmia10
Copy link
Author

My bad, i'll update the failing test cases

@anupamdalmia10
Copy link
Author

Fixed the failing test cases

@anupamdalmia10
Copy link
Author

Looks like test cases from different module are failing...

@Aneurysm9
Copy link
Member

Looks like test cases from different module are failing...

Tests in instrumentation/github.com/aws/aws-lambda-go/otellambda are failing due to the change in detected resource attributes. Can you please update the test expectations.

@anupamdalmia10
Copy link
Author

Looks like test cases from different module are failing...

Tests in instrumentation/github.com/aws/aws-lambda-go/otellambda are failing due to the change in detected resource attributes. Can you please update the test expectations.

working on it

@anupamdalmia10
Copy link
Author

Looks like test cases from different module are failing...

Tests in instrumentation/github.com/aws/aws-lambda-go/otellambda are failing due to the change in detected resource attributes. Can you please update the test expectations.

working on it

@Aneurysm9 , updated the test cases in the concerned package

@codecov
Copy link

codecov bot commented Feb 24, 2022

Codecov Report

Merging #1857 (25cb430) into main (add6caa) will decrease coverage by 2.5%.
The diff coverage is 40.0%.

❗ Current head 25cb430 differs from pull request most recent head 5409850. Consider uploading reports for the commit 5409850 to get more accurate results

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #1857     +/-   ##
=======================================
- Coverage   72.1%   69.6%   -2.6%     
=======================================
  Files        124     127      +3     
  Lines       5330    5396     +66     
=======================================
- Hits        3848    3757     -91     
- Misses      1370    1501    +131     
- Partials     112     138     +26     
Impacted Files Coverage Δ
detectors/gcp/gce.go 8.6% <0.0%> (-0.2%) ⬇️
detectors/gcp/gke.go 0.0% <0.0%> (ø)
detectors/aws/lambda/detector.go 90.4% <100.0%> (+0.4%) ⬆️
detectors/gcp/cloud-run.go 100.0% <100.0%> (ø)
propagators/ot/ot_propagator.go 92.7% <0.0%> (-1.9%) ⬇️
...tation/github.com/aws/aws-sdk-go-v2/otelaws/aws.go 92.9% <0.0%> (-1.2%) ⬇️
...ion/github.com/aws/aws-sdk-go-v2/otelaws/config.go 100.0% <0.0%> (ø)
...om/aws/aws-sdk-go-v2/otelaws/dynamodbattributes.go
samplers/jaegerremote/sampler.go
...aegerremote/internal/testutils/sampling_manager.go
... and 21 more

@anupamdalmia10
Copy link
Author

anupamdalmia10 commented Feb 25, 2022

This particular check "codecov/patch" is failing because there is a change in both gce and gke detectors and the test cases/files for those do not exist as of now. Shall those be added as a part of this PR or are the changes good to be merged?

@MrAlias
Copy link
Contributor

MrAlias commented Feb 25, 2022

This particular check "codecov/patch" is failing because there is a change in both gce and gke detectors and the test cases/files for those do not exist as of now. Shall those be added as a part of this PR or are the changes good to be merged?

It would be appreciated if you wanted to add coverage for these here.

@anupamdalmia10
Copy link
Author

This particular check "codecov/patch" is failing because there is a change in both gce and gke detectors and the test cases/files for those do not exist as of now. Shall those be added as a part of this PR or are the changes good to be merged?

It would be appreciated if you wanted to add coverage for these here.

Sure @MrAlias , I'll work on the test cases and update the PR

@anupamdalmia10
Copy link
Author

@MrAlias , there is another PR in progress: #1584

It will depend on it how the test cases are going to be organised further in fir gcp detectors.

plantfansam referenced this pull request in plantfansam/opentelemetry-go-contrib Mar 18, 2022
@@ -18,6 +18,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
These attributes are detected automatically, but it is also now possible to provide a custom function to set attributes using `WithAttributeSetter`. (#1582)
- Add resource detector for GCP cloud function. (#1584)
- Add OpenTracing baggage extraction to the OpenTracing propagator in `go.opentelemetry.io/contrib/propagators/ot`. (#1880)
- Add missing `cloud.platform` value to AWS Lambda, GCP Compute Engine, GCP Cloud Run, GCP GKE resource detectors and add `cloud.provider` to GCP GKE resource detector. (#1857)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move this to the Unreleased section.

Comment on lines +31 to +48
type GCE struct {
mc metadataClient
onGCE func() bool
}

var NewGCE = func() *GCE {
return &GCE{
mc: metadata.NewClient(nil),
onGCE: metadata.OnGCE,
}
}

// compile time assertion that GCE implements the resource.Detector interface.
var _ resource.Detector = (*GCE)(nil)

// Detect detects associated resources when running on GCE hosts.
func (gce *GCE) Detect(ctx context.Context) (*resource.Resource, error) {
if !metadata.OnGCE() {
if !gce.onGCE() {
Copy link
Contributor

@MrAlias MrAlias Mar 23, 2022

Choose a reason for hiding this comment

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

This is an exported type in a stable package. It needs to be considered what will happen for an existing user that is declaring a new variable of this type already (i.e. GCE{}) and they upgrade: the onGCE field will be nil and this will panic.

This also exports a new variable (I'm not sure why is this isn't func declaration?). I would suggest we try and preserve the existing initialization behavior of the GCE type as best we can to support existing uses and not include this new var. Also, if we ultimately want to add this, it should not be done in a PR dedicated to the addition (not in a PR adding semconv values).

I expect this was done to accommodate mocking while testing. Instead of this approach, I would suggest abstract the metadata package functions used to be unexported package variables that a test could overwrite.

}

// NewCloudRun creates a CloudRun detector.
func NewGKE() *GKE {
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar here.

@MrAlias MrAlias added the area: detector Related to a detector package label Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: detector Related to a detector package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants