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

feat(pubsub): add otel tracing with links #9594

Merged

Conversation

hongalex
Copy link
Member

@hongalex hongalex commented Mar 15, 2024

This replace #8592 and adds the missing subscribe side spans + updates the publish side spans to match our most recent design

  • Use links instead of parent/child spans for batch RPC operations
  • Align spans names with most recent OpenTelemetry messaging semantic conventions
  • Align attributes to most recent messaging semconv
  • Add subscribe side integration tests
  • Fix integration tests to use span ID generator
  • Integrate the newly added AddLinks API to get bidirectional links

Note: this PR uses an experimental golang.org/x/exp/slices package, which was added in go 1.21. This also depends on OpenTelemetry v1.28.0, which requires go 1.21 or higher. This PR will have failing vet.sh checks, but should be merged into the base branch, pubsub-otel-trace. That branch instead should wait on bumping the min go version before merging.

…/google-cloud-go into pubsub-otel-trace-receive-clean
@hongalex hongalex changed the title feat(pubsub): add otel subscribe tracing with links feat(pubsub): add otel tracing with links Jul 2, 2024
@hongalex hongalex requested a review from shollyman July 2, 2024 22:47
@hongalex hongalex marked this pull request as ready for review July 2, 2024 22:50
revert lang version changes to go.mod/work

revert changes to go.mod

fix go otel dependency versions

remove unneeded changes

revert renaming of ctx

add clarifying comment to activeSpans map

run go mod tidy

commit go.sum

run go mod tidy
Copy link

@feywind feywind left a comment

Choose a reason for hiding this comment

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

Overall, this looks pretty good :) I need to catch up now...

pubsub/iterator.go Show resolved Hide resolved
pubsub/iterator.go Outdated Show resolved Hide resolved
pubsub/iterator.go Outdated Show resolved Hide resolved
pubsub/trace.go Show resolved Hide resolved
pubsub/iterator.go Show resolved Hide resolved
pubsub/iterator.go Outdated Show resolved Hide resolved
s := strings.Split(fqn, "/")
// Some tests don't use FQN, in which case return empty projectID.
if len(s) == 1 {
return "", s[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a default project retained on the client?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not for tests, since we're instantiating the iterator directly via newMessageIterator We should probably change the tests to use an actual project. If that's preferred, I can make that change and remove the check here.

Copy link
Contributor

Choose a reason for hiding this comment

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

If empty project for tests is a consistent idiom for pubsub it's fine for the time being, but might be good to revisit.

Copy link
Member Author

Choose a reason for hiding this comment

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

It only happens once, admittedly, so not exactly an idiom. I fixed that test now, but also made this return empty strings for both if the format is not "projects/p/subscriptions/s"

pubsub/subscription.go Show resolved Hide resolved
@hongalex hongalex requested a review from shollyman July 22, 2024 22:53
pubsub/iterator.go Outdated Show resolved Hide resolved
@alvarowolfx alvarowolfx self-requested a review July 31, 2024 17:58
pubsub/iterator.go Outdated Show resolved Hide resolved
s := strings.Split(fqn, "/")
// Some tests don't use FQN, in which case return empty projectID.
if len(s) == 1 {
return "", s[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

If empty project for tests is a consistent idiom for pubsub it's fine for the time being, but might be good to revisit.

pubsub/subscription.go Show resolved Hide resolved
Copy link
Contributor

@shollyman shollyman left a comment

Choose a reason for hiding this comment

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

Approving this. Most of my feedback is derived from my less frequent interactions with this client, and the PR itself includes testing and benchmarking for the status quo.

@jameshartig
Copy link
Contributor

@hongalex can we get another pre-release of this for testing?

@hongalex hongalex merged commit 10826f0 into googleapis:pubsub-otel-trace Aug 2, 2024
130 of 172 checks passed
@hongalex
Copy link
Member Author

hongalex commented Aug 2, 2024

@hongalex can we get another pre-release of this for testing?

Yeah, I created another release:

go get cloud.google.com/go/pubsub@v1.42.0-beta.otel.trace

This doesn't contain changes for configuring num callbacks, but I'll update that branch to pull in changes from here as well.

@jameshartig
Copy link
Contributor

Thanks!

This doesn't contain changes for configuring num callbacks, but I'll update that branch to pull in changes from here as well.

That's okay for now, we have another application where we can test the traces without needing to configure num callbacks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the Pub/Sub API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants