3
3
require 'opentelemetry-metrics-api'
4
4
require 'opentelemetry-metrics-sdk'
5
5
require 'opentelemetry-exporter-otlp'
6
+
6
7
# We need to load the function code's dependencies, and _before_ any dependencies might
7
8
# be initialized outside of the function handler, bootstrap instrumentation. This allows
8
9
# instrumentation targets to be present, and accommodates instrumentations like AWS SDK
9
- # that add plugins on client initialization (vs. prepending methods).
10
- def preload_libraries
10
+ # that add plugins on client initialization (vs. prepending methods).
11
+ def preload_function_dependencies
11
12
default_task_location = '/var/task'
12
13
13
14
handler_file = ENV . values_at ( 'ORIG_HANDLER' , '_HANDLER' ) . compact . first &.split ( '.' ) &.first
@@ -28,27 +29,12 @@ def preload_libraries
28
29
end
29
30
end
30
31
31
- preload_libraries
32
-
33
- require 'opentelemetry/instrumentation/aws_sdk/handler'
34
- require 'opentelemetry/instrumentation/aws_sdk/services'
35
-
36
- def loaded_constants
37
- services = Aws . constants & OpenTelemetry ::Instrumentation ::AwsSdk ::SERVICES . map ( &:to_sym )
32
+ preload_function_dependencies
38
33
39
- services . each_with_object ( [ ] ) do |service , constants |
40
- next if Aws . autoload? ( service )
41
-
42
- begin
43
- constants << Aws . const_get ( service , false ) . const_get ( :Client , false )
44
- rescue StandardError => e
45
- OpenTelemetry . logger . warn { "Constant could not be loaded: #{ e . message } " }
46
- end
47
- end
48
- end
34
+ require 'opentelemetry-registry'
35
+ require 'opentelemetry-instrumentation-all'
49
36
50
- Seahorse ::Client ::Base . add_plugin ( OpenTelemetry ::Instrumentation ::AwsSdk ::Plugin ) if defined? ( Seahorse ::Client ::Base )
51
- loaded_constants . each { |klass | klass . add_plugin ( OpenTelemetry ::Instrumentation ::AwsSdk ::Plugin ) }
37
+ OpenTelemetry ::Instrumentation . registry . install_all
52
38
53
39
require 'solarwinds_apm'
54
40
0 commit comments