Currently using Redis instrumentation
otel.WithTracing(tracing => tracing.AddRedisInstrumentation("name", connection, null))
in Program.cs
to get traces and it works, but for each activity recorded four trace/log messages are written. The same goes for SEQ and Application Insights (using AzureMonitor distro)
- <command> (HMGET)
- ResponseReceived
- Sent
- Enqueued
Is there any way to remove those? I’m using Serilog and writing to OpenTelemetryLogger by setting writeToProviders: true
when configurating Serilog.
Code
app.Logging.ClearProviders();
app.Logging
.SetMinimumLevel(LogLevel.Information)
.AddOpenTelemetry(logger =>
{
logger.SetResourceBuilder(resource);
logger.IncludeScopes = true;
logger.IncludeFormattedMessage = true;
logger.ParseStateValues = true;
if (exportOtlp)
{
logger.AddOtlpExporter();
}
});
app.Host.UseSerilog((context, services, configuration) =>
{
configuration
.ReadFrom.Configuration(context.Configuration)
.ReadFrom.Services(services)
.Enrich.FromLogContext()
.WriteTo.Console();
var seq = context.Configuration.GetSection("Log");
var seqUrl = seq["SeqUrl"];
if (string.IsNullOrEmpty(seqUrl))
{
Log.Logger.Warning("Missing Seq url in Log:SeqUrl, skipping writing to Seq.");
}
else
{
configuration.WriteTo.Seq(seqUrl, apiKey: seq["SeqKey"]);
}
},
// Preserve logger when running tests since they are run in parallel and creates multiple
// test hosts which will cause error setting the static logger twice.
// Logger instance already frozen is the exception message.
app.Configuration.GetValue<bool>("PreserveStaticLogger"),
// Disable during tests since environment is Development and we don't want to write to Azure
// when running tests if we have enabled it
!app.Configuration.GetValue<bool>("SkipWriteToProviders"));
Thanks