Persist ILogger scope for Distributed Tracing feature
See original GitHub issueHi,
When I create a ILogger Scope in my method with a DurableOrchestrationContext, activities called does not log the scope. I understand why but I am wondering if anything can be done about it, so that the scope is automagically included and is logged when I am in the activity.
using (logger.BeginScope("{SomeId}", someID)
{
var returnValue = await context.CallActivityAsync<MyObject>("MapCartToMyObject", rawDataForProcessing);
}
...
[FunctionName("MapCartToMyObject")]
public static async Task<string> MapCartToMyObjectAsync([ActivityTrigger] DurableActivityContext inputs, ILogger log)
{
var rawData = inputs.GetInput<string>();
log.LogInformation("In {FunctionName}, some logging text: {RawData}", "MapCartToMyObjectAsync", rawData);
}
...
If not, are there any reccomendations, like “pass the logger in as a parameter” etc?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:6 (2 by maintainers)
Top Results From Across the Web
ILogger.BeginScope(): persisting scope between calls to ...
My issue is that I need to call other methods in other classes, and I'm injecting the ILogger into all my classes. So...
Read more >Logging in .NET Core and ASP.NET Core
In this article. Automatically log scope with SpanId, TraceId, ParentId, Baggage, and Tags.
Read more >Distributed Logging and Tracing with Spring Boot 3 and ...
Distributed tracing enables developers and operations teams to track requests as they move across multiple services, providing insight into the ...
Read more >Tracing with Spring Boot, OpenTelemetry, and Jaeger
A guide on how to set up your Spring Boot applications to emit traces and analyze them with Jaeger.
Read more >Distributed Tracing for Functions
The distributed tracing feature observes the function's execution as it moves through the different components of the system.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Well the idea for us, is to have a mechanism for storing correlation id’s so that we easlily can follow a durable execution through all logging we do using one id. Letting replay run as usual is not a problem as the thought of scope is to only couple different log entries together. GetStatusAsync with history is great and we love it, but when looking at logs there is a need to follow the thread, and as far as I have found getting the status with history is not easy from Application Insights. (sorry if I am rambling a bit)
I’m interested in a feature like this. This would make it a lot easier to pass around state to keep with the logs. @cgillum it looks like the end-to-end correlation feature has landed, but this didn’t make it in with it.
I can see a section related to this in the limitations of the correlation-csharp documentation. It seems like a PR that was blocking support for this has been merged. Is this something that can be reconsidered for support?