-
Notifications
You must be signed in to change notification settings - Fork 93
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
Logging improvements #456
Logging improvements #456
Conversation
} | ||
} | ||
|
||
logDirectory = CreateDirectoryIfMissing(logDirectory) ?? Path.GetTempPath(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a respective doc update to reflect this fallback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in 829226d
src/OpenTelemetry.AutoInstrumentation/Instrumentations/GraphQL/GraphQLCommon.cs
Show resolved
Hide resolved
Added a related issue #457 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - @lachmatt could you please rebase and rebuild so you fix the change that came with the addition of the EventListener
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
little things
|
||
if (logDirectory == null) | ||
{ | ||
var nativeLogFile = Environment.GetEnvironmentVariable(ConfigurationKeys.LogPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about renaming nativeLogFile
to something more or less like envVarValue
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in 3bd2baa
docs/config.md
Outdated
@@ -58,6 +58,8 @@ Default logs directory paths are: | |||
- Windows: `%ProgramData%\OpenTelemetry .NET AutoInstrumentation\logs` | |||
- Linux: `/var/log/opentelemetry/dotnet` | |||
|
|||
If there is a problem with creation of the default directory, the path of the current user's [temporary folder](https://docs.microsoft.com/en-us/dotnet/api/System.IO.Path.GetTempPath?view=net-6.0) is used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is a problem with creation of the default directory, the path of the current user's [temporary folder](https://docs.microsoft.com/en-us/dotnet/api/System.IO.Path.GetTempPath?view=net-6.0) is used. | |
If there is a problem with the creation of the default directory, | |
the path of the current user's [temporary folder](https://docs.microsoft.com/en-us/dotnet/api/System.IO.Path.GetTempPath?view=net-6.0) | |
is used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in 3bd2baa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, however since #458 was merged, the following files may need to be updated for tests to pass:
src/OpenTelemetry.AutoInstrumentation/Diagnostics/SdkSelfDiagnosticsEventListener.cs
test/OpenTelemetry.AutoInstrumentation.Tests/Diagnostics/SdkSelfDiagnosticsEventListenerTests.cs
.../OpenTelemetry.AutoInstrumentation.Tests/Diagnostics/SdkSelfDiagnosticsEventListenerTests.cs
Show resolved
Hide resolved
/// <summary> | ||
/// Configuration key for setting the directory for the profiler's log files. | ||
/// If set, this setting takes precedence over environment variable OTEL_DOTNET_AUTO_LOG_PATH. | ||
/// If not set, default is | ||
/// "%ProgramData%"\OpenTelemetry .NET AutoInstrumentation\logs\" on Windows or | ||
/// "/var/log/opentelemetry/dotnet/" on Linux. | ||
/// </summary> | ||
public const string LogDirectory = "OTEL_DOTNET_AUTO_LOG_DIRECTORY"; | ||
|
||
/// <summary> | ||
/// Configuration key for setting the path for the profiler's native log file. | ||
/// Environment variable OTEL_DOTNET_AUTO_LOG_DIRECTORY takes precedence over this setting, if set. | ||
/// </summary> | ||
public const string LogPath = "OTEL_DOTNET_AUTO_LOG_PATH"; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to have both settings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added them both here, because both need to be checked to be consistent with StartupLogger
, which takes them into account when deciding on log directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it is also used in the native logger. I created an issue to remove one of them: #476
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, better to have a single env var and use the same for native and managed.
Another thing that we may want to consider post-beta is: the native log is one file for multiple applications so it is not symmetrical to the managed one. Perhaps it will make the user's life simpler if the logs of a single run were easier to "group".
Why
Remove console logging.
Fixes #334
What
Simple logging to a file, based on logic from loader:
FileSink
from loaderPossible improvements:
Tests
Smoke tests.