File tree Expand file tree Collapse file tree 5 files changed +24
-4
lines changed
test/OpenTelemetry.Instrumentation.AspNetCore.Tests/RouteTests Expand file tree Collapse file tree 5 files changed +24
-4
lines changed Original file line number Diff line number Diff line change 455
455
"IdealHttpRoute" : " /Index" ,
456
456
"ActivityDisplayName" : " GET" ,
457
457
"ActivityHttpRoute" : " " ,
458
- "MetricHttpRoute" : " " ,
458
+ "MetricHttpRoute" : " / " ,
459
459
"RouteInfo" : {
460
460
"HttpMethod" : " GET" ,
461
461
"Path" : " /" ,
Original file line number Diff line number Diff line change @@ -27,10 +27,12 @@ public static IEnumerable<object[]> GetTestCases()
27
27
private static List < object [ ] > GetArgumentsFromTestCaseObject ( IEnumerable < TestCase > input )
28
28
{
29
29
var result = new List < object [ ] > ( ) ;
30
+ var dotnetVersion = Environment . Version . Major ;
30
31
31
32
foreach ( var testCase in input )
32
33
{
33
- if ( testCase . MinimumDotnetVersion . HasValue && Environment . Version . Major < testCase . MinimumDotnetVersion . Value )
34
+ if ( ( testCase . MinimumDotnetVersion . HasValue && dotnetVersion < testCase . MinimumDotnetVersion . Value ) ||
35
+ ( testCase . MaximumDotnetVersion . HasValue && dotnetVersion > testCase . MaximumDotnetVersion . Value ) )
34
36
{
35
37
continue ;
36
38
}
Original file line number Diff line number Diff line change 128
128
{
129
129
"name" : " Root path" ,
130
130
"testApplicationScenario" : " RazorPages" ,
131
+ "maximumDotnetVersion" : 9 ,
131
132
"httpMethod" : " GET" ,
132
133
"path" : " /" ,
133
134
"expectedStatusCode" : 200 ,
134
135
"currentHttpRoute" : " " ,
135
136
"expectedHttpRoute" : " /Index"
136
137
},
138
+ {
139
+ "name" : " Root path" ,
140
+ "testApplicationScenario" : " RazorPages" ,
141
+ "minimumDotnetVersion" : 10 ,
142
+ "httpMethod" : " GET" ,
143
+ "path" : " /" ,
144
+ "expectedStatusCode" : 200 ,
145
+ "currentHttpRoute" : " " ,
146
+ "expectedHttpRoute" : " /Index" ,
147
+ "expectedMetricRoute" : " /"
148
+ },
137
149
{
138
150
"name" : " Index page" ,
139
151
"testApplicationScenario" : " RazorPages" ,
Original file line number Diff line number Diff line change @@ -74,11 +74,13 @@ public async Task TestHttpRoute(TestCase testCase)
74
74
Assert . Equal ( testCase . HttpMethod , activityHttpMethod ) ;
75
75
Assert . Equal ( testCase . HttpMethod , metricHttpMethod ) ;
76
76
77
- // TODO: The CurrentHttpRoute property will go away. It They only serve to capture status quo.
77
+ // TODO: The CurrentHttpRoute property will go away. They only serve to capture status quo.
78
78
// If CurrentHttpRoute is null, then that means we already conform to the correct behavior.
79
79
var expectedHttpRoute = testCase . CurrentHttpRoute ?? testCase . ExpectedHttpRoute ;
80
80
Assert . Equal ( expectedHttpRoute , activityHttpRoute ) ;
81
- Assert . Equal ( expectedHttpRoute , metricHttpRoute ) ;
81
+
82
+ var expectedMetricRoute = testCase . ExpectedMetricRoute ?? expectedHttpRoute ;
83
+ Assert . Equal ( expectedMetricRoute , metricHttpRoute ) ;
82
84
83
85
// Activity.DisplayName should be a combination of http.method + http.route attributes, see:
84
86
// https://github.com/open-telemetry/semantic-conventions/blob/main/docs/http/http-spans.md#name
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ public class TestCase
11
11
12
12
public int ? MinimumDotnetVersion { get ; set ; }
13
13
14
+ public int ? MaximumDotnetVersion { get ; set ; }
15
+
14
16
public TestApplicationScenario TestApplicationScenario { get ; set ; }
15
17
16
18
public string ? HttpMethod { get ; set ; }
@@ -23,6 +25,8 @@ public class TestCase
23
25
24
26
public string ? CurrentHttpRoute { get ; set ; }
25
27
28
+ public string ? ExpectedMetricRoute { get ; set ; }
29
+
26
30
public override string ToString ( )
27
31
{
28
32
// This is used by Visual Studio's test runner to identify the test case.
You can’t perform that action at this time.
0 commit comments