forked from open-telemetry/opentelemetry-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
instrumentation.rb
38 lines (31 loc) · 932 Bytes
/
instrumentation.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
# frozen_string_literal: true
# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0
module OpenTelemetry
module Instrumentation
module Dalli
# The Instrumentation class contains logic to detect and install the Dalli
# instrumentation
class Instrumentation < OpenTelemetry::Instrumentation::Base
install do |_config|
require_dependencies
add_patches
end
present do
defined?(::Dalli)
end
option :peer_service, default: nil, validate: :string
option :db_statement, default: :include, validate: ->(opt) { %I[omit obfuscate include].include?(opt) }
private
def require_dependencies
require_relative 'utils'
require_relative 'patches/server'
end
def add_patches
::Dalli::Server.prepend(Patches::Server)
end
end
end
end
end