refactor: moving telemetry wip

This commit is contained in:
Stevan Freeborn
2025-06-03 16:31:09 -05:00
parent 852f27c7b5
commit 8e0ec2d3d5
9 changed files with 69 additions and 17 deletions
@@ -7,12 +7,12 @@ public class HostExtensionsTests
{
var builder = WebApplication.CreateBuilder();
builder.AddTelemetry(static () => new StevesBotWebhookInstrumentation());
builder.AddTelemetry(static () => new TestInstrumentation());
var app = builder.Build();
app.Services
.GetService<StevesBotWebhookInstrumentation>()
.GetService<TestInstrumentation>()
.Should()
.BeNull();
@@ -42,7 +42,7 @@ public class HostExtensionsTests
builder.Configuration.AddJsonStream(new MemoryStream(Encoding.UTF8.GetBytes(json)));
builder.AddTelemetry(static () => new StevesBotWebhookInstrumentation());
builder.AddTelemetry(static () => new TestInstrumentation());
var app = builder.Build();
@@ -62,4 +62,16 @@ public class HostExtensionsTests
.Should()
.NotBeNull();
}
private class TestInstrumentation : IInstrumentation
{
public string SourceName { get; } = "TestSource";
public string SourceVersion { get; } = "1.0.0";
public ActivitySource Source { get; } = new ActivitySource("TestSource", "1.0.0");
public void Dispose()
{
Source.Dispose();
}
}
}
@@ -1,4 +1,4 @@
namespace StevesBot.Library.Tests.Unit;
namespace StevesBot.Webhook.Tests.Unit;
public sealed class StevesBotWebhookInstrumentationTests : IDisposable
{
@@ -1,4 +1,5 @@
global using System.Collections.Concurrent;
global using System.Diagnostics;
global using System.Net;
global using System.Text;
@@ -13,6 +14,7 @@ global using RichardSzalay.MockHttp;
global using StevesBot.Library.Discord.Rest;
global using StevesBot.Library.Discord.Rest.Requests;
global using StevesBot.Webhook.Telemetry;
global using StevesBot.Webhook.YouTube;
global using StevesBot.Webhook.YouTube.Data;
global using StevesBot.Webhook.YouTube.Handlers;
@@ -1,4 +1,4 @@
namespace StevesBot.Library.Tests.Unit;
namespace StevesBot.Worker.Tests.Unit;
public sealed class StevesBotWorkerInstrumentationTests : IDisposable
{
+2 -4
View File
@@ -1,4 +1,4 @@
global using System.Net;
global using System.Diagnostics;
global using System.Net.WebSockets;
global using System.Text;
global using System.Text.Json;
@@ -14,9 +14,6 @@ global using Microsoft.Extensions.Logging;
global using Moq;
global using RichardSzalay.MockHttp;
global using StevesBot.Library.Discord;
global using StevesBot.Library.Discord.Common;
global using StevesBot.Library.Discord.Rest;
global using StevesBot.Library.Discord.Rest.Requests;
@@ -24,6 +21,7 @@ global using StevesBot.Worker.Discord;
global using StevesBot.Worker.Discord.Gateway;
global using StevesBot.Worker.Discord.Gateway.Events;
global using StevesBot.Worker.Discord.Gateway.Events.Data;
global using StevesBot.Worker.Telemetry;
global using StevesBot.Worker.Tests.Integration.Infrastructure;
global using StevesBot.Worker.Threading;
global using StevesBot.Worker.WebSockets;