@@ -1212,9 +1212,8 @@ void ConfigureTestServices(IServiceCollection services)
1212
1212
Assert . Empty ( hubActivity ) ;
1213
1213
}
1214
1214
1215
- // note: this is always passing on Net9 or lower, because AddAspNetCoreInstrumentation only adds the subscription in Net10 or higher.
1216
1215
[ Fact ]
1217
- public async Task RazorComponentsActivitesCanBeDisabled ( )
1216
+ public async Task RazorComponentsActivitiesCanBeDisabled ( )
1218
1217
{
1219
1218
var exportedItems = new List < Activity > ( ) ;
1220
1219
void ConfigureTestServices ( IServiceCollection services )
@@ -1239,7 +1238,7 @@ void ConfigureTestServices(IServiceCollection services)
1239
1238
{
1240
1239
activity . Start ( ) ;
1241
1240
activity . SetTag ( "aspnetcore.components.type" , "BasicTests" ) ;
1242
- activity . SetTag ( "aspnetcore.components.method" , "BlazorActivitesCanBeDisabled " ) ;
1241
+ activity . SetTag ( "aspnetcore.components.method" , "BlazorActivitiesCanBeDisabled " ) ;
1243
1242
activity . Stop ( ) ;
1244
1243
}
1245
1244
@@ -1260,6 +1259,57 @@ void ConfigureTestServices(IServiceCollection services)
1260
1259
1261
1260
Assert . Empty ( blazorActivity ) ;
1262
1261
}
1262
+
1263
+ #if NET10_0_OR_GREATER
1264
+ [ Fact ]
1265
+ public async Task RazorComponentsActivitiesAreEnabledByDefault ( )
1266
+ {
1267
+ var exportedItems = new List < Activity > ( ) ;
1268
+ void ConfigureTestServices ( IServiceCollection services )
1269
+ {
1270
+ this . tracerProvider = Sdk . CreateTracerProviderBuilder ( )
1271
+ . AddAspNetCoreInstrumentation ( )
1272
+ . AddInMemoryExporter ( exportedItems )
1273
+ . Build ( ) ;
1274
+ }
1275
+
1276
+ using ( var client = this . factory
1277
+ . WithWebHostBuilder ( builder =>
1278
+ {
1279
+ builder . ConfigureTestServices ( ConfigureTestServices ) ;
1280
+ builder . ConfigureLogging ( loggingBuilder => loggingBuilder . ClearProviders ( ) ) ;
1281
+ } )
1282
+ . CreateClient ( ) )
1283
+ {
1284
+ var fakeActivitySource = new ActivitySource ( "Microsoft.AspNetCore.Components" ) ;
1285
+ var activity = fakeActivitySource . CreateActivity ( "Microsoft.AspNetCore.Components.HandleEvent" , ActivityKind . Internal , parentId : null , null , null ) ;
1286
+ if ( activity != null )
1287
+ {
1288
+ activity . Start ( ) ;
1289
+ activity . SetTag ( "aspnetcore.components.type" , "BasicTests" ) ;
1290
+ activity . SetTag ( "aspnetcore.components.method" , "BlazorActivitiesCanBeDisabled" ) ;
1291
+ activity . Stop ( ) ;
1292
+ }
1293
+
1294
+ try
1295
+ {
1296
+ using var response = await client . GetAsync ( new Uri ( "/api/values" , UriKind . Relative ) ) ;
1297
+ }
1298
+ catch ( Exception )
1299
+ {
1300
+ // ignore errors
1301
+ }
1302
+
1303
+ WaitForActivityExport ( exportedItems , 1 ) ;
1304
+ }
1305
+
1306
+ var blazorActivity = exportedItems
1307
+ . Where ( a => a . DisplayName . StartsWith ( "Microsoft.AspNetCore.Components" , StringComparison . InvariantCulture ) ) ;
1308
+
1309
+ Assert . NotEmpty ( blazorActivity ) ;
1310
+ }
1311
+ #endif
1312
+
1263
1313
#endif
1264
1314
1265
1315
public void Dispose ( )
0 commit comments