File tree Expand file tree Collapse file tree 13 files changed +28
-26
lines changed
Expand file tree Collapse file tree 13 files changed +28
-26
lines changed Original file line number Diff line number Diff line change 1616
1717 # Add environment information
1818 c . resource = OpenTelemetry ::SDK ::Resources ::Resource . create (
19- 'deployment.environment.name' => ENV . fetch ( 'RACK_ENV' , 'development' ) ,
19+ 'deployment.environment.name' => ENV . fetch ( 'RACK_ENV' , 'development' )
2020 )
2121end
2222
3737 'operation' => 'fetch_data' ,
3838 'plant_type' => 'cedar' ,
3939 'is_evergreen' => true
40- } ,
40+ }
4141)
4242
4343# Emit a warning log with different attributes.
4848 body : 'Database connection is slow.' ,
4949 attributes : {
5050 'component' => 'database' ,
51- 'latency_ms' => 500 ,
52- } ,
51+ 'latency_ms' => 500
52+ }
5353)
5454
5555# Emit an error log.
5656begin
57- raise StandardError , " Failed to write to disk"
58- rescue => e
57+ raise StandardError , ' Failed to write to disk'
58+ rescue StandardError => e
5959 logger . on_emit (
6060 timestamp : Time . now ,
6161 severity_text : 'ERROR' ,
6464 attributes : {
6565 'exception.type' => e . class . name ,
6666 'exception.message' => e . message ,
67- 'exception.stacktrace' => e . backtrace . join ( "\n " ) ,
68- } ,
67+ 'exception.stacktrace' => e . backtrace . join ( "\n " )
68+ }
6969 )
7070end
Original file line number Diff line number Diff line change 1616
1717 # Add environment information
1818 c . resource = OpenTelemetry ::SDK ::Resources ::Resource . create (
19- 'deployment.environment.name' => ENV . fetch ( 'RACK_ENV' , 'development' ) ,
19+ 'deployment.environment.name' => ENV . fetch ( 'RACK_ENV' , 'development' )
2020 )
2121end
2222
Original file line number Diff line number Diff line change @@ -4,8 +4,8 @@ source 'https://rubygems.org'
44
55gem 'logger' , '~> 1.7.0'
66
7- gem 'opentelemetry-sdk' , '~> 1.8.0'
87gem 'opentelemetry-exporter-otlp' , '~> 0.30.0'
8+ gem 'opentelemetry-sdk' , '~> 1.8.0'
99
10- gem 'opentelemetry-logs-sdk' , '~> 0.2.0'
1110gem 'opentelemetry-exporter-otlp-logs' , '~> 0.2.0'
11+ gem 'opentelemetry-logs-sdk' , '~> 0.2.0'
Original file line number Diff line number Diff line change 1010require 'opentelemetry/exporter/otlp_logs'
1111
1212# Ensure DSN is set
13- dsn = ENV [ 'UPTRACE_DSN' ]
13+ dsn = ENV . fetch ( 'UPTRACE_DSN' , nil )
1414abort ( 'Missing UPTRACE_DSN environment variable' ) unless dsn
1515
1616# Configure OpenTelemetry (for traces, metrics, and logs if desired)
2121 endpoint : 'https://api.uptrace.dev/v1/logs' ,
2222 headers : { 'uptrace-dsn' : dsn } , # Uptrace auth
2323 compression : 'gzip' , # Reduce bandwidth
24- timeout : 10 # Seconds
24+ timeout : 10 # Seconds
2525)
2626
2727# Attach batch processor (buffers + exports logs)
Original file line number Diff line number Diff line change @@ -4,9 +4,9 @@ source 'https://rubygems.org'
44
55gem 'logger' , '~> 1.7.0'
66
7- gem 'opentelemetry-sdk' , '~> 1.8.0'
87gem 'opentelemetry-exporter-otlp' , '~> 0.30.0'
8+ gem 'opentelemetry-sdk' , '~> 1.8.0'
99
10- gem 'opentelemetry-metrics-sdk' , '~> 0.7.3'
11- gem 'opentelemetry-metrics-api' , '~> 0.3.0'
1210gem 'opentelemetry-exporter-otlp-metrics' , '~> 0.5.0'
11+ gem 'opentelemetry-metrics-api' , '~> 0.3.0'
12+ gem 'opentelemetry-metrics-sdk' , '~> 0.7.3'
Original file line number Diff line number Diff line change 1111require 'opentelemetry-exporter-otlp-metrics'
1212
1313# Fetch Uptrace DSN from environment (required)
14- dsn = ENV [ 'UPTRACE_DSN' ]
14+ dsn = ENV . fetch ( 'UPTRACE_DSN' , nil )
1515abort ( 'Missing UPTRACE_DSN environment variable' ) unless dsn
1616
1717puts "Using Uptrace DSN: #{ dsn } "
Original file line number Diff line number Diff line change @@ -4,6 +4,6 @@ source 'https://rubygems.org'
44
55gem 'logger' , '~> 1.7.0'
66
7- gem 'opentelemetry-sdk' , '~> 1.8.0'
87gem 'opentelemetry-exporter-otlp' , '~> 0.30.0'
98gem 'opentelemetry-propagator-xray' , '~> 0.24.0'
9+ gem 'opentelemetry-sdk' , '~> 1.8.0'
Original file line number Diff line number Diff line change 1111require 'opentelemetry/instrumentation/all'
1212
1313# Fetch Uptrace DSN from environment (required)
14- dsn = ENV [ 'UPTRACE_DSN' ]
14+ dsn = ENV . fetch ( 'UPTRACE_DSN' , nil )
1515abort ( 'Missing UPTRACE_DSN environment variable' ) unless dsn
1616
1717puts "Using Uptrace DSN: #{ dsn } "
Original file line number Diff line number Diff line change 22
33source 'https://rubygems.org'
44
5- gem 'rails' , '~> 8.0.2'
6- gem 'puma' , '~> 6.4'
75gem 'opentelemetry-instrumentation-rails' , '~> 0.36.0'
6+ gem 'puma' , '~> 6.4'
7+ gem 'rails' , '~> 8.0.2'
88gem 'uptrace' , path : '../..'
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ Uptrace.configure_opentelemetry(dsn: '') do |c|
1919 c . service_version = '1.0.0'
2020end
2121
22+ # TraceRequestApp is a minimal Rails application
2223class TraceRequestApp < Rails ::Application
2324 config . root = __dir__
2425 config . secret_key_base = 'secret_key_base'
@@ -31,6 +32,7 @@ class TraceRequestApp < Rails::Application
3132 config . paths [ 'config/routes.rb' ] = [ ]
3233end
3334
35+ # ExampleController
3436class ExampleController < ActionController ::Base
3537 include Rails . application . routes . url_helpers
3638
You can’t perform that action at this time.
0 commit comments