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 — [WIP] feat: add opentelemetry instrumentation by robertlaurin · Pull Request #3185 · googleapis/google-api-ruby-client

Conversation

@robertlaurin

@robertlaurin robertlaurin commented Mar 8, 2021

Copy link
Copy Markdown

No description provided.

Sorry, something went wrong.

Uh oh!

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

All reactions
@google-cla

google-cla Bot commented Mar 8, 2021

Copy link
Copy Markdown

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

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
  • It's possible we don't have your GitHub username or you're using a different email address on your commit. Check your existing CLA data and verify that your email is set on your git commits.
Corporate signers
  • Your company has a Point of Contact who decides which employees are authorized to participate. Ask your POC to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the Google project maintainer to go/cla#troubleshoot (Public version).
  • The email used to register you as an authorized contributor must be the email used for the Git commit. Check your existing CLA data and verify that your email is set on your git commits.
  • The email used to register you as an authorized contributor must also be attached to your GitHub account.

ℹ️ Googlers: Go here for more info.

All reactions

Sorry, something went wrong.

Uh oh!

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

@google-cla google-cla Bot added the cla: no This human has *not* signed the Contributor License Agreement. label Mar 8, 2021
robertlaurin
robertlaurin commented Mar 8, 2021
View reviewed changes

@robertlaurin robertlaurin left a comment

Copy link
Copy Markdown
Author

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.

Hey @dazuma, here's rough draft here to get the discussion/review started.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread google-apis-core/lib/google/apis/core/http_command.rb

begin
require 'opencensus'
OPENCENSUS_AVAILABLE = true

@robertlaurin robertlaurin Mar 8, 2021

Copy link
Copy Markdown
Author

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.

Did you want to maintain support for opencensus in addition to opentelemetry?

Sorry, something went wrong.

Uh oh!

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

All reactions

@dazuma dazuma Mar 11, 2021

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.

Uhh, yeah, as much as I don't want to support OpenCensus here anymore, I also don't think we should rip it out unceremoniously. We should rather add a deprecation warning for a time. Can we use the logic of: try requiring opentelemetry and if that works enable it, otherwise try requiring opencensus and if that works enable it, otherwise disable both? So you can just leave the opencensus_{begin,end}_span methods in place, and add new ones for OpenTelemetry.

Sorry, something went wrong.

Uh oh!

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

robertlaurin reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread google-apis-core/lib/google/apis/core/instrumentation.rb Outdated
module Google
module Apis
module Core
class Instrumentation < OpenTelemetry::Instrumentation::Base

@robertlaurin robertlaurin Mar 8, 2021

Copy link
Copy Markdown
Author

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.

I included the instrumentation base as it surfaces configuration in a consistent way with other instrumented gems.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread google-apis-core/spec/google/apis/core/http_command_spec.rb Outdated
expect(events[0].uncompressed_size).to eql 0
expect(events[1].type).to eql :RECEIVED
expect(events[1].uncompressed_size).to eql 11
span_double = instance_double(OpenTelemetry::Trace::Span)

@robertlaurin robertlaurin Mar 8, 2021

Copy link
Copy Markdown
Author

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.

I don't typically reach for doubles, but I was apprehensive towards including opentelemetry-sdk so we could use the in memory exporter to assert the generated spans.

Sorry, something went wrong.

Uh oh!

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

All reactions

@dazuma dazuma Mar 11, 2021

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.

Why were you apprehensive? Perfectly happy including the SDK gem as a development dependency (not a runtime dependency) so it's available for tests, if it will make this cleaner.

Sorry, something went wrong.

Uh oh!

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

All reactions

@robertlaurin robertlaurin Mar 17, 2021 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Author

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.

Why were you apprehensive?

I just didn't want to assume that you would want the SDK included so I opted to present a quick alternative first so I could get your feedback. I will change this to use the SDK as I address the rest of your feedback.

Sorry, something went wrong.

Uh oh!

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

All reactions
@fbogsany fbogsany mentioned this pull request Jun 14, 2022
Google API client instrumentation open-telemetry/opentelemetry-ruby-contrib#25
Closed
dazuma
dazuma reviewed Mar 11, 2021
View reviewed changes
Comment thread google-apis-core/lib/google/apis/core/http_command.rb

begin
require 'opencensus'
OPENCENSUS_AVAILABLE = true

@dazuma dazuma Mar 11, 2021

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.

Uhh, yeah, as much as I don't want to support OpenCensus here anymore, I also don't think we should rip it out unceremoniously. We should rather add a deprecation warning for a time. Can we use the logic of: try requiring opentelemetry and if that works enable it, otherwise try requiring opencensus and if that works enable it, otherwise disable both? So you can just leave the opencensus_{begin,end}_span methods in place, and add new ones for OpenTelemetry.

Sorry, something went wrong.

Uh oh!

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

robertlaurin reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread google-apis-core/lib/google/apis/core/http_command.rb Outdated
'http.host' => url.host.to_s,
'http.method' => method.to_s,
'http.target' => url.path.to_s,
'peer.service' => 'google'

@dazuma dazuma Mar 11, 2021

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.

I don't think most google backends are actually emitting spans or setting service.name so it may not matter that much... But from my understanding of the semantics of this attribute, I suggest using url.host.to_s which will return the "official" ID of the service being called.

Sorry, something went wrong.

Uh oh!

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

robertlaurin reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread google-apis-core/lib/google/apis/core/http_command.rb Outdated
# Log exceptions and continue, so OpenTelemetry failures don't cause
# the entire request to fail.
logger.debug { sprintf('Error opening OpenCensus span: %s', e) }
logger.debug { sprintf('Error opening OpenTelemetry span: %s', e) }

@dazuma dazuma Mar 11, 2021

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.

I know the opencensus code used sprintf. That was unfortunate and I should have changed it. Could you just use normal string interpolation for this?

Sorry, something went wrong.

Uh oh!

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

robertlaurin reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread google-apis-core/lib/google/apis/core/http_command.rb Outdated
'peer.service' => 'google'
}

@opentelemetry_span = Google::Apis::Core::Instrumentation.instance.tracer.start_span(url.host.to_s, attributes: attributes)

@dazuma dazuma Mar 11, 2021

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.

In general, what's the best practice for naming spans? This just provides the service name. Should we include the method being called?

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread google-apis-core/spec/google/apis/core/http_command_spec.rb Outdated
expect(events[0].uncompressed_size).to eql 0
expect(events[1].type).to eql :RECEIVED
expect(events[1].uncompressed_size).to eql 11
span_double = instance_double(OpenTelemetry::Trace::Span)

@dazuma dazuma Mar 11, 2021

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.

Why were you apprehensive? Perfectly happy including the SDK gem as a development dependency (not a runtime dependency) so it's available for tests, if it will make this cleaner.

Sorry, something went wrong.

Uh oh!

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

All reactions
@dazuma dazuma added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 11, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 11, 2021
@robertlaurin robertlaurin closed this Mar 23, 2021
@robertlaurin
robertlaurin force-pushed the feat-add-opentelemetry branch from fcb8442 to d2f2abb Compare March 23, 2021 15:19
@robertlaurin

robertlaurin commented Mar 23, 2021

Copy link
Copy Markdown
Author

Accidentally did a bad rebase the close the PR :/

Re-opened -> #3414

All reactions

Sorry, something went wrong.

Uh oh!

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

@robertlaurin robertlaurin mentioned this pull request Mar 23, 2021
feat: add opentelemetry instrumentation #3414
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@dazuma dazuma dazuma left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

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

Assignees

No one assigned

Labels

cla: no This human has *not* signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

3 participants

@robertlaurin @dazuma @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.