Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure logging for writing to AI from .NET Stateless service #100

Open
davidelettieri opened this issue Apr 2, 2019 · 5 comments
Open

Comments

@davidelettieri
Copy link

Following this I was able to configure a stateless service to events to AI, I'm also able to write logs to AI but the logs from the Stateless service are not related to the chain of call as shown in the screenshot

tempsnip

Is there any snippet I can use to make this work?

@yantang-msft
Copy link
Contributor

@lmolkova Would you be able to share any example to correlate custom event with the Activity?

@lmolkova
Copy link
Member

lmolkova commented Apr 2, 2019

As long as OperationCorrelationTelemetryInitializer is configured, there is no need to do anything else - it will use Activity and stamp ids on all telemtery items including custom events.

Here is where it is added in the example: https://github.com/yantang-msft/service-fabric-application-insights-example/blob/master/StatelessBackend/StatelessBackend.cs#L32

@davidelettieri
Copy link
Author

I'm sorry my question was not very clear. I'll try to add some context.

On a .NET Core Web Api Stateless service I have the following action on a controller and the LogInformation calls are correctly linked to the request as shown in the screenshot of my first comment. The random value is retrieved via remoting from another stateless service
image

Here I have the service I call and I create the tracking events that are shown in my first comment. I also have two LogInformation calls that are in AI but are not related to the chain of calls.
image

I would like to use the logging infrastructure to log to AI but also be able to follow through the calls and find all the logs.

Let me know if I should clarify more.

@yantang-msft
Copy link
Contributor

@davidelettieri I suppose you have done something like this in your asp.net core project:

            WebHost.CreateDefaultBuilder(args)
                .UseApplicationInsights()
                .ConfigureLogging(logging =>
                {
                    logging.AddApplicationInsights();
                }

@lmolkova I don't see the OperationCorrelationTelemetryInitializer added here. Would it be a bug of the asp.net core sdk?

@lmolkova
Copy link
Member

lmolkova commented Apr 3, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants