File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ def labels
1313 format : format ,
1414 method : method ,
1515 }
16- labels . merge ( payload . slice ( *Yabeda . default_tags . keys - labels . keys ) )
16+ labels . merge ( payload . slice ( *( Yabeda . default_tags . keys + Yabeda . rails . default_tags . keys ) - labels . keys ) )
1717 end
1818 end
1919
Original file line number Diff line number Diff line change @@ -18,6 +18,12 @@ class TestApplication < Rails::Application
1818end
1919
2020class HelloController < ActionController ::API
21+ def append_info_to_payload ( payload )
22+ super
23+ payload [ :custom_tag_from_rails ] = "hello-world-from-rails"
24+ payload [ :custom_tag ] = "hello-world"
25+ end
26+
2127 def world
2228 render json : { hello : :world }
2329 end
Original file line number Diff line number Diff line change @@ -46,4 +46,30 @@ def app
4646 . by ( 1 )
4747 end
4848 end
49+
50+ context "with default_tags set" do
51+ before do
52+ Yabeda . default_tag :custom_tag , nil
53+ end
54+
55+ it "increments counters for every request" do
56+ expect { get "/hello/world" } . to \
57+ increment_yabeda_counter ( Yabeda . rails . requests_total )
58+ . with_tags ( custom_tag : "hello-world" )
59+ . by ( 1 )
60+ end
61+ end
62+
63+ context "with ':rails' default_tags set" do
64+ before do
65+ Yabeda . default_tag :custom_tag_from_rails , nil , group : :rails
66+ end
67+
68+ it "increments counters for every request" do
69+ expect { get "/hello/world" } . to \
70+ increment_yabeda_counter ( Yabeda . rails . requests_total )
71+ . with_tags ( custom_tag_from_rails : "hello-world-from-rails" )
72+ . by ( 1 )
73+ end
74+ end
4975end
You can’t perform that action at this time.
0 commit comments