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

contrib/google.golang.org/api: update google.golang.org/api version #1971

Merged
merged 8 commits into from
May 24, 2023

Conversation

rarguelloF
Copy link
Contributor

@rarguelloF rarguelloF commented May 9, 2023

What does this PR do?

  • Update google.golang.org/api version used in the project and re-generate contrib/google.golang.org/api/endpoints_gen.go file using the same version.
  • Refactor gen_endpoints script to work more reliably (downloads the source code directly from the repo instead of trying to find the local version downloaded by go tooling) and create a separate go module so it's easier to run locally.
  • Update Testing outlier google.golang.org/api CI job to pin the google.golang.org/api version instead of google.golang.org/grpc.
  • Add WithEndpointMetadataDisabled option to contrib/google.golang.org/api to allow disabling the behavior of setting dynamically service.name and resource.name based on success/failure of endpoint identification.

Motivation

Trying to unblock #1889

Describe how to test/QA your changes

Reviewer's Checklist

  • Changed code has unit tests for its functionality.
  • If this interacts with the agent in a new way, a system test has been added.

@rarguelloF rarguelloF marked this pull request as ready for review May 9, 2023 13:31
@rarguelloF rarguelloF requested a review from a team May 9, 2023 13:31
@rarguelloF rarguelloF requested a review from a team as a code owner May 9, 2023 13:31
@dferstay
Copy link
Contributor

dferstay commented May 9, 2023

Thank you, @rarguelloF :)

Copy link
Contributor

@ajgajg1134 ajgajg1134 left a comment

Choose a reason for hiding this comment

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

So halfway through reviewing this code and leaving comments I realized most of the code from the new main.go file is copied from make_endpoints.go 😛 . So while we can make the changes I commented, it feels like a good idea to not modify too heavily.

One question: I think this might be considered a breaking change for customer reliant on this API right? As endpoints may now have different names? It doesn't seem like it will break compilation though? I'm thinking that the best approach for us here will be to modify the package docs for this package to make it very clear to customers that we will periodically regenerate the "known endpoints" from the google "source of truth" and that they do not follow sem ver for those changes and therefore changes may occur in a way that causes spans/metrics to have their names changed (if I'm properly understanding the difference, please feel free to word this in whatever makes the most sense to you since you've spent more time looking at this area than I have at this point)

@pr-commenter
Copy link

pr-commenter bot commented May 11, 2023

Benchmarks

Comparing candidate commit 8ed32c0 in PR branch rarguelloF/update-google-golang-org-api with baseline commit 768cd3a in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 24 metrics, 0 unstable metrics.

@rarguelloF
Copy link
Contributor Author

@ajgajg1134 Thanks for your review!
You are right, this could cause breaking changes on resource.name and service.name for customers relying on these, depending on the google.golang.org/api version they are using.
I added a warning comment in the package, and also an option WithEndpointMetadataEnabled to allow customers disabling this behavior entirely (it will be enabled by default). Please let me know what you think!

Copy link
Contributor

@ajgajg1134 ajgajg1134 left a comment

Choose a reason for hiding this comment

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

Very close, just a few small things now

@@ -116,6 +118,31 @@ func TestURLShortener(t *testing.T) {
assert.Equal(t, ext.SpanKindClient, s0.Tag(ext.SpanKind))
}

func TestWithEndpointMetadataEnabled(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func TestWithEndpointMetadataEnabled(t *testing.T) {
func TestWithEndpointMetadataDisabled(t *testing.T) {

svc.Representatives.RepresentativeInfoByAddress().Do()

spans := mt.FinishedSpans()
assert.Len(t, spans, 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
assert.Len(t, spans, 1)
require.Len(t, spans, 1)

svc.Representatives.RepresentativeInfoByAddress().Do()

spans := mt.FinishedSpans()
assert.Len(t, spans, 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
assert.Len(t, spans, 1)
require.Len(t, spans, 1)

func downloadGoogleApiSrc() string {
zipUrl := downloadUrl()
func downloadGoogleAPISrc() (string, error) {
zipUrl := googleAPIClientURL()
Copy link
Contributor

Choose a reason for hiding this comment

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

ooops I missed this one before

Suggested change
zipUrl := googleAPIClientURL()
zipURL := googleAPIClientURL()

@@ -83,3 +85,11 @@ func WithAnalyticsRate(rate float64) Option {
}
}
}

// WithEndpointMetadataEnabled allows to enable/disable the enriched Google endpoint metadata behavior for
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add some details here on why a customer would want to pass this option to override the default of true (totally ok to just copy some bits from the warning)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to write a shorter version of the warning here, please let me know if that works!

@dferstay
Copy link
Contributor

@ajgajg1134 ,

Very close, just a few small things now

It looks like all of your comments have been addressed. Would it be possible to get a re-review when you get a chance?

Copy link
Contributor

@ajgajg1134 ajgajg1134 left a comment

Choose a reason for hiding this comment

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

Looks good thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants