feat: add gem for auto-instrumentation in otel-operator#1384
feat: add gem for auto-instrumentation in otel-operator#1384xuan-cao-swi wants to merge 85 commits intoopen-telemetry:mainfrom
Conversation
|
We don't need to push to make the gem ready/release, but the script file need to get some review first. |
|
👋 This pull request has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the |
|
👋 This pull request has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the |
There have been a lot of changes since my last review. Removing my approval to take another look.
…lemetry-ruby-contrib into auto-instrumentation
|
@xuan-cao-swi can you rebase main? I will test this ASAP and get it finished this Friday |
arielvalentin
left a comment
There was a problem hiding this comment.
One last set of requests.
There was a problem hiding this comment.
Whenever we patch and introduce methods that are not decorators including class, module, or instance variables we should prefix them with _otel for methods or @_otel for variables.
Any Constants should be marked as private and likely best to prefix with OTEL_ as well.
There was a problem hiding this comment.
Updated with prefix and private_constant
thompson-tomo
left a comment
There was a problem hiding this comment.
Can you also add it to the auto labeller config
| gem 'bundler' | ||
| gem 'minitest' | ||
| gem 'rake' | ||
| gem 'rubocop' | ||
| gem 'rubocop-performance' | ||
| gem 'simplecov' | ||
| gem 'yard' | ||
| gem 'opentelemetry-test-helpers' |
There was a problem hiding this comment.
Can you add versions like the others
.cspell.yml
Outdated
| - Triager | ||
| - triagers | ||
| - Untrace | ||
| - vitess | ||
| - webmocks | ||
| - yardoc | ||
| - rackup | ||
| - traceparent |
There was a problem hiding this comment.
Are we sure all of these are needed, I believe I added some of these to cspell ie yard
There was a problem hiding this comment.
I am not sure about what is needed; feel free to suggest which one to remove.
There was a problem hiding this comment.
My suggestion would be to remove them all & then see which one's you get warnings for.
There was a problem hiding this comment.
Removed these words
There was a problem hiding this comment.
Just checking on this one as I can still see them.
thompson-tomo
left a comment
There was a problem hiding this comment.
Do we also need to add it to toys for the release process?
…trib into auto-instrumentation
Co-authored-by: Ariel Valentin <arielvalentin@users.noreply.github.com> Co-authored-by: James Thompson <thompson.tomo@outlook.com>
…lemetry-ruby-contrib into auto-instrumentation
There was a problem hiding this comment.
Note we are still needing it to be added to labeller & release process. I have drafted updated docs to help guide this process aka #2219.
| Naming/FileName: | ||
| Enabled: false | ||
| Gemspec/DevelopmentDependencies: | ||
| Enabled: false |
There was a problem hiding this comment.
| Naming/FileName: | |
| Enabled: false | |
| Gemspec/DevelopmentDependencies: | |
| Enabled: false |
If naming is an issue add an exclusion rather than disable entire cop.
|
|
||
| if spec.respond_to?(:metadata) | ||
| spec.metadata['changelog_uri'] = "https://rubydoc.info/gems/#{spec.name}/#{spec.version}/file/CHANGELOG.md" | ||
| spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby-contrib/auto-instrumentation' |
There was a problem hiding this comment.
Update to match existing instrumentations ie use tag and directory.
| gemspec | ||
|
|
||
| group :test do | ||
| gem 'bundler' |
There was a problem hiding this comment.
This should have a version if we in fact need it no other gem list it.
There was a problem hiding this comment.
Removed the bundler
…lemetry-ruby-contrib into auto-instrumentation
kaylareopelle
left a comment
There was a problem hiding this comment.
This is so close! I noticed a few things in my review today.
| module OTelInitializer | ||
| @initialized = false | ||
|
|
||
| OTEL_INSTRUMENTATION_MAP = { |
There was a problem hiding this comment.
Are there any new instrumentations we should add here?
| require 'version' | ||
|
|
||
| Gem::Specification.new do |spec| | ||
| spec.name = 'auto-instrumentation' |
There was a problem hiding this comment.
What do you think about calling the gem opentelemetry-auto-instrumentation? Without the opentelemetry prefix it feels very broad.
I remember talking about naming a long time ago, but haven't found that conversation.
@thompson-tomo made a similar comment in the changelog about updating the name.
| opentelemetry-instrumentation-all | ||
| opentelemetry-exporter-otlp | ||
| opentelemetry-helpers-mysql | ||
| opentelemetry-helpers-sql-obfuscation |
There was a problem hiding this comment.
I think we want to replace the sql-obfuscation gem with opentelemetry-helpers-sql-processor
| opentelemetry-helpers-sql-obfuscation | ||
| opentelemetry-resource-detector-azure | ||
| opentelemetry-resource-detector-container | ||
| opentelemetry-resource-detector-aws |
There was a problem hiding this comment.
We also have a GCP resource detector. Does that make sense to include?
|
|
||
| ## Configuration | ||
|
|
||
| The following environment variables are specific to this gem (not standard OpenTelemetry variables): |
There was a problem hiding this comment.
What do you think about mentioning that all other OTEL environment variables can still be used for configuration with this gem?
|
|
||
| require 'test_helper' | ||
|
|
||
| describe 'AutoInstrumentation' do |
There was a problem hiding this comment.
| describe 'AutoInstrumentation' do | |
| describe 'OpenTelemetry::AutoInstrumentation' do |
| require 'opentelemetry-sdk' | ||
| require 'opentelemetry-instrumentation-all' |
There was a problem hiding this comment.
If we require these and opentelemetry/resource/detector here, could we be getting false positives? (just thinking about open-telemetry/opentelemetry-ruby#1956)
The tests seem to pass even if we remove those requires.
| warn '[OpenTelemetry] WARNING: Detected OpenTelemetry gems in your Gemfile: ' \ | ||
| "#{gem_names}. When using auto-instrumentation, OpenTelemetry gems are loaded " \ | ||
| 'from the auto-instrumentation gem path, NOT from your bundle. The gem versions ' \ | ||
| 'in your Gemfile/Gemfile.lock are not used and may cause version conflicts or ' \ | ||
| 'unexpected behavior. Please remove these gems from your Gemfile when using ' \ | ||
| 'auto-instrumentation.' |
There was a problem hiding this comment.
Does this mean that people who want to use metrics or logs can't use auto instrumentation? If that's the case, what do you think about adding a note to the README?
| gem 'rake', '13.0.6' | ||
| gem 'bigdecimal', '3.1.3' | ||
| gem 'logger', '1.5.3' |
There was a problem hiding this comment.
Why are these versions locked?
There was a problem hiding this comment.
This was the main problem I encountered with the rails example. I was using Ruby 3.4 and these versions are older than the latest versions. If I commented these versions out and regenerated the Gemfile.lock, everything worked fine.
When I tried to follow the instructions in the example README and installed the versions it asked for specifically, I kept getting the same error.
Description
This PR aims to contribute a script/gem that can load the necessary OpenTelemetry-related gems and initialize the SDK for the opentelemetry-operator. The script/gem also includes a resource detector as part of its features.
The main idea was inspired by new_relic, which prepends the bundler.require function and places the loading script at the end of the loading procedure. For apps or scripts that don't use Bundler or a Gemfile, more details on variations of app loading can be found in the README. Currently, the goal is to ensure that Rails apps can work, with future improvements in mind.
The reason behind creating this gem is to facilitate easy installation and dependency enforcement. Although for the OpenTelemetry-Operator Node.js, it puts the loading script directly in the src folder (and then copy over to binding volume), it still relies on the auto-instrumentation-node package to install all required packages (e.g., API/SDK and instrumentation packages).
The main purpose of the gem is to serve the OpenTelemetry-Operator, which requires more configuration changes (see the configuration section in the README). Users don't need to modify their Ruby app codebase while using the instrumentation from OpenTelemetry-Ruby, but anyone can still use it in any environment.
The gem name, file structure, and implementation need more suggestions to make them more reasonable. I have tested it with rails and sinatra (through rackup), and I currently still in the process of testing against the opentelemetry operator cluster locally. Once the operator testing done, I will mark the pr as ready.
Related to open-telemetry/opentelemetry-operator#3756