-
Notifications
You must be signed in to change notification settings - Fork 32
/
honeycomb-beeline.rb
60 lines (51 loc) · 1.19 KB
/
honeycomb-beeline.rb
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
51
52
53
54
55
56
57
58
59
60
# frozen_string_literal: true
require "forwardable"
require "libhoney"
require "honeycomb/beeline/version"
require "honeycomb/client"
require "honeycomb/trace"
# main module
module Honeycomb
INTEGRATIONS = %i[
active_support
aws
faraday
rack
rails
railtie
rake
redis
sequel
sinatra
].freeze
class << self
extend Forwardable
attr_reader :client
def_delegators :@client, :libhoney, :start_span, :add_field,
:add_field_to_trace, :current_span, :current_trace,
:with_field, :with_trace_field
def configure
Configuration.new.tap do |config|
yield config
@client = Honeycomb::Client.new(configuration: config)
end
@client
end
def load_integrations
integrations_to_load.each do |integration|
begin
require "honeycomb/integrations/#{integration}"
rescue LoadError
end
end
end
def integrations_to_load
if ENV["HONEYCOMB_INTEGRATIONS"]
ENV["HONEYCOMB_INTEGRATIONS"].split(",")
else
INTEGRATIONS
end
end
end
end
Honeycomb.load_integrations unless ENV["HONEYCOMB_DISABLE_AUTOCONFIGURE"]