Skip to content

Commit

Permalink
.59 method coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
andracc committed Oct 11, 2024
1 parent 3da4411 commit 5e70834
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
29 changes: 17 additions & 12 deletions Backend.Tests/Otel/OtelServiceTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// using System.Diagnostics;
using System;
using System.Diagnostics;
using BackendFramework.Otel;
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;
Expand All @@ -9,23 +10,12 @@ namespace Backend.Tests.Otel
public class OtelServiceTests
{

[Test]
public static void TestAddOtelTagCoverage()
{
var services = new ServiceCollection();
OtelService.AddOtelInstrumentation(services);
OtelService.AddOtelTag("test key", "test val");


}

// [Test]
// public static void TestAddOtelTagCoverage()
// {
// var services = new ServiceCollection();
// OtelService.AddOtelInstrumentation(services);
// Activity? act = OtelService.AddOtelTag("test key", "test val");
// Assert.That(act, Is.Not.Null);
// OtelService.AddOtelTag("test key", "test val");


// }
Expand All @@ -36,6 +26,9 @@ public static void TestAddOtelTag()
{
var services = new ServiceCollection();
OtelService.AddOtelInstrumentation(services);

// AddActivityListener();

var activity = OtelService.AddOtelTag("test key", "test val");
Console.WriteLine("result was " + activity);
Assert.That(activity, Is.Not.Null);
Expand All @@ -57,5 +50,17 @@ public static void TestAddOtelTag()

}

private static void AddActivityListener()
{
var activityListener = new ActivityListener
{
ShouldListenTo = s => true,
SampleUsingParentId = (ref ActivityCreationOptions<string> activityOptions) => ActivitySamplingResult.AllData,
Sample = (ref ActivityCreationOptions<ActivityContext> activityOptions) => ActivitySamplingResult.AllData
};
ActivitySource.AddActivityListener(activityListener);

}

}
}
5 changes: 0 additions & 5 deletions Backend/Otel/OtelService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,4 @@ public static void AddOtelInstrumentation(IServiceCollection services)
services.AddOpenTelemetryInstrumentation();
}

public static Activity? GetActivity()
{
return Activity.Current;

}
}

0 comments on commit 5e70834

Please sign in to comment.