[feature request] Allow ActivityContext
to be passed into ILogger
explicitly, rather than relying solely on Activity.Current
#6085
Labels
enhancement
New feature or request
needs-triage
New issues which have not been classified or triaged by a community member
pkg:OpenTelemetry
Issues related to OpenTelemetry NuGet package
Package
OpenTelemetry
Is your feature request related to a problem?
My scenario might be an edge-case but it also might not be - in the Akka.NET project we have our own logging infrastructure dating back to the begging of the project (2013) designed to allow logs to be formatted and processed asynchronously using some of our actors. We capture the context from the live running actor and defer the expensive formatting until later - similar in spirit and execution to OpenTelemetry's own processing pipeline.
We capture a
LogEvent
, emit it via an in-memory topic broker to aLogActor
who either renders it live (in batches) on the console or exports it to something like Serilog, NLog, or Microsoft.Extensions.Logging.An issue I have: akkadotnet/akka.net#7476 - we are trying to add support for capturing an
ActivityContext
when some of our built-in actors are doing message processing. The issue we have is this:opentelemetry-dotnet/src/OpenTelemetry/Logs/ILogger/OpenTelemetryLogger.cs
Line 56 in d9864b1
There's not any means to pass the
ActivityContext
as a state object to the OTELILogger
implementation. The only real way to preserve our theActivityContext
is to forward the entireActivity
to ourLogActor
, have it set that as theActivity.Current
, and then clear it as soon as theILogger
is done.What is the expected behavior?
I would love a means of being able to just pass in the
ActivityContext
explicitly from elsewhere to theLog
method and use that as the provided context for theILogger
, so I can keep the processing of log events and the recording of traces temporally decoupled from each other.Which alternative solutions or features have you considered?
As I mentioned in the first part of the post - we could just keep the entire
Activity
and temporarily restore it asActivity.Current
in order to satisfy the currentILogger
implementation. Not totally keen on doing this because it's kind of ugly.Additional context
No response
The text was updated successfully, but these errors were encountered: