File tree Expand file tree Collapse file tree 8 files changed +109
-5
lines changed
opentelemetry-auto-instrumentation Expand file tree Collapse file tree 8 files changed +109
-5
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ opentelemetry-helpers-sql-obfuscation
3333opentelemetry-resource-detector-google_cloud_platform
3434opentelemetry-resource-detector-azure
3535opentelemetry-resource-detector-container
36+ opentelemetry-resource-detector-aws
3637```
3738
3839### Example installation strategies
Original file line number Diff line number Diff line change 1+ # Example
2+
3+ ## Installation
4+
5+ Install opentelemetry-auto-instrumentation through ` gem install `
6+ Then ` bundle install `
7+
8+
9+ ## Simple Example (simple-example)
10+
11+ ``` bash
12+ OTEL_RUBY_REQUIRE_BUNDLER=true OTEL_TRACES_EXPORTER=console RUBYOPT=" -r opentelemetry-auto-instrumentation" OTEL_RUBY_OPERATOR=false ruby app.rb
13+ ```
14+
15+ ## Rails Example (rails-example)
16+
17+ Without auto-instrumentation
18+ ``` bash
19+ bundle exec rackup config.ru
20+ ```
21+
22+ In other terminal make the request call
23+ ``` bash
24+ wget http://localhost:9292
25+ # or curl http://localhost:9292 if you have curl on system
26+ ```
27+
28+ With auto-instrumentation
29+ ``` bash
30+ OTEL_RUBY_REQUIRE_BUNDLER=false OTEL_TRACES_EXPORTER=console RUBYOPT=" -r opentelemetry-auto-instrumentation" OTEL_RUBY_OPERATOR=false bundle exec rackup config.ru
31+ ```
32+
33+ The load sequence must be opentelemetry-auto-instrumentation -> user library -> bundler.require (initialize otel sdk and instrumentation installation)
34+
35+ In other terminal make the request call
36+ ``` bash
37+ wget http://localhost:9292
38+ # or curl http://localhost:9292 if you have curl on system
39+ ```
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ # Gemfile
4+ source 'https://rubygems.org'
5+
6+ gem 'rails'
7+ gem 'rack'
8+ gem 'rake' , '13.0.6'
9+ gem 'bigdecimal' , '3.1.3'
10+ gem 'logger' , '1.5.3'
11+ gem 'webrick'
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ # Copyright The OpenTelemetry Authors
4+ #
5+ # SPDX-License-Identifier: Apache-2.0
6+
7+ require 'rails'
8+ require 'action_controller/railtie'
9+
10+ require 'bundler'
11+ Bundler . require
12+
13+ # MyApp
14+ class MyApp < Rails ::Application
15+ config . secret_key_base = 'your_secret_key_here'
16+ config . eager_load = false
17+ config . logger = Logger . new ( $stdout)
18+ config . api_only = true
19+ config . active_support . to_time_preserves_timezone = :zone
20+
21+ routes . draw do
22+ get '/' , to : 'application#index'
23+ get '/hello' , to : 'application#hello'
24+ post '/data' , to : 'application#create'
25+ end
26+ end
27+
28+ # ApplicationController
29+ class ApplicationController < ActionController ::API
30+ def index
31+ render json : { message : 'Hello World!' , time : Time . current }
32+ end
33+
34+ def hello
35+ name = params [ :name ] || 'World'
36+ render json : { greeting : "Hello #{ name } !" }
37+ end
38+
39+ def create
40+ render json : {
41+ message : 'Data received' ,
42+ data : params . except ( :controller , :action )
43+ }
44+ end
45+ end
46+
47+ MyApp . initialize!
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ require_relative 'app'
4+
5+ run MyApp
Original file line number Diff line number Diff line change 1- source 'https://rubygems.org'
1+ # frozen_string_literal: true
22
3+ source 'https://rubygems.org'
Original file line number Diff line number Diff line change 44#
55# SPDX-License-Identifier: Apache-2.0
66
7- url = URI . parse ( " http://catfact.ninja/fact" )
7+ url = URI . parse ( ' http://catfact.ninja/fact' )
88req = Net ::HTTP ::Get . new ( url . to_s )
9- res = Net ::HTTP . start ( url . host , url . port ) { |http |
9+ Net ::HTTP . start ( url . host , url . port ) do |http |
1010 http . request ( req )
11- }
11+ end
Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ def require(...)
118118
119119# set OTEL_OPERATOR to false if not in autoinstrumentation-ruby image, default to /otel-auto-instrumentation-ruby
120120# /otel-auto-instrumentation-ruby is set in opentelemetry-operator ruby.go
121- operator_gem_path = ENV [ 'OTEL_RUBY_OPERATOR' ] . nil? || ENV [ 'OTEL_RUBY_OPERATOR' ] == 'true' ? '/otel-auto-instrumentation-ruby' : nil
121+ operator_gem_path = ENV [ 'OTEL_RUBY_OPERATOR' ] == 'true' ? '/otel-auto-instrumentation-ruby' : nil
122122additional_gem_path = operator_gem_path || ENV [ 'OTEL_RUBY_ADDITIONAL_GEM_PATH' ] || Gem . dir
123123$stdout. puts "Loading the additional gem path from #{ additional_gem_path } " if ENV [ 'OTEL_RUBY_AUTO_INSTRUMENTATION_DEBUG' ] == 'true'
124124
You can’t perform that action at this time.
0 commit comments