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

samples: add OTel Tracing quickstart #1371

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

samples: add OTel Tracing quickstart #1371

wants to merge 6 commits into from

Conversation

cojenco
Copy link
Contributor

@cojenco cojenco commented Oct 30, 2024

No description provided.

@cojenco cojenco requested review from a team as code owners October 30, 2024 17:57
@cojenco cojenco requested a review from dandhlee October 30, 2024 17:57
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: storage Issues related to the googleapis/python-storage API. samples Issues that are directly related to samples. labels Oct 30, 2024
@cojenco cojenco marked this pull request as draft October 30, 2024 18:02
Copy link

snippet-bot bot commented Oct 30, 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


# Configure the sampling rate to control trace ingestion volume.
# Trace sampling rate must be in the range [0.0,1.0].
tracing_rate = 1.0
Copy link
Member

Choose a reason for hiding this comment

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

Is there a rule of thumb for tracing rate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It truly depends on the user application and how users want to balance cost vs trace volume. For quickstart purposes, I think we want to set to 1.0 to ensure users can see the traces in Cloud Trace console.


from opentelemetry import trace
from opentelemetry.exporter.cloud_trace import CloudTraceSpanExporter
from opentelemetry.instrumentation.requests import RequestsInstrumentor
Copy link
Member

Choose a reason for hiding this comment

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

call out that this is optional for requests spans

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

RequestsInstrumentor().instrument(tracer_provider=tracer_provider)

# Instantiate a storage client and perform a write and read workload.
storage_client = storage.Client()
Copy link
Member

Choose a reason for hiding this comment

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

Do you need a parent span that groups the requests being made?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to create a root span that groups all the requests, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/python-storage 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