2
2
// SPDX-License-Identifier: Apache-2.0
3
3
4
4
using System . Diagnostics . Metrics ;
5
- using Microsoft . Extensions . Configuration ;
6
- using Microsoft . Extensions . DependencyInjection ;
7
5
using OpenTelemetry . Tests ;
8
6
9
7
using Xunit ;
10
8
11
9
namespace OpenTelemetry . Metrics . Tests ;
12
10
13
- #pragma warning disable SA1402
14
-
15
- public abstract class MetricSnapshotTestsBase
11
+ public class MetricSnapshotTests
16
12
{
17
- private readonly IConfiguration configuration ;
18
-
19
- protected MetricSnapshotTestsBase ( )
20
- {
21
- this . configuration = MetricApiTestsBase . BuildConfiguration ( ) ;
22
- }
23
-
24
13
[ Fact ]
25
14
public void VerifySnapshot_Counter ( )
26
15
{
@@ -30,10 +19,6 @@ public void VerifySnapshot_Counter()
30
19
using var meter = new Meter ( Utils . GetCurrentMethodName ( ) ) ;
31
20
var counter = meter . CreateCounter < long > ( "meter" ) ;
32
21
using var meterProvider = Sdk . CreateMeterProviderBuilder ( )
33
- . ConfigureServices ( services =>
34
- {
35
- services . AddSingleton ( this . configuration ) ;
36
- } )
37
22
. AddMeter ( meter . Name )
38
23
. AddInMemoryExporter ( exportedMetrics )
39
24
. AddInMemoryExporter ( exportedSnapshots )
@@ -103,10 +88,6 @@ public void VerifySnapshot_Histogram()
103
88
using var meter = new Meter ( Utils . GetCurrentMethodName ( ) ) ;
104
89
var histogram = meter . CreateHistogram < int > ( "histogram" ) ;
105
90
using var meterProvider = Sdk . CreateMeterProviderBuilder ( )
106
- . ConfigureServices ( services =>
107
- {
108
- services . AddSingleton ( this . configuration ) ;
109
- } )
110
91
. AddMeter ( meter . Name )
111
92
. AddInMemoryExporter ( exportedMetrics )
112
93
. AddInMemoryExporter ( exportedSnapshots )
@@ -199,10 +180,6 @@ public void VerifySnapshot_ExponentialHistogram()
199
180
using var meter = new Meter ( Utils . GetCurrentMethodName ( ) ) ;
200
181
var histogram = meter . CreateHistogram < int > ( "histogram" ) ;
201
182
using var meterProvider = Sdk . CreateMeterProviderBuilder ( )
202
- . ConfigureServices ( services =>
203
- {
204
- services . AddSingleton ( this . configuration ) ;
205
- } )
206
183
. AddMeter ( meter . Name )
207
184
. AddView ( "histogram" , new Base2ExponentialBucketHistogramConfiguration ( ) )
208
185
. AddInMemoryExporter ( exportedMetrics )
@@ -225,7 +202,7 @@ public void VerifySnapshot_ExponentialHistogram()
225
202
metricPoint1 . TryGetHistogramMinMaxValues ( out var min , out var max ) ;
226
203
Assert . Equal ( 10 , min ) ;
227
204
Assert . Equal ( 10 , max ) ;
228
- AggregatorTestsBase . AssertExponentialBucketsAreCorrect ( expectedHistogram , metricPoint1 . GetExponentialHistogramData ( ) ) ;
205
+ AggregatorTests . AssertExponentialBucketsAreCorrect ( expectedHistogram , metricPoint1 . GetExponentialHistogramData ( ) ) ;
229
206
230
207
// Verify Snapshot 1
231
208
Assert . Single ( exportedSnapshots ) ;
@@ -236,7 +213,7 @@ public void VerifySnapshot_ExponentialHistogram()
236
213
snapshot1 . MetricPoints [ 0 ] . TryGetHistogramMinMaxValues ( out min , out max ) ;
237
214
Assert . Equal ( 10 , min ) ;
238
215
Assert . Equal ( 10 , max ) ;
239
- AggregatorTestsBase . AssertExponentialBucketsAreCorrect ( expectedHistogram , snapshot1 . MetricPoints [ 0 ] . GetExponentialHistogramData ( ) ) ;
216
+ AggregatorTests . AssertExponentialBucketsAreCorrect ( expectedHistogram , snapshot1 . MetricPoints [ 0 ] . GetExponentialHistogramData ( ) ) ;
240
217
241
218
// Verify Metric == Snapshot
242
219
Assert . Equal ( metric1 . Name , snapshot1 . Name ) ;
@@ -270,7 +247,7 @@ public void VerifySnapshot_ExponentialHistogram()
270
247
metricPoint1 . TryGetHistogramMinMaxValues ( out min , out max ) ;
271
248
Assert . Equal ( 5 , min ) ;
272
249
Assert . Equal ( 10 , max ) ;
273
- AggregatorTestsBase . AssertExponentialBucketsAreCorrect ( expectedHistogram , metricPoint2 . GetExponentialHistogramData ( ) ) ;
250
+ AggregatorTests . AssertExponentialBucketsAreCorrect ( expectedHistogram , metricPoint2 . GetExponentialHistogramData ( ) ) ;
274
251
275
252
// Verify Snapshot 1 after second export
276
253
// This value is expected to be unchanged.
@@ -289,14 +266,6 @@ public void VerifySnapshot_ExponentialHistogram()
289
266
snapshot2 . MetricPoints [ 0 ] . TryGetHistogramMinMaxValues ( out min , out max ) ;
290
267
Assert . Equal ( 5 , min ) ;
291
268
Assert . Equal ( 10 , max ) ;
292
- AggregatorTestsBase . AssertExponentialBucketsAreCorrect ( expectedHistogram , snapshot2 . MetricPoints [ 0 ] . GetExponentialHistogramData ( ) ) ;
293
- }
294
- }
295
-
296
- public class MetricSnapshotTests : MetricSnapshotTestsBase
297
- {
298
- public MetricSnapshotTests ( )
299
- : base ( )
300
- {
269
+ AggregatorTests . AssertExponentialBucketsAreCorrect ( expectedHistogram , snapshot2 . MetricPoints [ 0 ] . GetExponentialHistogramData ( ) ) ;
301
270
}
302
271
}
0 commit comments