Skip to content

Commit ba4076f

Browse files
committed
add a custom stats instrument to the acceptance stack
1 parent 8e1379a commit ba4076f

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

spec/acceptance/config/hooks.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
handler_plugin_dir: ./spec/acceptance/plugins/handlers
33
auth_plugin_dir: ./spec/acceptance/plugins/auth
44
lifecycle_plugin_dir: ./spec/acceptance/plugins/lifecycle
5+
instruments_plugin_dir: ./spec/acceptance/plugins/instruments
56

67
log_level: debug
78

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# frozen_string_literal: true
2+
3+
class Stats < Hooks::Plugins::Instruments::StatsBase
4+
def initialize
5+
# just a demo implementation
6+
end
7+
8+
def success
9+
log.debug("response success recorded")
10+
end
11+
end

spec/acceptance/plugins/lifecycle/request_method_logger.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@ class RequestMethodLogger < Hooks::Plugins::Lifecycle
55
def on_request(env)
66
log.debug("on_request called with method: #{env['REQUEST_METHOD']}")
77
end
8+
9+
def on_response(env, response)
10+
stats.success
11+
end
812
end

0 commit comments

Comments
 (0)