chore: otlp adjustments
This commit is contained in:
parent
efd261be77
commit
4982db6609
2 changed files with 11 additions and 12 deletions
|
@ -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<RawPacket>
|
|||
{
|
||||
private readonly PacketDistributorService<OperationCode, AuthSession> _distributorService;
|
||||
|
||||
private readonly TracerProvider _tracerProvider;
|
||||
private readonly ActivitySource _activitySource;
|
||||
|
||||
public PacketConsumer(PacketDistributorService<OperationCode, AuthSession> distributorService, TracerProvider tracerProvider)
|
||||
public PacketConsumer(PacketDistributorService<OperationCode, AuthSession> distributorService)
|
||||
{
|
||||
_distributorService = distributorService;
|
||||
_tracerProvider = tracerProvider;
|
||||
_activitySource = new ActivitySource(nameof(PacketConsumer));
|
||||
}
|
||||
|
||||
public Task Consume(ConsumeContext<RawPacket> 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ if (configuration.GetValue<bool>("Tracing:Enabled"))
|
|||
.WithTracing(tracing =>
|
||||
{
|
||||
tracing.AddSource(nameof(Server));
|
||||
//tracing.AddSource("MassTransit");
|
||||
tracing.AddSource("MassTransit");
|
||||
tracing.AddEntityFrameworkCoreInstrumentation(options => options.SetDbStatementForText = true);
|
||||
tracing.AddNpgsql();
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue