diff --git a/Continuity.AuthServer/Consumers/PacketConsumer.cs b/Continuity.AuthServer/Consumers/PacketConsumer.cs index a94bdd1..c1f1b03 100644 --- a/Continuity.AuthServer/Consumers/PacketConsumer.cs +++ b/Continuity.AuthServer/Consumers/PacketConsumer.cs @@ -1,9 +1,9 @@ // Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. +using System.Diagnostics; using Continuity.AuthServer.Packets; using JetBrains.Annotations; using MassTransit; -using OpenTelemetry.Trace; using Rai.PacketMediator; using Wonderking.Packets; @@ -14,23 +14,22 @@ public class PacketConsumer : IConsumer { private readonly PacketDistributorService _distributorService; - private readonly TracerProvider _tracerProvider; + private readonly ActivitySource _activitySource; - public PacketConsumer(PacketDistributorService distributorService, TracerProvider tracerProvider) + public PacketConsumer(PacketDistributorService distributorService) { _distributorService = distributorService; - _tracerProvider = tracerProvider; + _activitySource = new ActivitySource(nameof(PacketConsumer)); } public Task Consume(ConsumeContext context) { - var tracer = _tracerProvider.GetTracer("Rai.PacketMediator"); + using var activity = _activitySource?.StartActivity("PacketConsumption"); + activity?.SetTag("PacketId", context.Message.OperationCode.ToString()); + activity?.SetTag("SessionId", context.Message.Session.Id.ToString()); + activity?.SetTag("PacketSize", context.Message.MessageBody.Length); - using var scope = tracer.StartActiveSpan("PacketHandler"); - scope.SetAttribute("PacketId", context.Message.OperationCode.ToString()); - scope.SetAttribute("SessionId", context.Message.Session.Id.ToString()); - scope.SetAttribute("PacketSize", context.Message.MessageBody.Length); - - return _distributorService.AddPacketAsync(context.Message.MessageBody, context.Message.OperationCode, context.Message.Session); + return _distributorService.AddPacketAsync(context.Message.MessageBody, context.Message.OperationCode, + context.Message.Session); } } diff --git a/Continuity.AuthServer/Program.cs b/Continuity.AuthServer/Program.cs index 7d8e734..a53a11f 100644 --- a/Continuity.AuthServer/Program.cs +++ b/Continuity.AuthServer/Program.cs @@ -53,7 +53,7 @@ if (configuration.GetValue("Tracing:Enabled")) .WithTracing(tracing => { tracing.AddSource(nameof(Server)); - //tracing.AddSource("MassTransit"); + tracing.AddSource("MassTransit"); tracing.AddEntityFrameworkCoreInstrumentation(options => options.SetDbStatementForText = true); tracing.AddNpgsql(); })