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

[bug] The log generated by setting OTEL_DIAGNOSTICS.json is binary and unreadable #6024

Open
domholmes opened this issue Dec 13, 2024 · 4 comments
Labels
bug Something isn't working needs-triage New issues which have not been classified or triaged by a community member pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package

Comments

@domholmes
Copy link

domholmes commented Dec 13, 2024

Package

OpenTelemetry

Package Version

Package Name Version
OpenTelemetry.Api 1.9.0
OpenTelemetry 1.9.0

Runtime Version

net8.0

Description

Creating a OTEL_DIAGNOSTICS.json in the correct place causes debug log files to be created e.g My.Project.exe.37076.log but they are unreadable

Steps to Reproduce

  1. Configure a working ASP.NET core application that exports OpenTelemetary data as expected
  2. Add a OTEL_DIAGNOSTICS.json file in the root of the project directory
  3. Run the application and generate trace data
  4. Attempt to open the log file written in the same directory

Expected Result

The log is a readable text file

Actual Result

The log is unreadable

Additional Context

{
"LogDirectory": ".",
"FileSize": 32768,
"LogLevel": "Error"
}

@domholmes domholmes added bug Something isn't working needs-triage New issues which have not been classified or triaged by a community member labels Dec 13, 2024
@github-actions github-actions bot added the pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package label Dec 13, 2024
@xiang17
Copy link
Contributor

xiang17 commented Dec 13, 2024

What does the log file look like? The file is written circularly in a fixed size block. And initially it was initialized with all NUL characters, so there may seem to have a lot of garbles after the lines of readable logs at file start.

@domholmes
Copy link
Author

Hi there. Most editors won't open it, reporting it as binary. Those that do, there are no readable characters at the start, even changing the LogLevel to ensure something should be printed.

@xiang17
Copy link
Contributor

xiang17 commented Jan 2, 2025

Can you give a minimal sample app that can reproduce the issue?

@domholmes
Copy link
Author

domholmes commented Jan 6, 2025

Ok so I did some more digging and the problem is that the log isn't overwritten with readable data until the TracerProviderBuilder is manually disposed i.e pressing Ctrl+C on the terminal to end the application and not just killing the debug session with the stop icon in Visual Studio (tracer.Dispose() is never reached).

This is only a problem when manually creating tracers with Sdk.CreateTracerProviderBuilder(). Using builder.Services.AddOpenTelemetry() the logs are written instantly (much more useful).

OtelLogTest.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage New issues which have not been classified or triaged by a community member pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package
Projects
None yet
Development

No branches or pull requests

2 participants