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

ILogger logs not reflecting correct application name #5560

Closed
Leonardo-Ferreira opened this issue Apr 22, 2024 · 6 comments
Closed

ILogger logs not reflecting correct application name #5560

Leonardo-Ferreira opened this issue Apr 22, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@Leonardo-Ferreira
Copy link

Bug Report

Azure.Monitor.OpenTelemetry.AspNetCore 1.1.0
OpenTelemetry.Exporter.Console 1.8.1
OpenTelemetry.Instrumentation.Process1.0.0-alpha.6
OpenTelemetry.Instrumentation.Runtime 1.8.0

Runtime version (e.g. net462, net48, netcoreapp3.1, net6.0 etc. You can
find this information from the *.csproj file):

net8.0

Symptom

A clear and concise description of what the bug is.

What is the expected behavior?

That just like the requests and metrics, the log would have the correct App Service Name

What is the actual behavior?

The app name unknown_service:dotnet

Reproduce

Create a new web api, default template... add the packages above and in the program.cs do

public class Program
{
    public static void Main(string[] args)
    {
        var builder = WebApplication.CreateBuilder(args);

        var resourceAttributes = new Dictionary<string, object> { { "service.name", "Flex Backend Mocker" } };

        builder.Services.AddOpenTelemetry()
                        .ConfigureResource(cfg => cfg.AddAttributes(resourceAttributes))
                        .WithMetrics(builder => builder.AddAspNetCoreInstrumentation().AddRuntimeInstrumentation().AddProcessInstrumentation().AddConsoleExporter())
                        .WithTracing(builder => builder.AddAspNetCoreInstrumentation().AddConsoleExporter())
                        .UseAzureMonitor(cfg =>
                        {
                            cfg.ConnectionString = "yourConnectionStringToAzureAppInsightsHere";
                        });

        // Add services to the container.
        builder.Services.AddMemoryCache();
        builder.Services.AddControllers();
        builder.Services.AddSingleton<Random>();

        var app = builder.Build();

        app.MapControllers();

        app.Run();
    }
}

Then run. Using a tool like Fiddler, you can capture the requests going out and you will see that only the logs like "application started etc" have the app name set to unknown_service:dotnet

Additional Context

N/A

@Leonardo-Ferreira Leonardo-Ferreira added the bug Something isn't working label Apr 22, 2024
@cijothomas
Copy link
Member

Can you follow #5551 (comment) ?

@rajkumar-rangaraj
Copy link
Contributor

Azure.Monitor.OpenTelemetry.AspNetCore had an issue where logs were using a different resource attributes. This was fixed in the 1.2.0-beta.3 version. Could you please try the new package and check if the issue is resolved? I recommend testing the behavior without the UseAzureMonitor API. If you have an issue related to that specific package, please post your question at https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore.

@Leonardo-Ferreira
Copy link
Author

Leonardo-Ferreira commented Apr 22, 2024

well, yes it solved this issue, but created another: now there are extra properties... like, my logged message is "Will Delay for 123ms" and now I have a extra property like {"0":"472"}

is there a way to turn off this "auto-enrichment"?

@cijothomas
Copy link
Member

well, yes it solved this issue, but created another: now there are extra properties... like, my logged message is "Will Delay for 123ms" and now I have a extra property like {"0":"472"}

is there a way to turn off this "auto-enrichment"?

Are you seeing that enrichment in AzureMonitor only? or when using ConsoleExporters (or OTLP) ?

@Leonardo-Ferreira
Copy link
Author

Only in azure monitor, this enrichment is not visible on the console

@cijothomas
Copy link
Member

Only in azure monitor, this enrichment is not visible on the console

mm. Strange! Not sure what's going on. I'd suggest to report it at azure-monitor repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants