Skip to content

Commit

Permalink
Merge branch 'main' into reyang/exception
Browse files Browse the repository at this point in the history
  • Loading branch information
reyang authored Mar 4, 2021
2 parents a6e2356 + 7da935e commit b54d0ba
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/OpenTelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ please check the latest changes
* Added new constructor with optional parameters to allow customization of
`ParentBasedSampler` behavior. ([#1727](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1727))

* The application base directory is now tested after the current directory when
searching for the
[self diagnostic configuration file](https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/src/OpenTelemetry/README.md#troubleshooting).
([#1865](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1865))

## 1.0.1

Released 2021-Feb-10
Expand Down
19 changes: 16 additions & 3 deletions src/OpenTelemetry/Internal/SelfDiagnosticsConfigParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,25 @@ public bool TryGetConfiguration(out string logDirectory, out int fileSizeInKB, o
logLevel = EventLevel.LogAlways;
try
{
if (!File.Exists(ConfigFileName))
var configFilePath = ConfigFileName;

// First check using current working directory
if (!File.Exists(configFilePath))
{
return false;
#if NET452
configFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ConfigFileName);
#else
configFilePath = Path.Combine(AppContext.BaseDirectory, ConfigFileName);
#endif

// Second check using application base directory
if (!File.Exists(configFilePath))
{
return false;
}
}

using FileStream file = File.Open(ConfigFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
using FileStream file = File.Open(configFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
var buffer = this.configBuffer;
if (buffer == null)
{
Expand Down

0 comments on commit b54d0ba

Please sign in to comment.