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): support opentelemetry tracing #10633

Closed
wants to merge 17 commits into from
Closed

Conversation

hongalex
Copy link
Member

@hongalex hongalex commented Aug 2, 2024

This PR merges changes two other reviewed PRS: in #8317 and #9594, which merged changes into a feature branch pubsub-otel-trace.

Specifically this includes

  • Tracing support for publishing and subscribing
  • context propagation between publisher and subscriber via Pub/Sub message attributes
  • Linking for batch RPC spans (publish, ack, nack/modack)
  • New setting EnableOpenTelemetryTracing to pass into NewClientWithConfig to enable tracing

NOTE: OpenTelemetry tracing standards are in active development, and thus attributes, links, and span names are EXPERIMENTAL and subject to change or removal without notice.

hongalex and others added 12 commits August 31, 2023 14:31
* feat(pubsub): add publish tracing

* refactor tests to use InMemoryExporter

* update copyright year

* run go mod tidy

* rename PubsubMessageCarrier -> MessageCarrier, fix race

* make messageCarrier not exported

* downgrade otel sdk version to support go1.17

* add short delay to ensure spans are exported

* context renaming

* chore(ci): fix yaml syntax (#8448)

* chore: release main (#8445)

:robot: I have created a release *beep* *boop*
---


<details><summary>policytroubleshooter: 1.9.0</summary>

## [1.9.0](https://togithub.com/googleapis/google-cloud-go/compare/policytroubleshooter/v1.8.0...policytroubleshooter/v1.9.0) (2023-08-18)


### Features

* **policytroubleshooter/iam:** Start generating apiv3 ([#8444](https://togithub.com/googleapis/google-cloud-go/issues/8444)) ([fb1a8cc](https://togithub.com/googleapis/google-cloud-go/commit/fb1a8ccfa81b8b36658207e333ee83666c87be75))
</details>

---
This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).

* chore(notebooks): add config to generate apiv2 (#8454)

* feat(notebooks): clients for Notebooks API V2 (#8455)

- [ ] Regenerate this pull request now.

docs: supports Workbench Instances

https://cloud.google.com/vertex-ai/docs/workbench/reference/rest

PiperOrigin-RevId: 558178233

Source-Link: https://togithub.com/googleapis/googleapis/commit/ad329f84c0876a6f28026a01be584d3134a4df72

Source-Link: https://togithub.com/googleapis/googleapis-gen/commit/77e1a0df50f67c0e1c9a9fd768c82f931f601cec
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNzdlMWEwZGY1MGY2N2MwZTFjOWE5ZmQ3NjhjODJmOTMxZjYwMWNlYyJ9

* chore(ci): find changes on most recent main commit (#8457)

* chore: add datastore to allowlist of things to generate still (#8458)

* chore: release main (#8456)

:robot: I have created a release *beep* *boop*
---


<details><summary>notebooks: 1.10.0</summary>

## [1.10.0](https://togithub.com/googleapis/google-cloud-go/compare/notebooks/v1.9.1...notebooks/v1.10.0) (2023-08-21)


### Features

* **notebooks:** Clients for Notebooks API V2 ([#8455](https://togithub.com/googleapis/google-cloud-go/issues/8455)) ([1859e6c](https://togithub.com/googleapis/google-cloud-go/commit/1859e6ca01499ed297167aef60ae1d34a2ed24ea))
</details>

---
This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).

* fix(bigquery): value for datasetID on foreign keys (#8447)

Fixes #8442

* feat(datastore): SUM and AVG aggregations (#8307)

* feat(datastore): SUM and AVG aggregations

* feat(datastore): Fixing integration tests for SUM AVG

* feat(datastore): Fixing integration tests

* feat(datastore): Fixing integration tests

* feat(datastore): Updating protos

* feat(datastore): updating protos

* feat(datastore): Undo go.work.sum changes

* feat(datastore): Used new protos

* feat(datastore): Use latest protos

---------

Co-authored-by: meredithslota <[email protected]>
Co-authored-by: kolea2 <[email protected]>

* feat(datastore): Support aggregation query in transaction (#8439)

* feat(datastore): Support aggregation query in transaction

* feat(datastore): Refactoring integration test

* feat(datastore): Integration tests for sum and average

* chore(main): release datastore 1.14.0 (#8351)

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>

* add helper functions for creating publish spans

* refactor error tests

* fix(spanner): Transaction was started in a different session (#8467)

* fix: Transaction was started in a different session

Retrying a "Session not found" error could cause a "Transaction was
started in a different session" error. This happened because:
1. The detection of a "Session not found" error would remove the session
   from the pool, and also remove the session ID from the session handle
2. The retry mechanism would check out a new session from the pool, but
   not assign it to the transaction yet
3. The retry would then proceed to retry the transaction with an
   explicit BeginTransaction RPC. This function would however pick a new
   session from the pool, because step 2 had not yet assigned the
   transaction a new session.
4. The higher level retry loop would then after executing the
   BeginTransaction RPC assign the session that was picked in step 2 to
   the transaction.
5. The transaction would then proceed to use the session from step 2
   with the transaction from step 3.

* chore: remove unused code

* chore: fix import order

* feat(spanner/spannertest): support INSERT DML (#7820)

Co-authored-by: rahul2393 <[email protected]>

* test(datastore): Truncate transaction read time to millisecond (#8473)

* fix(datastore): Truncate transaction read time to millisecond

* fix(datastore): Truncate transaction read time to microsecond

* feat(auth): add base auth package (#8465)

This package provides:
- A TokenProvider interface
- A Token type
- A standard auth Error type
- Configuration and TokenProvider for 2L0 oauth2 flows
- Configuration and TokenProvider for 3L0 oauth2 flows
- A means to cache tokens

This code has been adapted from the golang oauth2 repo. In particular the types here are analogous to: oauth2, authhandler, and jwt packages. It should feel familiar for anyone who as worked with that library before, but it only provides a subset of the features that we require for our client libraries and auth stack as defined by our AIPs.

* test(datastore): Correct read time before creating entities (#8475)

* chore(main): release spanner 1.49.0 (#8468)

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>

* chore(ci): increase new-client fetch depth (#8483)

* feat(spanner/spansql): add support for bit functions, sequence functions and GENERATE_UUID (#8482)

* feat(spanner/spansql): add support for bit functions and sequence functions

* feat(spanner/spansql): add support for function GENERATE_UUID

* test(storage): increase timeout for requester pays test (#8421)

Increasing timeout to give some leeway. If the test continues flaking, we should investigate further why it fails.

* test(pubsublite): fix flaky TestRoutingPublisherUnloadIdlePublisher (#8478)

Fixes: https://togithub.com/googleapis/google-cloud-go/issues/7942

* test(pubsublite): fix flaky TestIntegration_SeekSubscription (#8479)

Fixes: https://togithub.com/googleapis/google-cloud-go/issues/7454

* feat(spanner): allow non-default service accounts (#8488)

* feat(spanner/spansql): add support for SEQUENCE statements (#8481)

* feat(spanner/spansql): add support for SEQUENCE statements

* feat(spanner/spansql): remove using generics for CI env

---------

Co-authored-by: Sri Harsha CH <[email protected]>
Co-authored-by: rahul2393 <[email protected]>

* chore(config): add config to generate apiv1 (#8490)

* feat(container): add support for NodeConfig Update (#8461)

feat: publicize tpu topology in v1 API
PiperOrigin-RevId: 560116372

Source-Link: googleapis/googleapis@cf6f9ee

Source-Link: googleapis/googleapis-gen@b618aaf
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjYxOGFhZmE2NDE3NDFhNTYxNWMyMTZiODc4NjAwNjViZGMzMGY4ZCJ9
BEGIN_NESTED_COMMIT
feat(bigquery/datapolicies): support using custom UDF in the data policy
PiperOrigin-RevId: 559480224

Source-Link: googleapis/googleapis@4ffd6cd

Source-Link: googleapis/googleapis-gen@2fa3b74
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMmZhM2I3NDk2ZjkyNzQ1YjE4N2QxYmI1ZjllNjVlNWQwMzZhNWQwNyJ9
END_NESTED_COMMIT
BEGIN_NESTED_COMMIT
docs(optimization): Minor formatting fix

PiperOrigin-RevId: 559474510

Source-Link: googleapis/googleapis@5b3202b

Source-Link: googleapis/googleapis-gen@7b6e921
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiN2I2ZTkyMTA4NTEzZDBmZjIxNjE0ZTBkYTZmYzgyNzkxNjFlNTVhMyJ9
END_NESTED_COMMIT
BEGIN_NESTED_COMMIT
docs(datacatalog): fix typo

PiperOrigin-RevId: 559249168

Source-Link: googleapis/googleapis@f49882a

Source-Link: googleapis/googleapis-gen@08d36c5
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMDhkMzZjNTkzYWI2MGYxODRhZmUxNDIzYTg0ZGY5NDJlMmFmMmRmMiJ9
END_NESTED_COMMIT
BEGIN_NESTED_COMMIT
docs(billing): update comments

PiperOrigin-RevId: 559241398

Source-Link: googleapis/googleapis@6fe53ad

Source-Link: googleapis/googleapis-gen@11b03ab
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMTFiMDNhYjZmOWNmMDBjYmNkMTY3MWFmN2Y1ZDcxMzQ4ZjI1NmE3NCJ9
END_NESTED_COMMIT
BEGIN_NESTED_COMMIT
feat(billing/budgets): Supported project-level-budgets in Public Budget API V1

Added scope for project scope filter in ListBudgetsRequest. When this field is set to a project's resource name, the budgets returned are tracking the costs for the given project.

feat: Added enable_project_level_recipients for project owner budget emails

Setting this field to true will enable email notification to project owners for project-level budgets.

PiperOrigin-RevId: 559152052

Source-Link: googleapis/googleapis@113867b

Source-Link: googleapis/googleapis-gen@017d177
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMDE3ZDE3N2Y1MTQ2OWQxNTA0MTdiN2I2YTQ1ZDk5ZDk5NjNmNzgxMyJ9
END_NESTED_COMMIT
BEGIN_NESTED_COMMIT
feat(billing/budgets): Supported project-level-budgets in Public Budget API V1Beta

Added scope for project scope filter in ListBudgetsRequest. When this field is set to a project's resource name, the budgets returned are tracking the costs for the given project.

feat: Added enable_project_level_recipients for project owner budget emails

Setting this field to true will enable email notification to project owners for project-level budgets.

PiperOrigin-RevId: 559151636

Source-Link: googleapis/googleapis@138b0f1

Source-Link: googleapis/googleapis-gen@41c0ba8
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDFjMGJhODk5Zjc2Y2JiZmFjZGRlY2NmN2M3Njk3NDdhY2FmZTI2ZCJ9
END_NESTED_COMMIT
BEGIN_NESTED_COMMIT
feat(dataproc): support min_num_instances for primary worker and InstanceFlexibilityPolicy for secondary worker

PiperOrigin-RevId: 559135594

Source-Link: googleapis/googleapis@4a5a6fd

Source-Link: googleapis/googleapis-gen@5c91126
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNWM5MTEyNjFmMDAyNTdmNzY4YThhMzIzYWExYTNlNDgzNjQwYzFkMiJ9
END_NESTED_COMMIT
BEGIN_NESTED_COMMIT
docs(batch): Revert HTML formats in comments

docs: Expand compute resource API docs to match with VM's machine type field

docs: Clarify Batch API proto doc about pubsub notifications
PiperOrigin-RevId: 558940776

Source-Link: googleapis/googleapis@a7ee700

Source-Link: googleapis/googleapis-gen@4f3a485
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGYzYTQ4NWYzY2ViMTNiNjdlMDUyMmI3NGE3ZmQ5Y2NkZTJhYTZhMSJ9
END_NESTED_COMMIT

* feat(config): new clients (#8493)

* feat(spanner/spansql): add support for aggregate functions (#8498)

* fix exactly once delivery test

* fix(pubsub): make AckWithResult return success when constructed (#8489)

---------

Co-authored-by: Noah Dietz <[email protected]>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Chris Smith <[email protected]>
Co-authored-by: gcf-owl-bot[bot] <78513119+gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Cody Oss <[email protected]>
Co-authored-by: Alvaro Viebrantz <[email protected]>
Co-authored-by: Baha Aiman <[email protected]>
Co-authored-by: meredithslota <[email protected]>
Co-authored-by: kolea2 <[email protected]>
Co-authored-by: Knut Olav Løite <[email protected]>
Co-authored-by: go_vargo <[email protected]>
Co-authored-by: rahul2393 <[email protected]>
Co-authored-by: TOGASHI Tomoki <[email protected]>
Co-authored-by: Brenna N Epp <[email protected]>
Co-authored-by: tmdiep <[email protected]>
Co-authored-by: Roman Slyusarchuk <[email protected]>
Co-authored-by: Sri Harsha CH <[email protected]>
Co-authored-by: Julie Qiu <[email protected]>
Co-authored-by: yoshi-code-bot <[email protected]>
* feat(pubsub): add otel tracing for subscribing

* fix trailing merge conflict lines

* run go mod tidy

* add subscribe span test, refactor to map to use SpanContext

* switch to using sync.map for optimization

* fix parent spans

* switch subscribe spans to use events

* make subscribe span end after ack

* use updated custom attribute names

* standardize attribute names and span names

* upgrade dependencies, add disable trace flag

* clean up create span

* wrap publish side spans in helpers

* add test for when telemetry is disabled

* fix issue with nil clientconfig

* add code.Function attribute

* make tracing disabled by default, wrap spans in helper

* span events cleanup

* support context passing for GAPIC spans

* undo changes to semconv in storage client

* fix publish tests and parent ordering

* fix disable tracing and error tests

* update subscribe side spans and tests

* fix race condition, rename concurrency control span

* add basic benchmark

* make process span end after ack/nack called

* run go mod tidy

* switch to using exp/slices since go1.21 not supported yet

* update activeSpans sync.map comment and name

* add helper function for extracting resource ID from fqn

* guard otel code behind flag

* switch code.function naming

* remove extra argument from toMessage

* revert changes to ctx passed to fc.acquire, fix span hierarchy

* rename span map and fix context clobbering bug

* removed unused args in message conversion helpers

* fix leak in activeSpans map, shift context passing, rename attributes

* fix failing tests because of attributes changes

* cleanup unused function and rename FQN helper

* simplify payload size attribute calc

* fix issue with trying to use uninitialized span

* run go mod tidy

* upgrade to latest semconv version

* migrate more attributes to semconv 1.26.0

* fix trace tests

* add ink to batch spans for message spans

* add name of span we are linking to

* add project attribute, check span recording

* fix issue with not pulling messages

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

* run go.mod tidy

* temporarily remove use of go1.21 package

* remove use of attribute.Set which requires go1.21

* downgrade back to go1.20

* downgrade back to go1.20

* bump go version to use latest otel version

* update enable otel client comment

* improve documentation, fix ack/modack logic flow

* clarified context assignment comment for otelctx

* fix span context propagation in subscribe spans

* undo bad merge, fix empty project FQN parsing
@hongalex hongalex requested review from shollyman and a team as code owners August 2, 2024 22:28
@product-auto-label product-auto-label bot added the api: pubsub Issues related to the Pub/Sub API. label Aug 2, 2024
Copy link

google-cla bot commented Aug 2, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

go.work.sum Outdated
Comment on lines 87 to 90
<<<<<<< HEAD
golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457/go.mod h1:pRgIJT+bRLFKnoM1ldnzKoxTIn14Yxz928LQRYYgIN0=
=======
>>>>>>> 443e0ee35d1d0730d1101a96f97c8d4f5ce43095
Copy link

Choose a reason for hiding this comment

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

@hongalex I tried pubsub/v1.42.0-beta.otel.trace but failed go work vendor because have this line.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for letting me know, that should be fixed now.

You can also try pulling the latest version from the feature branch using go get cloud.google.com/go/pubsub@pubsub-otel-trace

Either way, we're hoping to merge this PR into main soon.

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.

I'm assuming this is a mechanical change based on the description. If you need me to scrutinize this further, let me know and I'll make more than the cursory pass here.

@hongalex hongalex closed this Aug 19, 2024
@hongalex hongalex reopened this Aug 19, 2024
@hongalex
Copy link
Member Author

This PR is superseded by #10709

@hongalex hongalex closed this Aug 19, 2024
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.

3 participants