77
88import static io .opentelemetry .api .common .AttributeKey .stringKey ;
99import static io .opentelemetry .instrumentation .micrometer .v1_5 .AbstractCounterTest .INSTRUMENTATION_NAME ;
10- import static io .opentelemetry .sdk .testing .assertj .OpenTelemetryAssertions .assertThat ;
1110import static io .opentelemetry .sdk .testing .assertj .OpenTelemetryAssertions .equalTo ;
1211
1312import io .micrometer .core .instrument .DistributionSummary ;
@@ -47,74 +46,68 @@ void testMicrometerHistogram() {
4746 testing ()
4847 .waitAndAssertMetrics (
4948 INSTRUMENTATION_NAME ,
50- "testSummary" ,
51- metrics ->
52- metrics .anySatisfy (
53- metric ->
54- assertThat (metric )
55- .hasDescription ("This is a test distribution summary" )
56- .hasUnit ("things" )
57- .hasHistogramSatisfying (
58- histogram ->
59- histogram .hasPointsSatisfying (
60- points ->
61- points
62- .hasSum (555.5 )
63- .hasCount (4 )
64- .hasAttributesSatisfyingExactly (
65- equalTo (stringKey ("tag" ), "value" ))))));
49+ metric ->
50+ metric
51+ .hasName ("testSummary" )
52+ .hasDescription ("This is a test distribution summary" )
53+ .hasUnit ("things" )
54+ .hasHistogramSatisfying (
55+ histogram ->
56+ histogram .hasPointsSatisfying (
57+ points ->
58+ points
59+ .hasSum (555.5 )
60+ .hasCount (4 )
61+ .hasAttributesSatisfyingExactly (
62+ equalTo (stringKey ("tag" ), "value" )))));
6663 testing ()
6764 .waitAndAssertMetrics (
6865 INSTRUMENTATION_NAME ,
69- "testSummary.max" ,
70- metrics ->
71- metrics .anySatisfy (
72- metric ->
73- assertThat (metric )
74- .hasDescription ("This is a test distribution summary" )
75- .hasDoubleGaugeSatisfying (
76- gauge ->
77- gauge .hasPointsSatisfying (
78- point ->
79- point
80- .hasValue (500 )
81- .hasAttributesSatisfyingExactly (
82- equalTo (stringKey ("tag" ), "value" ))))));
66+ metric ->
67+ metric
68+ .hasName ("testSummary.max" )
69+ .hasDescription ("This is a test distribution summary" )
70+ .hasDoubleGaugeSatisfying (
71+ gauge ->
72+ gauge .hasPointsSatisfying (
73+ point ->
74+ point
75+ .hasValue (500 )
76+ .hasAttributesSatisfyingExactly (
77+ equalTo (stringKey ("tag" ), "value" )))));
8378 testing ()
8479 .waitAndAssertMetrics (
8580 INSTRUMENTATION_NAME ,
86- "testSummary.histogram" ,
87- metrics ->
88- metrics .anySatisfy (
89- metric ->
90- assertThat (metric )
91- .hasDoubleGaugeSatisfying (
92- gauge ->
93- gauge .hasPointsSatisfying (
94- point ->
95- point
96- .hasValue (1 )
97- .hasAttributesSatisfyingExactly (
98- equalTo (stringKey ("le" ), "1" ),
99- equalTo (stringKey ("tag" ), "value" )),
100- point ->
101- point
102- .hasValue (2 )
103- .hasAttributesSatisfyingExactly (
104- equalTo (stringKey ("le" ), "10" ),
105- equalTo (stringKey ("tag" ), "value" )),
106- point ->
107- point
108- .hasValue (3 )
109- .hasAttributesSatisfyingExactly (
110- equalTo (stringKey ("le" ), "100" ),
111- equalTo (stringKey ("tag" ), "value" )),
112- point ->
113- point
114- .hasValue (4 )
115- .hasAttributesSatisfyingExactly (
116- equalTo (stringKey ("le" ), "1000" ),
117- equalTo (stringKey ("tag" ), "value" ))))));
81+ metric ->
82+ metric
83+ .hasName ("testSummary.histogram" )
84+ .hasDoubleGaugeSatisfying (
85+ gauge ->
86+ gauge .hasPointsSatisfying (
87+ point ->
88+ point
89+ .hasValue (1 )
90+ .hasAttributesSatisfyingExactly (
91+ equalTo (stringKey ("le" ), "1" ),
92+ equalTo (stringKey ("tag" ), "value" )),
93+ point ->
94+ point
95+ .hasValue (2 )
96+ .hasAttributesSatisfyingExactly (
97+ equalTo (stringKey ("le" ), "10" ),
98+ equalTo (stringKey ("tag" ), "value" )),
99+ point ->
100+ point
101+ .hasValue (3 )
102+ .hasAttributesSatisfyingExactly (
103+ equalTo (stringKey ("le" ), "100" ),
104+ equalTo (stringKey ("tag" ), "value" )),
105+ point ->
106+ point
107+ .hasValue (4 )
108+ .hasAttributesSatisfyingExactly (
109+ equalTo (stringKey ("le" ), "1000" ),
110+ equalTo (stringKey ("tag" ), "value" )))));
118111 }
119112
120113 @ Test
@@ -136,61 +129,55 @@ void testMicrometerPercentiles() {
136129 testing ()
137130 .waitAndAssertMetrics (
138131 INSTRUMENTATION_NAME ,
139- "testSummary" ,
140- metrics ->
141- metrics .anySatisfy (
142- metric ->
143- assertThat (metric )
144- .hasDescription ("This is a test distribution summary" )
145- .hasUnit ("things" )
146- .hasHistogramSatisfying (
147- histogram ->
148- histogram .hasPointsSatisfying (
149- point ->
150- point
151- .hasSum (150 )
152- .hasCount (2 )
153- .hasAttributesSatisfyingExactly (
154- equalTo (stringKey ("tag" ), "value" ))))));
132+ metric ->
133+ metric
134+ .hasName ("testSummary" )
135+ .hasDescription ("This is a test distribution summary" )
136+ .hasUnit ("things" )
137+ .hasHistogramSatisfying (
138+ histogram ->
139+ histogram .hasPointsSatisfying (
140+ point ->
141+ point
142+ .hasSum (150 )
143+ .hasCount (2 )
144+ .hasAttributesSatisfyingExactly (
145+ equalTo (stringKey ("tag" ), "value" )))));
155146 testing ()
156147 .waitAndAssertMetrics (
157148 INSTRUMENTATION_NAME ,
158- "testSummary.max" ,
159- metrics ->
160- metrics .anySatisfy (
161- metric ->
162- assertThat (metric )
163- .hasDescription ("This is a test distribution summary" )
164- .hasDoubleGaugeSatisfying (
165- gauge ->
166- gauge .hasPointsSatisfying (
167- point ->
168- point
169- .hasValue (100 )
170- .hasAttributesSatisfyingExactly (
171- equalTo (stringKey ("tag" ), "value" ))))));
149+ metric ->
150+ metric
151+ .hasName ("testSummary.max" )
152+ .hasDescription ("This is a test distribution summary" )
153+ .hasDoubleGaugeSatisfying (
154+ gauge ->
155+ gauge .hasPointsSatisfying (
156+ point ->
157+ point
158+ .hasValue (100 )
159+ .hasAttributesSatisfyingExactly (
160+ equalTo (stringKey ("tag" ), "value" )))));
172161 testing ()
173162 .waitAndAssertMetrics (
174163 INSTRUMENTATION_NAME ,
175- "testSummary.percentile" ,
176- metrics ->
177- metrics .anySatisfy (
178- metric ->
179- assertThat (metric )
180- .hasDoubleGaugeSatisfying (
181- gauge ->
182- gauge .hasPointsSatisfying (
183- point ->
184- point .hasAttributesSatisfyingExactly (
185- equalTo (stringKey ("phi" ), "0.5" ),
186- equalTo (stringKey ("tag" ), "value" )),
187- point ->
188- point .hasAttributesSatisfyingExactly (
189- equalTo (stringKey ("phi" ), "0.95" ),
190- equalTo (stringKey ("tag" ), "value" )),
191- point ->
192- point .hasAttributesSatisfyingExactly (
193- equalTo (stringKey ("phi" ), "0.99" ),
194- equalTo (stringKey ("tag" ), "value" ))))));
164+ metric ->
165+ metric
166+ .hasName ("testSummary.percentile" )
167+ .hasDoubleGaugeSatisfying (
168+ gauge ->
169+ gauge .hasPointsSatisfying (
170+ point ->
171+ point .hasAttributesSatisfyingExactly (
172+ equalTo (stringKey ("phi" ), "0.5" ),
173+ equalTo (stringKey ("tag" ), "value" )),
174+ point ->
175+ point .hasAttributesSatisfyingExactly (
176+ equalTo (stringKey ("phi" ), "0.95" ),
177+ equalTo (stringKey ("tag" ), "value" )),
178+ point ->
179+ point .hasAttributesSatisfyingExactly (
180+ equalTo (stringKey ("phi" ), "0.99" ),
181+ equalTo (stringKey ("tag" ), "value" )))));
195182 }
196183}
0 commit comments