-
Notifications
You must be signed in to change notification settings - Fork 293
Added support to read diagnostics config from the path defined in environment variable #2769
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
9603d2e
draft
Yun-Ting ebdcb49
order
Yun-Ting 89b7e53
platforms
Yun-Ting 4faf7e7
logDirectory
Yun-Ting c060069
test
Yun-Ting 5d3e501
update
Yun-Ting 5343264
comments
Yun-Ting 6525f04
Update BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.Applica…
Yun-Ting 693e452
Merge branch 'main' into yunl/funcApp3
Yun-Ting 754c12c
local AspNet testing
Yun-Ting ee91e8d
Merge branch 'main' into yunl/funcApp3
Yun-Ting 39d0107
Merge branch 'yunl/funcApp3' of https://github.com/microsoft/Applicat…
Yun-Ting dc66b62
clenaup test, changelog
Yun-Ting 94a0f19
fixed version
Yun-Ting File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,13 +5,16 @@ | |
| using System.IO; | ||
| using System.Text; | ||
| using System.Text.RegularExpressions; | ||
| using Microsoft.ApplicationInsights.Extensibility.Implementation.Platform; | ||
|
|
||
| internal class SelfDiagnosticsConfigParser | ||
| { | ||
| public const string ConfigFileName = "ApplicationInsightsDiagnostics.json"; | ||
| private const int FileSizeLowerLimit = 1024; // Lower limit for log file size in KB: 1MB | ||
| private const int FileSizeUpperLimit = 128 * 1024; // Upper limit for log file size in KB: 128MB | ||
|
|
||
| private const string LogDiagnosticsEnviornmentVariable = "APPLICATIONINSIGHTS_LOG_DIAGNOSTICS"; | ||
Yun-Ting marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| /// <summary> | ||
| /// ConfigBufferSize is the maximum bytes of config file that will be read. | ||
| /// </summary> | ||
|
|
@@ -40,8 +43,14 @@ public bool TryGetConfiguration(out string logDirectory, out int fileSizeInKB, o | |
| { | ||
| var configFilePath = ConfigFileName; | ||
|
|
||
| if (PlatformSingleton.Current.TryGetEnvironmentVariable(LogDiagnosticsEnviornmentVariable, out string logDiagnosticsPath)) | ||
| { | ||
| configFilePath = Path.Combine(logDiagnosticsPath, ConfigFileName); | ||
| logDirectory = logDiagnosticsPath; | ||
| } | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove the blank space before
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we want to have a blank line before comment? |
||
| // First check using current working directory | ||
Yun-Ting marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (!File.Exists(configFilePath)) | ||
| else if (!File.Exists(configFilePath)) | ||
| { | ||
| #if NET452 | ||
| configFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ConfigFileName); | ||
|
|
@@ -67,7 +76,8 @@ public bool TryGetConfiguration(out string logDirectory, out int fileSizeInKB, o | |
|
|
||
| file.Read(buffer, 0, buffer.Length); | ||
| string configJson = Encoding.UTF8.GetString(buffer); | ||
| if (!TryParseLogDirectory(configJson, out logDirectory)) | ||
|
|
||
| if (logDirectory == null && !TryParseLogDirectory(configJson, out logDirectory)) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.