-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfig.ru
50 lines (40 loc) · 1.27 KB
/
config.ru
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# frozen_string_literal: true
require "bundler/setup"
Bundler.require
require 'opentelemetry/sdk'
require 'opentelemetry/exporter/otlp'
require 'opentelemetry/instrumentation/all'
require_relative './o11y_wrapper.rb'
begin
OpenTelemetry::SDK.configure do |c|
c.service_name = ENV['SERVICE_NAME'] || "year-ruby"
# enable all auto-instrumentation available
c.use_all()
# add the Baggage and CarryOn processors to thepipeline
c.add_span_processor(O11yWrapper::BaggageSpanProcessor.new)
c.add_span_processor(O11yWrapper::CarryOnSpanProcessor.new)
# Because we tinkered with the pipeline, we'll need to
# wire up span batching and sending via OTLP ourselves.
# This is usually the default.
c.add_span_processor(
OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(
OpenTelemetry::Exporter::OTLP::Exporter.new()
)
)
end
rescue OpenTelemetry::SDK::ConfigurationError => e
puts "What now?"
puts e.inspect
end
Tracer = OpenTelemetry.tracer_provider.tracer("year-internal")
class App < Grape::API
format :txt
get :year do
Tracer.in_span("🗓 get-a-year ✨") do
sleep rand(0..0.005)
(2015..2020).to_a.sample
end
end
end
use OpenTelemetry::Instrumentation::Rack::Middlewares::TracerMiddleware
run App