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: Add OpenTelemetry publish sample #1258

Merged
merged 1 commit into from
Sep 27, 2024
Merged

Conversation

mukund-ananthu
Copy link
Contributor

Fixes #<issue_number_goes_here> 🦕

@mukund-ananthu mukund-ananthu requested review from a team as code owners September 25, 2024 07:29
@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label Sep 25, 2024
Copy link

snippet-bot bot commented Sep 25, 2024

Here is the summary of changes.

You are about to add 1 region tag.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label bot added api: pubsub Issues related to the googleapis/python-pubsub API. samples Issues that are directly related to samples. labels Sep 25, 2024
@mukund-ananthu mukund-ananthu changed the title Add OpenTelemetry publish sample feat: Add OpenTelemetry publish sample Sep 25, 2024
Copy link

conventional-commit-lint-gcf bot commented Sep 25, 2024

🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use automerge label. Good luck human!

-- conventional-commit-lint bot
https://conventionalcommits.org/

@mukund-ananthu mukund-ananthu self-assigned this Sep 25, 2024
@mukund-ananthu mukund-ananthu added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Sep 25, 2024
@yoshi-kokoro yoshi-kokoro removed kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Sep 25, 2024
@mukund-ananthu mukund-ananthu force-pushed the publish_samples branch 6 times, most recently from 2fcd31e to 184b8e5 Compare September 25, 2024 21:42
# Choose and configure the exporter for your set up accordingly.

# Sample 1 in every 1000 traces.
sampler = ParentBased(root=TraceIdRatioBased(1 / 1000))
Copy link
Member

Choose a reason for hiding this comment

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

Can you sample at 100% to begin with and add a comment to lower the trace in production?

I can imagine customers who use the sample don't see that there are any traces exported and think something is broken.

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 use 1/100 with 10k messages published. That ensures there would be atleast 100 samples exported.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, changed it to 1 based on offline discussion.

Comment on lines 238 to 239
tracer = trace.get_tracer("google.cloud.pubsub_v1.publisher")
with tracer.start_as_current_span("parent cloud trace span"):
Copy link
Member

Choose a reason for hiding this comment

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

I think we should omit this, since it's not necessary to wrap the traces in this way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. This would mean, there would be no parent trace. But as discussed offline, we are good with this / this is intended.

@mukund-ananthu mukund-ananthu enabled auto-merge (squash) September 25, 2024 23:43
@mukund-ananthu mukund-ananthu force-pushed the publish_samples branch 2 times, most recently from 4edd561 to 326822f Compare September 27, 2024 04:12
@mukund-ananthu mukund-ananthu merged commit bc13ff0 into main Sep 27, 2024
26 of 27 checks passed
@mukund-ananthu mukund-ananthu deleted the publish_samples branch September 27, 2024 05:00
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 googleapis/python-pubsub API. samples Issues that are directly related to samples. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants