Skip to content

Commit 8d4cc09

Browse files
author
MPCoreDeveloper
committed
integration open telemetry
1 parent 8ef20a5 commit 8d4cc09

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/SharpCoreDB.Tests/Graph/Metrics/OpenTelemetryIntegrationTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,22 @@ namespace SharpCoreDB.Tests.Graph.Metrics;
1515
/// </summary>
1616
public class OpenTelemetryIntegrationTests
1717
{
18+
/// <summary>
19+
/// Static constructor to register ActivityListener for test execution.
20+
/// Required for ActivitySource.StartActivity() to return non-null activities.
21+
/// </summary>
22+
static OpenTelemetryIntegrationTests()
23+
{
24+
// Register ActivityListener to enable activity creation during tests
25+
ActivitySource.AddActivityListener(new ActivityListener
26+
{
27+
ShouldListenTo = source => source.Name == OpenTelemetryIntegration.ActivitySourceName,
28+
Sample = (ref ActivityCreationOptions<ActivityContext> options) => ActivitySamplingResult.AllDataAndRecorded,
29+
ActivityStarted = activity => { },
30+
ActivityStopped = activity => { }
31+
});
32+
}
33+
1834
[Fact]
1935
public void OpenTelemetryIntegration_ActivitySourceCreated()
2036
{

0 commit comments

Comments
 (0)