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

Pubsub client instrumentation #10547

Closed
samwright opened this issue Feb 14, 2024 · 2 comments
Closed

Pubsub client instrumentation #10547

samwright opened this issue Feb 14, 2024 · 2 comments
Labels
enhancement New feature or request needs triage New issue that requires triage

Comments

@samwright
Copy link
Contributor

samwright commented Feb 14, 2024

Is your feature request related to a problem? Please describe.

At my company we use Google Cloud PubSub a lot, and would like to create spans from sending and receiving messages.

Describe the solution you'd like

I have done this #10546

Describe alternatives you've considered

The pubsub client comes with OpenCensus support built-in, but without all the lovely otel attributes and features.

Additional context

A few things to note:

  • I added a few attributes in PubsubAttributes, ideally these become part of semantic-conventions soon (I've linked to PRs in that class)
  • The subscriber's receive span uses the publisher's create span as its parent. I don't mind changing that, or making it configurable to instead pointing to it using a SpanLink
  • I made some choices about how to name topic/subscription, which should be discussed. What we get given are: projects/{{NAME_OF_GCP_PROJECT}}/topics/{{NAME_OF_TOPIC}} and projects/{{NAME_OF_GCP_PROJECT}}/subscriptions/{{NAME_OF_SUBSCRIPTION}}, which are good for uniqueness but IMO a bit too long for a span name, but also isn't quite the right format for cloud.resource_id.

Here are the spans created when publishing and receiving a message:

Field or Attribute Span Batch Span Create Span Receive
Span name my-topic publish my-topic create my-subscriber receive
Parent my-topic create
Links my-topic create
SpanKind CLIENT PRODUCER CONSUMER
cloud.resource_id "//pubsub.googleapis.com/projects/my-project/topics/my-topic" "//pubsub.googleapis.com/projects/my-project/topics/my-topic" "//pubsub.googleapis.com/projects/my-project/subscriptions/my-subscription"
messaging.system "gcp_pubsub" "gcp_pubsub" "gcp_pubsub"
messaging.operation "publish" "create" "receive"
messaging.destination.name "my-topic" "my-topic"
messaging.client_id "my-subscription"
messaging.batch.message_count 1
messaging.gcp_pubsub.message.ordering_key "my-key" [1] "my-key" [1]
messaging.message.body.size 1024 1024
messaging.message.envelope.size 1234
messaging.message.id "abc123"
messaging.gcp_pubsub.message.ack_result "ack" [2]

[1] Attribute is not present if there is no ordering key

[2] The message receiver can either:

  1. choose to acknowledge the message (attribute is "ack"),
  2. choose to not acknowledge the message (attribute is "nack"),
  3. not do either (attribute is not set)
@samwright samwright added enhancement New feature or request needs triage New issue that requires triage labels Feb 14, 2024
@trask
Copy link
Member

trask commented Feb 27, 2024

@samwright does it make sense to close this based on your #10546 (comment)?

The python and java clients will get native support for otel (see comment), so no need to carry on with this PR

@samwright
Copy link
Contributor Author

Yes, sorry I meant to close this ticket but forgot about it. I'm looking forward to official otel support in the pubsub clients!

@samwright samwright closed this as not planned Won't fix, can't repro, duplicate, stale Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs triage New issue that requires triage
Projects
None yet
Development

No branches or pull requests

2 participants