Skip to content

Commit 3a38bc7

Browse files
author
Muriel Picone Farías
committed
Move requires for custom subscriber and handlers to subscriber
1 parent f1abe62 commit 3a38bc7

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

instrumentation/grape/lib/opentelemetry/instrumentation/grape/instrumentation.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ def gem_version
3535

3636
def require_dependencies
3737
require_relative 'subscriber'
38-
require_relative 'event_handler'
39-
require_relative 'custom_subscribers/endpoint_run'
4038
end
4139

4240
def subscribe

instrumentation/grape/lib/opentelemetry/instrumentation/grape/subscriber.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
#
55
# SPDX-License-Identifier: Apache-2.0
66

7+
require_relative 'custom_subscribers/endpoint_run'
8+
require_relative 'event_handler'
9+
710
module OpenTelemetry
811
module Instrumentation
912
module Grape
@@ -31,13 +34,12 @@ def subscribe
3134
#
3235
# Reference: https://github.com/rails/rails/blob/05cb63abdaf6101e6c8fb43119e2c0d08e543c28/activesupport/lib/active_support/notifications/fanout.rb#L320-L322
3336
CUSTOM_SUBSCRIPTIONS = {
34-
endpoint_run: 'OpenTelemetry::Instrumentation::Grape::CustomSubscribers::EndpointRun'
37+
endpoint_run: OpenTelemetry::Instrumentation::Grape::CustomSubscribers::EndpointRun
3538
}.freeze
3639

3740
def subscribe_to_custom_notifications
3841
CUSTOM_SUBSCRIPTIONS.each do |event, klass|
39-
custom_subscriber = Object.const_get(klass).new
40-
::ActiveSupport::Notifications.subscribe("#{event}.grape", custom_subscriber)
42+
::ActiveSupport::Notifications.subscribe("#{event}.grape", klass.new)
4143
end
4244
end
4345

0 commit comments

Comments
 (0)