From dfa51220a53930d087e1be2613e0ae7ba21d3032 Mon Sep 17 00:00:00 2001 From: Timothy Mothra Date: Fri, 9 Jul 2021 10:26:22 -0700 Subject: [PATCH 01/11] log to indicated Authentication Policy caught the response from ingestion (#2319) --- .../Implementation/TelemetryChannelEventSource.cs | 6 ++++++ .../TransmissionPolicy/AuthenticationTransmissionPolicy.cs | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/BASE/src/ServerTelemetryChannel/Implementation/TelemetryChannelEventSource.cs b/BASE/src/ServerTelemetryChannel/Implementation/TelemetryChannelEventSource.cs index 849c7558c3..4b78dd2b45 100644 --- a/BASE/src/ServerTelemetryChannel/Implementation/TelemetryChannelEventSource.cs +++ b/BASE/src/ServerTelemetryChannel/Implementation/TelemetryChannelEventSource.cs @@ -565,6 +565,12 @@ public void TransmissionFlushAsyncWarning(string exception, string appDomainName this.WriteEvent(77, exception ?? string.Empty, this.ApplicationName); } + [Event(78, Message = "AuthenticatedTransmissionError. Received a failed ingestion response. TransmissionId: {0}. Status Code: {1}. Status Description: {2}", Level = EventLevel.Warning)] + public void AuthenticationPolicyCaughtFailedIngestion(string transmissionId, string statusCode, string statusDescription, string appDomainName = "Incorrect") + { + this.WriteEvent(78, transmissionId ?? string.Empty, statusCode ?? string.Empty, statusDescription ?? string.Empty, this.ApplicationName); + } + private static string GetApplicationName() { //// We want to add application name to all events BUT diff --git a/BASE/src/ServerTelemetryChannel/Implementation/TransmissionPolicy/AuthenticationTransmissionPolicy.cs b/BASE/src/ServerTelemetryChannel/Implementation/TransmissionPolicy/AuthenticationTransmissionPolicy.cs index 0dc78e8cf6..4444a32ee4 100644 --- a/BASE/src/ServerTelemetryChannel/Implementation/TransmissionPolicy/AuthenticationTransmissionPolicy.cs +++ b/BASE/src/ServerTelemetryChannel/Implementation/TransmissionPolicy/AuthenticationTransmissionPolicy.cs @@ -1,6 +1,7 @@ namespace Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Implementation.TransmissionPolicy { using System; + using System.Globalization; using System.Threading.Tasks; using Microsoft.ApplicationInsights.Channel.Implementation; @@ -65,6 +66,10 @@ private void HandleTransmissionSentEvent(object sender, TransmissionProcessedEve { case ResponseStatusCodes.Unauthorized: case ResponseStatusCodes.Forbidden: + TelemetryChannelEventSource.Log.AuthenticationPolicyCaughtFailedIngestion( + transmissionId: e.Transmission.Id, + statusCode: e.Response.StatusCode.ToString(CultureInfo.InvariantCulture), + statusDescription: e.Response.StatusDescription); this.ApplyThrottlePolicy(e); break; } From c68a4f4d839a1474c7e74340261eab552d6e5daf Mon Sep 17 00:00:00 2001 From: Timothy Mothra Date: Fri, 9 Jul 2021 16:57:21 -0700 Subject: [PATCH 02/11] Update linux-build.yml (#2329) update version of dotnet 5 --- NETCORE/.vsts/linux-build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/NETCORE/.vsts/linux-build.yml b/NETCORE/.vsts/linux-build.yml index de11ffc536..4bd8f81d2d 100644 --- a/NETCORE/.vsts/linux-build.yml +++ b/NETCORE/.vsts/linux-build.yml @@ -37,8 +37,7 @@ steps: - task: UseDotNet@2 displayName: install dotnet 5 inputs: - version: 5.0.100-rc.2.20479.15 - includePreviewVersions: true + version: 5.0.x - task: DotNetCoreCLI@2 displayName: DotNetCoreCLI - Restore Solution From 317786702ee9c356f7e452b6739fcdcceb59f455 Mon Sep 17 00:00:00 2001 From: Timothy Mothra Date: Fri, 9 Jul 2021 17:47:38 -0700 Subject: [PATCH 03/11] Self-Diagnostics: include datetimestamp in filename (#2325) * include datetimestamp in self-diagnostics filename * come review comments * update readme * update readme * Update Readme.md --- .../MemoryMappedFileHandlerTest.cs | 19 +++++++++++-------- .../SelfDiagnosticsConfigRefresherTest.cs | 15 ++++++++------- .../MemoryMappedFileHandler.cs | 17 +++++++++++++++-- .../SelfDiagnosticsConfigRefresher.cs | 2 ++ troubleshooting/ETW/Readme.md | 7 +++++-- 5 files changed, 41 insertions(+), 19 deletions(-) diff --git a/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Extensibility/Implementation/Tracing/SelfDiagnostics/MemoryMappedFileHandlerTest.cs b/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Extensibility/Implementation/Tracing/SelfDiagnostics/MemoryMappedFileHandlerTest.cs index 702d10f857..6e5d230a4a 100644 --- a/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Extensibility/Implementation/Tracing/SelfDiagnostics/MemoryMappedFileHandlerTest.cs +++ b/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Extensibility/Implementation/Tracing/SelfDiagnostics/MemoryMappedFileHandlerTest.cs @@ -15,15 +15,16 @@ public class MemoryMappedFileHandlerTest [TestMethod] public void MemoryMappedFileHandler_Success() { - var fileName = Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName) + "." - + Process.GetCurrentProcess().Id + ".log"; + string filePath; var fileSize = 1024; using (var handler = new MemoryMappedFileHandler()) { handler.CreateLogFile(".", fileSize); + + filePath = handler.CurrentFilePath; } - var actualBytes = ReadFile(fileName, MessageOnNewFile.Length); + var actualBytes = ReadFile(filePath, MessageOnNewFile.Length); CollectionAssert.AreEqual(MessageOnNewFile, actualBytes); } @@ -36,6 +37,8 @@ public void MemoryMappedFileHandler_Circular_Success() var messageToOverflow = Encoding.UTF8.GetBytes("1234567"); var expectedBytesAtEnd = Encoding.UTF8.GetBytes("1234"); var expectedBytesAtStart = Encoding.UTF8.GetBytes("567cessfully opened file.\n"); + string filePath; + using (var handler = new MemoryMappedFileHandler()) { handler.CreateLogFile(".", fileSize); @@ -43,20 +46,20 @@ public void MemoryMappedFileHandler_Circular_Success() handler.Write(buffer, fileSize - MessageOnNewFile.Length - expectedBytesAtEnd.Length); handler.Write(messageToOverflow, messageToOverflow.Length); + + filePath = handler.CurrentFilePath; } - var fileName = Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName) + "." - + Process.GetCurrentProcess().Id + ".log"; - var actualBytes = ReadFile(fileName, buffer.Length); + var actualBytes = ReadFile(filePath, buffer.Length); CollectionAssert.AreEqual(expectedBytesAtStart, SubArray(actualBytes, 0, expectedBytesAtStart.Length)); CollectionAssert.AreEqual(expectedBytesAtEnd, SubArray(actualBytes, actualBytes.Length - expectedBytesAtEnd.Length, expectedBytesAtEnd.Length)); } - private static byte[] ReadFile(string fileName, int byteCount) + private static byte[] ReadFile(string filePath, int byteCount) { byte[] actualBytes = new byte[byteCount]; - using (var file = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + using (var file = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { file.Read(actualBytes, 0, byteCount); } diff --git a/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Extensibility/Implementation/Tracing/SelfDiagnostics/SelfDiagnosticsConfigRefresherTest.cs b/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Extensibility/Implementation/Tracing/SelfDiagnostics/SelfDiagnosticsConfigRefresherTest.cs index 5bd6318e09..fa12d6b1e5 100644 --- a/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Extensibility/Implementation/Tracing/SelfDiagnostics/SelfDiagnosticsConfigRefresherTest.cs +++ b/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Extensibility/Implementation/Tracing/SelfDiagnostics/SelfDiagnosticsConfigRefresherTest.cs @@ -27,8 +27,10 @@ public void SelfDiagnosticsConfigRefresher_OmitAsConfigured() // Emitting event of EventLevel.Warning CoreEventSource.Log.OperationIsNullWarning(); + var filePath = configRefresher.CurrentFilePath; + int bufferSize = 512; - byte[] actualBytes = ReadFile(bufferSize); + byte[] actualBytes = ReadFile(filePath, bufferSize); string logText = Encoding.UTF8.GetString(actualBytes); Assert.IsTrue(logText.StartsWith(MessageOnNewFileString)); @@ -52,8 +54,10 @@ public void SelfDiagnosticsConfigRefresher_CaptureAsConfigured() // Emitting event of EventLevel.Error CoreEventSource.Log.InvalidOperationToStopError(); + var filePath = configRefresher.CurrentFilePath; + int bufferSize = 512; - byte[] actualBytes = ReadFile(bufferSize); + byte[] actualBytes = ReadFile(filePath, bufferSize); string logText = Encoding.UTF8.GetString(actualBytes); Assert.IsTrue(logText.StartsWith(MessageOnNewFileString)); @@ -77,12 +81,9 @@ private static string ParseLogMessage(string logLine) return logLine.Substring(timestampPrefixLength); } - private static byte[] ReadFile(int byteCount) + private static byte[] ReadFile(string filePath, int byteCount) { - var outputFileName = Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName) + "." - + Process.GetCurrentProcess().Id + ".log"; - var outputFilePath = Path.Combine(".", outputFileName); - using (var file = File.Open(outputFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + using (var file = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { byte[] actualBytes = new byte[byteCount]; file.Read(actualBytes, 0, byteCount); diff --git a/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/SelfDiagnostics/MemoryMappedFileHandler.cs b/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/SelfDiagnostics/MemoryMappedFileHandler.cs index 2647ccf430..a319f43f81 100644 --- a/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/SelfDiagnostics/MemoryMappedFileHandler.cs +++ b/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/SelfDiagnostics/MemoryMappedFileHandler.cs @@ -2,6 +2,7 @@ namespace Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.Sel { using System; using System.Diagnostics; + using System.Globalization; using System.IO; using System.IO.MemoryMappedFiles; using System.Text; @@ -38,6 +39,8 @@ internal class MemoryMappedFileHandler : IDisposable public int LogFileSize { get => this.logFileSize; private set => this.logFileSize = value; } + public string CurrentFilePath => this.underlyingFileStreamForMemoryMappedFile?.Name; + /// /// Create a log file. If the file already exists, it will be overwritten. /// @@ -48,8 +51,7 @@ public void CreateLogFile(string logDirectory, int fileSize) try { Directory.CreateDirectory(logDirectory); - var fileName = Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName) + "." - + Process.GetCurrentProcess().Id + ".log"; + var fileName = GenerateFileName(); var filePath = Path.Combine(logDirectory, fileName); // Because the API [MemoryMappedFile.CreateFromFile][1](the string version) behaves differently on @@ -162,6 +164,17 @@ public virtual void Write(byte[] buffer, int byteCount) } } + private static string GenerateFileName() + { + var dateTimeStamp = DateTime.UtcNow.ToString("yyyyMMdd-HHmmss", CultureInfo.InvariantCulture); + + var currentProcess = Process.GetCurrentProcess(); + var processFileName = Path.GetFileName(currentProcess.MainModule.FileName); + var processId = currentProcess.Id; + + return $"{dateTimeStamp}.{processFileName}.{processId}.log"; + } + /// /// Try to get the log stream which is seeked to the position where the next line of log should be written. /// diff --git a/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/SelfDiagnostics/SelfDiagnosticsConfigRefresher.cs b/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/SelfDiagnostics/SelfDiagnosticsConfigRefresher.cs index 5ec4aa95be..78b86d9fd6 100644 --- a/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/SelfDiagnostics/SelfDiagnosticsConfigRefresher.cs +++ b/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/SelfDiagnostics/SelfDiagnosticsConfigRefresher.cs @@ -37,6 +37,8 @@ public SelfDiagnosticsConfigRefresher() this.worker = Task.Run(() => this.Worker(this.cancellationTokenSource.Token), this.cancellationTokenSource.Token); } + public string CurrentFilePath => this.memoryMappedFileHandler.CurrentFilePath; + /// public void Dispose() { diff --git a/troubleshooting/ETW/Readme.md b/troubleshooting/ETW/Readme.md index 3662dc15ff..0ccf3670a2 100644 --- a/troubleshooting/ETW/Readme.md +++ b/troubleshooting/ETW/Readme.md @@ -122,7 +122,8 @@ As of version 2.18.0, this SDK ships a "self-diagnostics feature" which captures The self-diagnostics feature can be enabled/changed/disabled while the process is running. The SDK will attempt to read the configuration file every 10 seconds, using a non-exclusive read-only mode. -The SDK will create or overwrite a file with new logs according to the configuration. +The SDK will create or overwrite a file with new logs according to the configuration. +This file will not exceed the configured max size and will be circularly overwritten. #### Configuration @@ -150,13 +151,15 @@ Example: #### Configuration Parameters -A `FileSize`-KiB log file named as `ExecutableName.ProcessId.log` (e.g. `foobar.exe.12345.log`) will be generated at the specified directory `LogDirectory`. +A `FileSize`-KiB log file named as `YearMonthDay-HourMinuteSecond.ExecutableName.ProcessId.log` (e.g. `20010101-120000.foobar.exe.12345.log`) will be generated at the specified directory `LogDirectory`. +The file name starts with the `DateTime.UtcNow` timestamp of when the file was created. 1. `LogDirectory` is the directory where the output log file will be stored. It can be an absolute path or a relative path to the current directory. 2. `FileSize` is a positive integer, which specifies the log file size in [KiB](https://en.wikipedia.org/wiki/Kibibyte). This value must be between 1 MiB and 128 MiB (inclusive), or it will be rounded to the closest upper or lower limit. +The log file will never exceed this configured size, and will be circularly rewriten. 3. `LogLevel` is the lowest level of the events to be captured. This value must match one of the [fields](https://docs.microsoft.com/dotnet/api/system.diagnostics.tracing.eventlevel#fields) of the `EventLevel` enum. From 39d636f6fbbf351d81979efffa8da92b8651917c Mon Sep 17 00:00:00 2001 From: Timothy Mothra Date: Fri, 16 Jul 2021 14:18:57 -0700 Subject: [PATCH 04/11] Update CHANGELOG.md (#2332) --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 416ff518a5..181fabf9b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ # Changelog ## VNext - +- [Change Self-Diagnostics to include datetimestamp in filename](https://github.com/microsoft/ApplicationInsights-dotnet/pull/2325) +- [AAD: Add logging to AuthenticationTransmissionPolicy](https://github.com/microsoft/ApplicationInsights-dotnet/pull/2319) ## Version 2.18.0-beta3 - [Enable the self diagnostics and fix a NullReferenceException bug](https://github.com/microsoft/ApplicationInsights-dotnet/pull/2302) From 030ebad50145a335c5b3d307409f8c0cc3b872f4 Mon Sep 17 00:00:00 2001 From: Timothy Mothra Date: Tue, 20 Jul 2021 20:01:45 -0700 Subject: [PATCH 05/11] prune public api (#2336) --- .../net452/PublicAPI.Unshipped.txt | 18 ++---------------- .../net46/PublicAPI.Unshipped.txt | 18 ++---------------- .../netstandard2.0/PublicAPI.Unshipped.txt | 18 ++---------------- .../Implementation/Authentication/AuthToken.cs | 15 +++++---------- .../Authentication/CredentialEnvelope.cs | 2 +- .../Extensibility/TelemetryConfiguration.cs | 5 ++--- .../Properties/AssemblyInfo.cs | 1 + .../PerformanceCollector/AssemblyInfo.cs | 13 ------------- .../PerformanceCollectorModule.cs | 2 +- .../QuickPulseTelemetryModule.cs | 2 +- 10 files changed, 17 insertions(+), 77 deletions(-) diff --git a/.publicApi/Microsoft.ApplicationInsights.dll/net452/PublicAPI.Unshipped.txt b/.publicApi/Microsoft.ApplicationInsights.dll/net452/PublicAPI.Unshipped.txt index 076d707d9b..4e9a8eb77a 100644 --- a/.publicApi/Microsoft.ApplicationInsights.dll/net452/PublicAPI.Unshipped.txt +++ b/.publicApi/Microsoft.ApplicationInsights.dll/net452/PublicAPI.Unshipped.txt @@ -1,21 +1,7 @@ -abstract Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope.GetToken(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken -abstract Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope.GetTokenAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task -Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken -Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.AuthToken() -> void -Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.AuthToken(string token, System.DateTimeOffset expiresOn) -> void -Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.ExpiresOn.get -> System.DateTimeOffset -Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.ExpiresOn.set -> void -Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.Token.get -> string -Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.Token.set -> void -Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope -Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope.CredentialEnvelope() -> void -Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.CredentialEnvelope.get -> Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope + Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.SetAzureTokenCredential(object tokenCredential) -> void + Microsoft.ApplicationInsights.Channel.IAsyncFlushable Microsoft.ApplicationInsights.Channel.IAsyncFlushable.FlushAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task Microsoft.ApplicationInsights.Channel.InMemoryChannel.FlushAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task Microsoft.ApplicationInsights.TelemetryClient.FlushAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task -override Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.Equals(object obj) -> bool -override Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.GetHashCode() -> int -static Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.operator !=(Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken left, Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken right) -> bool -static Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.operator ==(Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken left, Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken right) -> bool \ No newline at end of file diff --git a/.publicApi/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt b/.publicApi/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt index 076d707d9b..4e9a8eb77a 100644 --- a/.publicApi/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt +++ b/.publicApi/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt @@ -1,21 +1,7 @@ -abstract Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope.GetToken(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken -abstract Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope.GetTokenAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task -Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken -Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.AuthToken() -> void -Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.AuthToken(string token, System.DateTimeOffset expiresOn) -> void -Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.ExpiresOn.get -> System.DateTimeOffset -Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.ExpiresOn.set -> void -Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.Token.get -> string -Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.Token.set -> void -Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope -Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope.CredentialEnvelope() -> void -Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.CredentialEnvelope.get -> Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope + Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.SetAzureTokenCredential(object tokenCredential) -> void + Microsoft.ApplicationInsights.Channel.IAsyncFlushable Microsoft.ApplicationInsights.Channel.IAsyncFlushable.FlushAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task Microsoft.ApplicationInsights.Channel.InMemoryChannel.FlushAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task Microsoft.ApplicationInsights.TelemetryClient.FlushAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task -override Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.Equals(object obj) -> bool -override Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.GetHashCode() -> int -static Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.operator !=(Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken left, Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken right) -> bool -static Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.operator ==(Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken left, Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken right) -> bool \ No newline at end of file diff --git a/.publicApi/Microsoft.ApplicationInsights.dll/netstandard2.0/PublicAPI.Unshipped.txt b/.publicApi/Microsoft.ApplicationInsights.dll/netstandard2.0/PublicAPI.Unshipped.txt index 076d707d9b..4e9a8eb77a 100644 --- a/.publicApi/Microsoft.ApplicationInsights.dll/netstandard2.0/PublicAPI.Unshipped.txt +++ b/.publicApi/Microsoft.ApplicationInsights.dll/netstandard2.0/PublicAPI.Unshipped.txt @@ -1,21 +1,7 @@ -abstract Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope.GetToken(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken -abstract Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope.GetTokenAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task -Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken -Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.AuthToken() -> void -Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.AuthToken(string token, System.DateTimeOffset expiresOn) -> void -Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.ExpiresOn.get -> System.DateTimeOffset -Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.ExpiresOn.set -> void -Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.Token.get -> string -Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.Token.set -> void -Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope -Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope.CredentialEnvelope() -> void -Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.CredentialEnvelope.get -> Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.CredentialEnvelope + Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.SetAzureTokenCredential(object tokenCredential) -> void + Microsoft.ApplicationInsights.Channel.IAsyncFlushable Microsoft.ApplicationInsights.Channel.IAsyncFlushable.FlushAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task Microsoft.ApplicationInsights.Channel.InMemoryChannel.FlushAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task Microsoft.ApplicationInsights.TelemetryClient.FlushAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task -override Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.Equals(object obj) -> bool -override Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.GetHashCode() -> int -static Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.operator !=(Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken left, Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken right) -> bool -static Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken.operator ==(Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken left, Microsoft.ApplicationInsights.Extensibility.Implementation.Authentication.AuthToken right) -> bool \ No newline at end of file diff --git a/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Authentication/AuthToken.cs b/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Authentication/AuthToken.cs index c46ecc58dc..24c2d55227 100644 --- a/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Authentication/AuthToken.cs +++ b/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Authentication/AuthToken.cs @@ -6,7 +6,7 @@ /// This represents the Azure.Core.AccessToken returned by Azure.Core.TokenCredential. /// (https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/core/Azure.Core/src/AccessToken.cs). /// - public struct AuthToken + internal struct AuthToken : IEquatable { /// /// Initializes a new instance of . @@ -46,17 +46,12 @@ public AuthToken(string token, DateTimeOffset expiresOn) public static bool operator !=(AuthToken left, AuthToken right) => !left.Equals(right); /// - public override bool Equals(object obj) - { - if (obj is AuthToken authToken) - { - return authToken.ExpiresOn == this.ExpiresOn && authToken.Token == this.Token; - } - - return false; - } + public override bool Equals(object obj) => (obj is AuthToken authToken) && this.Equals(authToken); /// public override int GetHashCode() => this.Token.GetHashCode() ^ this.ExpiresOn.GetHashCode(); + + /// + public bool Equals(AuthToken other) => other.ExpiresOn == this.ExpiresOn && other.Token == this.Token; } } diff --git a/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Authentication/CredentialEnvelope.cs b/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Authentication/CredentialEnvelope.cs index 9948faaf84..6bca49b6ab 100644 --- a/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Authentication/CredentialEnvelope.cs +++ b/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Authentication/CredentialEnvelope.cs @@ -7,7 +7,7 @@ /// This interface defines a class that can interact with Azure.Core.TokenCredential. /// See also: (https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/core/Azure.Core/src/TokenCredential.cs). /// - public abstract class CredentialEnvelope + internal abstract class CredentialEnvelope { /// /// Gets the TokenCredential instance held by this class. diff --git a/BASE/src/Microsoft.ApplicationInsights/Extensibility/TelemetryConfiguration.cs b/BASE/src/Microsoft.ApplicationInsights/Extensibility/TelemetryConfiguration.cs index bfa55d4b27..53d284b666 100644 --- a/BASE/src/Microsoft.ApplicationInsights/Extensibility/TelemetryConfiguration.cs +++ b/BASE/src/Microsoft.ApplicationInsights/Extensibility/TelemetryConfiguration.cs @@ -339,10 +339,9 @@ public string ConnectionString /// /// Gets an envelope for Azure.Core.TokenCredential which provides an AAD Authenticated token. - /// FOR INTERNAL USE ONLY. To set the Credential use . + /// To set the Credential use . /// - [EditorBrowsable(EditorBrowsableState.Never)] - public CredentialEnvelope CredentialEnvelope { get; private set; } + internal CredentialEnvelope CredentialEnvelope { get; private set; } /// /// Gets or sets the chain of processors. diff --git a/BASE/src/Microsoft.ApplicationInsights/Properties/AssemblyInfo.cs b/BASE/src/Microsoft.ApplicationInsights/Properties/AssemblyInfo.cs index 34c30d94ba..94ad08aa49 100644 --- a/BASE/src/Microsoft.ApplicationInsights/Properties/AssemblyInfo.cs +++ b/BASE/src/Microsoft.ApplicationInsights/Properties/AssemblyInfo.cs @@ -9,6 +9,7 @@ [assembly: InternalsVisibleTo("Microsoft.ApplicationInsights.AspNetCore.Tests, PublicKey=" + AssemblyInfo.PublicKey)] [assembly: InternalsVisibleTo("Microsoft.ApplicationInsights.WorkerService.Tests, PublicKey=" + AssemblyInfo.PublicKey)] [assembly: InternalsVisibleTo("Microsoft.AI.ServerTelemetryChannel, PublicKey=" + AssemblyInfo.PublicKey)] +[assembly: InternalsVisibleTo("Microsoft.AI.PerfCounterCollector, PublicKey=" + AssemblyInfo.PublicKey)] // Assembly dynamically generated by Moq in unit tests [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=" + AssemblyInfo.MoqPublicKey)] diff --git a/WEB/Src/PerformanceCollector/PerformanceCollector/AssemblyInfo.cs b/WEB/Src/PerformanceCollector/PerformanceCollector/AssemblyInfo.cs index 2cf2d67268..9a7f56d51e 100644 --- a/WEB/Src/PerformanceCollector/PerformanceCollector/AssemblyInfo.cs +++ b/WEB/Src/PerformanceCollector/PerformanceCollector/AssemblyInfo.cs @@ -9,16 +9,3 @@ [assembly: InternalsVisibleTo("Microsoft.AI.PerformanceCollector.Tests, PublicKey=" + AssemblyInfo.PublicKey)] [assembly: InternalsVisibleTo("Microsoft.ApplicationInsights.AspNetCore.Tests, PublicKey=" + AssemblyInfo.PublicKey)] [assembly: InternalsVisibleTo("Microsoft.ApplicationInsights.WorkerService.Tests, PublicKey=" + AssemblyInfo.PublicKey)] - -internal static class AssemblyInfo -{ -#if PUBLIC_RELEASE - // Public key; assemblies are delay signed. - public const string PublicKey = "0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9"; -#else - // Internal key; assemblies are public signed. - public const string PublicKey = "0024000004800000940000000602000000240000525341310004000001000100319b35b21a993df850846602dae9e86d8fbb0528a0ad488ecd6414db798996534381825f94f90d8b16b72a51c4e7e07cf66ff3293c1046c045fafc354cfcc15fc177c748111e4a8c5a34d3940e7f3789dd58a928add6160d6f9cc219680253dcea88a034e7d472de51d4989c7783e19343839273e0e63a43b99ab338149dd59f"; -#endif - - public const string MoqPublicKey = "0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7"; -} \ No newline at end of file diff --git a/WEB/Src/PerformanceCollector/PerformanceCollector/PerformanceCollectorModule.cs b/WEB/Src/PerformanceCollector/PerformanceCollector/PerformanceCollectorModule.cs index 5f7e2f0dc2..0b5a542393 100644 --- a/WEB/Src/PerformanceCollector/PerformanceCollector/PerformanceCollectorModule.cs +++ b/WEB/Src/PerformanceCollector/PerformanceCollector/PerformanceCollectorModule.cs @@ -189,7 +189,7 @@ public void Initialize(TelemetryConfiguration configuration) this.telemetryConfiguration = configuration; this.client = new TelemetryClient(configuration); - this.client.Context.GetInternalContext().SdkVersion = SdkVersionUtils.GetSdkVersion(PerformanceCounterUtility.SDKVersionPrefix()); + this.client.Context.GetInternalContext().SdkVersion = Common.SdkVersionUtils.GetSdkVersion(PerformanceCounterUtility.SDKVersionPrefix()); this.lastRefreshTimestamp = DateTime.MinValue; diff --git a/WEB/Src/PerformanceCollector/PerformanceCollector/QuickPulseTelemetryModule.cs b/WEB/Src/PerformanceCollector/PerformanceCollector/QuickPulseTelemetryModule.cs index 2c5a832ad0..de79924b72 100644 --- a/WEB/Src/PerformanceCollector/PerformanceCollector/QuickPulseTelemetryModule.cs +++ b/WEB/Src/PerformanceCollector/PerformanceCollector/QuickPulseTelemetryModule.cs @@ -410,7 +410,7 @@ private void InitializeServiceClient(TelemetryConfiguration configuration) string instanceName = string.IsNullOrWhiteSpace(cloudContext?.RoleInstance) ? Environment.MachineName : cloudContext.RoleInstance; string roleName = cloudContext?.RoleName ?? string.Empty; string streamId = GetStreamId(); - var assemblyVersion = SdkVersionUtils.GetSdkVersion(null); + var assemblyVersion = Common.SdkVersionUtils.GetSdkVersion(null); bool isWebApp = PerformanceCounterUtility.IsWebAppRunningInAzure(); int? processorCount = PerformanceCounterUtility.GetProcessorCount(); this.ServiceClient = new QuickPulseServiceClient( From 7362b6500f606e43146565030056688ee4f10ce7 Mon Sep 17 00:00:00 2001 From: Timothy Mothra Date: Wed, 21 Jul 2021 14:18:42 -0700 Subject: [PATCH 06/11] prep 2.18 (#2337) --- .props/_GlobalStaticVersion.props | 2 +- .../net452/PublicAPI.Shipped.txt | 1 + .../net452/PublicAPI.Unshipped.txt | 1 - .../netstandard2.0/PublicAPI.Shipped.txt | 1 + .../netstandard2.0/PublicAPI.Unshipped.txt | 1 - .../net452/PublicAPI.Shipped.txt | 5 +++++ .../net452/PublicAPI.Unshipped.txt | 7 ------- .../net46/PublicAPI.Shipped.txt | 5 +++++ .../net46/PublicAPI.Unshipped.txt | 7 ------- .../netstandard2.0/PublicAPI.Shipped.txt | 5 +++++ .../netstandard2.0/PublicAPI.Unshipped.txt | 7 ------- 11 files changed, 18 insertions(+), 24 deletions(-) diff --git a/.props/_GlobalStaticVersion.props b/.props/_GlobalStaticVersion.props index 001423c28d..9cc616c89d 100644 --- a/.props/_GlobalStaticVersion.props +++ b/.props/_GlobalStaticVersion.props @@ -13,7 +13,7 @@ 2 18 0 - beta3 + nightly