-
Notifications
You must be signed in to change notification settings - Fork 251
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
Add faraday instrumentation adapter #67 #148
Add faraday instrumentation adapter #67 #148
Conversation
* for access to global config, e.g., OpenTelemetry::Adapter.tracer
* e.g., $ docker-compose run ex-adapter-faraday $ ruby faraday.rb Expected: console output of SpanData
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.
This generally looks like it's on the right path. I have a handful of comments that follow. In addition to those, we'll need to consider testing and how that would look.
adapters/faraday/lib/opentelemetry/adapters/faraday/middlewares/tracer_middleware.rb
Show resolved
Hide resolved
adapters/faraday/lib/opentelemetry/adapters/faraday/middlewares/tracer_middleware.rb
Show resolved
Hide resolved
adapters/faraday/lib/opentelemetry/adapters/faraday/middlewares/tracer_middleware.rb
Outdated
Show resolved
Hide resolved
* want to be able to ship more instrumentation than a user needs, let the auto-installer determine what is applicable
* when 'faraday' isn't loaded/required already e.g., irb> require 'opentelemetry/adapters/faraday' irb> OpenTelemetry::Adapters::Faraday.install
* will only be called after Adapters::Faraday.install * reduces burden on caller
* for performance, since span.set_attribute involves a mutex, etc.
* to allow access to #http_text_format
* RE: "failures on heavily loaded CI server" -- increase delta experimentally, by 10x
adapters/faraday/lib/opentelemetry/adapters/faraday/middlewares/tracer_middleware.rb
Outdated
Show resolved
Hide resolved
hints: * for outbound requests: inject current span context into request headers * for inbound requests: extract remote span context from request headers, start a new span with parent context (using the extracted context)
* TRACER_VERSION can get locked to empty string if faraday isn't required yet
* allow (auto) installer to bind tracer to instrumentation * config[:tracer] will override default_tracer
…tation--67 ... # Conflicts: # sdk/test/opentelemetry/sdk/trace/export/batch_span_processor_test.rb
I've extracted the API changes to #154. |
I have noted this point in issue #155. |
* note: adapter.install effects aren't localized, so test order matters Update tests to avoid passing name, version to .install * name and version are now determined internally and shouldn't usually be passed in explicitly
example: $ bundle exec appraisal install $ bundle exec appraisal rake test
I have merged in the testing work mentioned in #155, now that the "shape" of the API is a little more solid (per sig feedback, etc.). |
adapters/faraday/test/opentelemetry/adapters/faraday/middlewares/tracer_middleware_test.rb
Show resolved
Hide resolved
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.
Thanks for the hard work. Given what we know today, this looks like a very solid preliminary blueprint for how we want to package instrumentation adapters for OTel. I'm approving this and will leave it open in case @fbogsany has any last requests.
adapters/faraday/lib/opentelemetry/adapters/faraday/middlewares/tracer_middleware.rb
Show resolved
Hide resolved
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.
This LGTM. We should figure out how to address the "disable for span reporting connection" issue and document it for authors of exporters.
* Use case: allow per-connection enabling/disabling of span reporting, possibly based on URL rules
* most likely failing due to bundler-2.1.x * see bundler issue #7489
* circleci build is failing after jruby:9.2.9-jre * theory: jruby includes (vendored) its own bundler version
I saw that faraday-1.0.0 was released, and have added an Appraisal for it. Also, there seems to be an issue with circleci + bundler-2.1.x (including 2.1.4) + appraisal (2.2.0), which is solved locally by using bundler-2.0.x and jruby-2.8.x (circleci config). |
👋 @duonoid. I had to integrate the changes from master before merging this PR (which I was just about to do). We now test against Ruby 2.7 and those tests are failing due to not being able to find a compatible version of bundler: https://circleci.com/gh/mutations/opentelemetry-ruby/1498?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link. Could you take a look? |
@mwear I had previously been able to work around the bundler+appraisal issues that I saw by uninstalling other versions of bundler and using, e.g., 2.0.x. It seems that ruby-2.7 is now including bundler-2.1.2 as a default gem, which cannot be uninstalled because it is a default gem thoughtbot/appraisal#162 mentions a similar issue For an immediate workaround, I could try removing Appraisal and just use |
* TODO: re-enable appraisal support once appraisal issue #162 is solved
Does this mean that we are only testing against one version of Faraday now? If so, I'm wondering how hard it would be to disable appraisal for Ruby 2.7 only. If it's more effort than it should be, then I'd settle for this and an issue to reinstate appraisal once a fix has been found. |
* don't run bundle exec appraisal rake test under ruby-2.7 * NOTE: build was failing under jruby:latest (9.3.x) as well
@mwear I have made some circle ci config changes to exclude 'appraisals' from running under ruby-2.7 for the time-being. |
🎉 Thanks for all your hard work @duonoid! |
Overview
Adds faraday instrumentation adapter.
Details
Related