Skip to content

Commit 814206d

Browse files
authored
Improve log message written by selfdiagnostics to file. (#4219)
1 parent 7139c7a commit 814206d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/OpenTelemetry/Internal/SelfDiagnosticsConfigRefresher.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace OpenTelemetry.Internal
3030
/// </summary>
3131
internal class SelfDiagnosticsConfigRefresher : IDisposable
3232
{
33-
public static readonly byte[] MessageOnNewFile = Encoding.UTF8.GetBytes("Successfully opened file.\n");
33+
public static readonly byte[] MessageOnNewFile = Encoding.UTF8.GetBytes("If you are seeing this message, it means that the OpenTelemetry SDK has successfully created the log file used to write self-diagnostic logs. This file will be appended with logs as they appear. If you do not see any logs following this line, it means no logs of the configured LogLevel is occurring. You may change the LogLevel to show lower log levels, so that logs of lower severities will be shown.\n");
3434

3535
private const int ConfigurationUpdatePeriodMilliSeconds = 10000;
3636

@@ -208,7 +208,7 @@ private void OpenLogFile(string newLogDirectory, int newFileSize)
208208

209209
// Because the API [MemoryMappedFile.CreateFromFile][1](the string version) behaves differently on
210210
// .NET Framework and .NET Core, here I am using the [FileStream version][2] of it.
211-
// Taking the last four prameter values from [.NET Framework]
211+
// Taking the last four parameter values from [.NET Framework]
212212
// (https://referencesource.microsoft.com/#system.core/System/IO/MemoryMappedFiles/MemoryMappedFile.cs,148)
213213
// and [.NET Core]
214214
// (https://github.com/dotnet/runtime/blob/master/src/libraries/System.IO.MemoryMappedFiles/src/System/IO/MemoryMappedFiles/MemoryMappedFile.cs#L152)
@@ -263,7 +263,7 @@ private void Dispose(bool disposing)
263263
this.cancellationTokenSource.Dispose();
264264
}
265265

266-
// Dispose EventListner before files, because EventListner writes to files.
266+
// Dispose EventListener before files, because EventListener writes to files.
267267
if (this.eventListener != null)
268268
{
269269
this.eventListener.Dispose();

test/OpenTelemetry.Tests/Internal/SelfDiagnosticsConfigRefresherTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,16 @@ public void SelfDiagnosticsConfigRefresher_CaptureAsConfigured()
7070

7171
// Emitting event of EventLevel.Error
7272
OpenTelemetrySdkEventSource.Log.SpanProcessorException("Event string sample", "Exception string sample");
73+
string expectedMessage = "Unknown error in SpanProcessor event '{0}': '{1}'.{Event string sample}{Exception string sample}";
7374

74-
int bufferSize = 512;
75+
int bufferSize = 2 * (MessageOnNewFileString.Length + expectedMessage.Length);
7576
byte[] actualBytes = ReadFile(bufferSize);
7677
string logText = Encoding.UTF8.GetString(actualBytes);
7778
Assert.StartsWith(MessageOnNewFileString, logText);
7879

7980
// The event was captured
8081
string logLine = logText.Substring(MessageOnNewFileString.Length);
8182
string logMessage = ParseLogMessage(logLine);
82-
string expectedMessage = "Unknown error in SpanProcessor event '{0}': '{1}'.{Event string sample}{Exception string sample}";
8383
Assert.StartsWith(expectedMessage, logMessage);
8484
}
8585
finally

0 commit comments

Comments
 (0)