GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: Add OpenTelemetry integration by sethmaxwl · Pull Request #149 · googleapis/python-pubsub

This repository was archived by the owner on Oct 13, 2026. It is now read-only.

Conversation

@sethmaxwl

@sethmaxwl sethmaxwl commented Jul 9, 2020 •
edited by plamut
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Closes #124
Requires. #158.

This PR adds OpenTelemetry tracing to publisher and subscriber clients.
This PR does not interfere with any underlying client functions. OpenTelemetry is an optional dependency that creates a trace that tracks a message from when it is published to when it is received by a subscriber.

Ongoing concerns

  • Adding OpenTelemetry to unit tests as external dependencies.

PR checklist

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jul 9, 2020
@sethmaxwl sethmaxwl changed the title Add OpenTelemetry integration feat: Add OpenTelemetry integration Jul 9, 2020
@plamut

plamut commented Jul 10, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

This requires dropping Python 2 support, right? (#131)

The samples PR is more or less ready to be merged (IMO) and we can then make one final Python 2 compatible release, and drop Python 2 support immediately afterwards.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@plamut plamut added the status: blocked Resolving the issue is dependent on other work. label Jul 10, 2020
@sethmaxwl

sethmaxwl commented Jul 10, 2020

Copy link
Copy Markdown
Author

This requires dropping Python 2 support, right? (#131)

Yes, OpenTelemetry does not support any Python version before 3.4.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

plamut
plamut reviewed Jul 10, 2020
View reviewed changes

@plamut plamut left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Disclaimer - I would have to familiarize myself with the opentelemetry library more, thus I primarily focused on the code aspects, and less on the actual semantics. Added suggestions at places where the code could benefit from them.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google/cloud/pubsub_v1/opentelemetry_tracing.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google/cloud/pubsub_v1/opentelemetry_tracing.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google/cloud/pubsub_v1/opentelemetry_tracing.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google/cloud/pubsub_v1/opentelemetry_tracing.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google/cloud/pubsub_v1/opentelemetry_tracing.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google/cloud/pubsub_v1/publisher/client.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread noxfile.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread tests/unit/pubsub_v1/opentelemetry/test_opentelemetry.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread tests/unit/pubsub_v1/publisher/test_publisher_client.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@sethmaxwl
feat: Add OpenTelemetry integration
6ebdf8e
@sethmaxwl

sethmaxwl commented Jul 13, 2020

Copy link
Copy Markdown
Author

Disclaimer - I would have to familiarize myself with the opentelemetry library more, thus I primarily focused on the code aspects, and less on the actual semantics. Added suggestions at places where the code could benefit from them.

All suggestions have been addressed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

plamut
plamut reviewed Jul 16, 2020
View reviewed changes

@plamut plamut left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM now, although we might have to do some additional changes once #158 is merged.

If you have time, you might want to rebase your branch onto that PR branch and see if things work there, too.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
plamut
plamut reviewed Jul 16, 2020
View reviewed changes
Comment thread google/cloud/pubsub_v1/publisher/client.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

sethmaxwl added 2 commits July 16, 2020 19:20
@sethmaxwl
Add test for span context key warning
84b3a12
@sethmaxwl
Merge branch 'master' into opentelemetry-integration
b629f9d
@sethmaxwl sethmaxwl mentioned this pull request Jul 17, 2020
Add OpenTelemetry Support googleapis/nodejs-pubsub#1061
Closed
@busunkim96 busunkim96 closed this Jul 31, 2020
@plamut plamut reopened this Jul 31, 2020
@sethmaxwl
Merge branch 'master' into opentelemetry-integration
a2d5037
@aravinsiva aravinsiva mentioned this pull request Aug 11, 2020
feat: add opentelemetry tracing googleapis/python-bigquery#215
Merged
@sethmaxwl
Rename subscriber span names
ce1bdda
AndrewAXue
AndrewAXue reviewed Aug 16, 2020
View reviewed changes
Comment thread README.rst

trace.set_tracer_provider(TracerProvider())
trace.get_tracer_provider().add_span_processor(
SimpleExportSpanProcessor(CloudTraceSpanExporter())

@AndrewAXue AndrewAXue Aug 16, 2020

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

You should be using a BatchSpanProcessor here. SimpleExportSpanProcessor exports all spans sequentially and will be very slow.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
chrisrossi
chrisrossi reviewed Aug 19, 2020
View reviewed changes
Comment thread google/cloud/pubsub_v1/publisher/client.py
if "googclient_OpenTelemetrySpanContext" in attrs:
_LOGGER.warning(
"googclient_OpenTelemetrySpanContext set on message"
"as an attribute, but will be overridden."

@chrisrossi chrisrossi Aug 19, 2020

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

No space between "message" and "as".

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@plamut
plamut requested a review from cguardia August 28, 2020 10:00
@cguardia cguardia added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 31, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 31, 2020
cguardia
cguardia approved these changes Aug 31, 2020
View reviewed changes

@cguardia cguardia left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

There are still a couple of suggestions from previous reviews, though they are mostly documentation and log warning formatting issues.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google/cloud/pubsub_v1/opentelemetry_tracing.py
"opentelemetry-api and opentelemetry-instrumentation"
"pip modules. See also"
"https://opentelemetry-python.readthedocs.io/en/stable/getting-started.html"
)

@cguardia cguardia Aug 31, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

There are no spaces at the end of these lines, which will cause words to be displayed together (e.g. couldnot, rather than could not).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google/cloud/pubsub_v1/opentelemetry_tracing.py
"A parent span was provided but it could not be"
"converted into a SpanContext. Ensure that the"
"parent is a mapping with at least a trace_id, span_id"
"and is_remote keys."

@cguardia cguardia Aug 31, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Same issue from above, where spaces are missing at the end of the lines.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread synth.py
python.py_samples()

# ----------------------------------------------------------------------------
# Additional unit test dependincies

@cguardia cguardia Aug 31, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Typo: dependencies.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google/cloud/pubsub_v1/opentelemetry_tracing.py
"pip modules. See also"
"https://opentelemetry-python.readthedocs.io/en/stable/getting-started.html"
)
USE_OPENTELEMETRY = False

@cguardia cguardia Aug 31, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Just a suggestion: In addition to the import try, wouldn't it be possible to use an environment variable for explicitly disabling opentelemetry? That way the tests below would not need to mess with sys.modules.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
cguardia
cguardia suggested changes Aug 31, 2020
View reviewed changes

@cguardia cguardia left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Seems like lint is not passing, plus there are a few failing tests. Please review.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@plamut

plamut commented Aug 31, 2020

Copy link
Copy Markdown
Contributor

Side note - before merging this (after releasing a new major version, of course), we must also run a few benchmarks to verify that the tracing does not hinder the performance, especially throughput. Mentioning as a a reminder to ourselves.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@johnbryan

johnbryan commented Aug 31, 2020

Copy link
Copy Markdown

Hi all, Seth (author of this PR) finished his Google internship in mid-August so I assume is not actively maintaining this PR now. I would be willing to address the remaining comments here but will not be able to get to it for a couple of weeks. Seth if I'm mistaken and you are indeed still following/working on this let us know, but I assume you have other things to do!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@plamut

plamut commented Aug 31, 2020

Copy link
Copy Markdown
Contributor

@johnbryan That sounds good, thanks!

No rush, though, as we need too release a new major version first anyway.

johnbryan reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@plamut plamut removed the status: blocked Resolving the issue is dependent on other work. label Sep 14, 2020
@plamut

plamut commented Sep 14, 2020

Copy link
Copy Markdown
Contributor

@johnbryan FYI, a new major version has been released, unblocking this PR (which needs an update now, however).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@anguillanneuf

anguillanneuf commented Oct 12, 2020

Copy link
Copy Markdown
Contributor

@johnbryan Will you have a chance to rebase this PR?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pamarc

pamarc commented Nov 30, 2020

Copy link
Copy Markdown

Hi, any news on this PR? This could be of use :)

CyberHippo, fabito, and bgarcial reacted with rocket emoji
All reactions
  • 🚀 3 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@plamut

plamut commented Mar 9, 2021

Copy link
Copy Markdown
Contributor

@johnbryan What's the status of this PR, do we have an ETA for bringing it to completion? Thanks in advance!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@parthea parthea assigned johnbryan Jul 18, 2021
@plamut

plamut commented Aug 4, 2021

Copy link
Copy Markdown
Contributor

Just as a quick status update, it is still not clear what exactly do want to be tracked, still awaiting the official specs. We can thus consider this PR blocked until further notice.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@plamut plamut added the status: blocked Resolving the issue is dependent on other work. label Aug 4, 2021
@plamut plamut mentioned this pull request Aug 4, 2021
PubSub add OpenTelemetry support #124
Closed
@plamut plamut added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Aug 4, 2021
@plamut
plamut changed the base branch from master to main August 25, 2021 10:18
@plamut
plamut requested review from a team August 25, 2021 10:18
@plamut
plamut changed the base branch from main to master August 26, 2021 11:53
@quartzmo quartzmo mentioned this pull request Sep 9, 2021
pubsub: Add OpenTelemetry tracing googleapis/google-cloud-ruby#13960
Closed
@owais owais mentioned this pull request Sep 14, 2021
Native OpenTelemetry integration falconry/falcon#1828
Open
@mikesmith37 mikesmith37 mentioned this pull request Nov 27, 2021
Open Telemetry Tracing Support #543
Closed
@pradn pradn added the release-please:force-run To run release-please label Mar 9, 2022
@release-please release-please Bot removed the release-please:force-run To run release-please label Mar 9, 2022
@CyberHippo

CyberHippo commented Aug 8, 2022

Copy link
Copy Markdown

Hi, is there any update/ETA on this PR? :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dmallanb

dmallanb commented Sep 15, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

This PR has been open a while - any updates as to why it's still blocked?
(EDIT 12/12/23 - have since decided myself it's not a required change and my use case has a workaround)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

pedroserrudo
pedroserrudo approved these changes Sep 18, 2023
View reviewed changes
dmaier-FN
dmaier-FN reviewed Dec 12, 2023
View reviewed changes
Comment thread google/cloud/pubsub_v1/publisher/client.py
data=data, ordering_key=ordering_key, attributes=attrs
)
span_name = "{} publisher".format(topic)
span_attributes = {"data": data.decode()}

@dmaier-FN dmaier-FN Dec 12, 2023

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

What is the argument for doing this? It seems to me that, best case, it results in the duplication of data in the message. But in the worst case it actually leaks sensitive information into observability stack, just like logging the output of a SQL query would.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tstringer-fn reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@mukund-ananthu

mukund-ananthu commented Sep 29, 2024

Copy link
Copy Markdown
Contributor

Closing this, since its now done.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mukund-ananthu mukund-ananthu closed this Sep 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

6 more reviewers
@chrisrossi chrisrossi chrisrossi left review comments
@plamut plamut plamut left review comments
@AndrewAXue AndrewAXue AndrewAXue left review comments
@dmaier-FN dmaier-FN dmaier-FN left review comments
@cguardia cguardia cguardia requested changes
@pedroserrudo pedroserrudo pedroserrudo approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@johnbryan johnbryan

Labels

cla: yes This human has signed the Contributor License Agreement. do not merge Indicates a pull request not ready for merge, due to either quality or timing. status: blocked Resolving the issue is dependent on other work.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

PubSub add OpenTelemetry support

Uh oh!

There was an error while loading. Please reload this page.

17 participants

@sethmaxwl @plamut @johnbryan @anguillanneuf @pamarc @CyberHippo @dmallanb @mukund-ananthu @chrisrossi @cguardia @pedroserrudo @AndrewAXue @dmaier-FN @pradn @googlebot @busunkim96 @yoshi-kokoro
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.