-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Azure.Monitor.LiveMetrics] add project scaffolding (#39719)
* scaffolding * fix merge conflict * update comment * fix subdirectory
- Loading branch information
1 parent
17a12b5
commit 27af7cf
Showing
8 changed files
with
157 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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
18 changes: 17 additions & 1 deletion
18
...zure.Monitor.OpenTelemetry.LiveMetrics/src/Azure.Monitor.OpenTelemetry.LiveMetrics.csproj
This file contains 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 |
---|---|---|
@@ -1,15 +1,31 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<Description>An OpenTelemetry .NET AzureMonitor OpenTelemetry Live Metrics</Description> | ||
<AssemblyTitle>AzureMonitor OpenTelemetry Live Metrics</AssemblyTitle> | ||
<Version>1.0.0-beta.1</Version> | ||
<PackageTags>Azure Monitor OpenTelemetry live Metrics ApplicationInsights</PackageTags> | ||
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks> | ||
<IncludeOperationsSharedSource>true</IncludeOperationsSharedSource> | ||
<Nullable>enable</Nullable> | ||
<DefineConstants>$(DefineConstants);LIVE_METRICS_EXPORTER;</DefineConstants> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Azure.Core" /> | ||
<PackageReference Include="OpenTelemetry" /> | ||
</ItemGroup> | ||
|
||
<!-- Shared sorce from Azure.Monitor.OpenTelemetry.Exporter --> | ||
<ItemGroup> | ||
<Compile Include="..\..\Azure.Monitor.OpenTelemetry.Exporter\src\Internals\ConnectionString\*.cs" LinkBase="Internals\ConnectionString" /> | ||
<Compile Include="..\..\Azure.Monitor.OpenTelemetry.Exporter\src\Internals\Platform\*.cs" LinkBase="Internals\Platform" /> | ||
<Compile Include="..\..\Azure.Monitor.OpenTelemetry.Exporter\src\Internals\NullableAttributes.cs" LinkBase="Internals" /> | ||
<Compile Include="..\..\Azure.Monitor.OpenTelemetry.Exporter\src\Internals\ExceptionExtensions.cs" LinkBase="Internals" /> | ||
</ItemGroup> | ||
|
||
<!-- Shared source from Azure.Core --> | ||
<ItemGroup> | ||
<Compile Include="$(AzureCoreSharedSources)ConnectionString.cs" LinkBase="Shared" /> | ||
</ItemGroup> | ||
|
||
</Project> |
69 changes: 69 additions & 0 deletions
69
...tor.OpenTelemetry.LiveMetrics/src/Internals/Diagnostics/LiveMetricsExporterEventSource.cs
This file contains 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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Diagnostics.Tracing; | ||
using System.Runtime.CompilerServices; | ||
using Azure.Monitor.OpenTelemetry.Exporter.Internals; | ||
|
||
namespace Azure.Monitor.OpenTelemetry.LiveMetrics.Internals.Diagnostics | ||
{ | ||
/// <summary> | ||
/// EventSource for the AzureMonitorExporter. | ||
/// EventSource Guid at Runtime: 72f5588f-fa1c-502e-0627-e13dd2bd67c9. | ||
/// (This guid can be found by debugging this class and inspecting the "Log" singleton and reading the "Guid" property). | ||
/// </summary> | ||
/// <remarks> | ||
/// PerfView Instructions: | ||
/// <list type="bullet"> | ||
/// <item>To collect all events: <code>PerfView.exe collect -MaxCollectSec:300 -NoGui /onlyProviders=*OpenTelemetry-AzureMonitor-LiveMetrics</code></item> | ||
/// <item>To collect events based on LogLevel: <code>PerfView.exe collect -MaxCollectSec:300 -NoGui /onlyProviders:OpenTelemetry-AzureMonitor-LiveMetrics::Verbose</code></item> | ||
/// </list> | ||
/// Dotnet-Trace Instructions: | ||
/// <list type="bullet"> | ||
/// <item>To collect all events: <code>dotnet-trace collect --process-id PID --providers OpenTelemetry-AzureMonitor-LiveMetrics</code></item> | ||
/// <item>To collect events based on LogLevel: <code>dotnet-trace collect --process-id PID --providers OpenTelemetry-AzureMonitor-LiveMetrics::Verbose</code></item> | ||
/// </list> | ||
/// Logman Instructions: | ||
/// <list type="number"> | ||
/// <item>Create a text file containing providers: <code>echo "{72f5588f-fa1c-502e-0627-e13dd2bd67c9}" > providers.txt</code></item> | ||
/// <item>Start collecting: <code>logman -start exporter -pf providers.txt -ets -bs 1024 -nb 100 256</code></item> | ||
/// <item>Stop collecting: <code>logman -stop exporter -ets</code></item> | ||
/// </list> | ||
/// </remarks> | ||
[EventSource(Name = EventSourceName)] | ||
internal sealed class LiveMetricsExporterEventSource : EventSource | ||
{ | ||
internal const string EventSourceName = "OpenTelemetry-AzureMonitor-LiveMetrics"; | ||
|
||
internal static readonly LiveMetricsExporterEventSource Log = new LiveMetricsExporterEventSource(); | ||
|
||
[NonEvent] | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
private bool IsEnabled(EventLevel eventLevel) => IsEnabled(eventLevel, EventKeywords.All); | ||
|
||
[NonEvent] | ||
public void FailedToParseConnectionString(Exception ex) | ||
{ | ||
if (IsEnabled(EventLevel.Error)) | ||
{ | ||
FailedToParseConnectionString(ex.FlattenException().ToInvariantString()); | ||
} | ||
} | ||
|
||
[Event(1, Message = "Failed to parse ConnectionString due to an exception: {0}", Level = EventLevel.Error)] | ||
public void FailedToParseConnectionString(string exceptionMessage) => WriteEvent(1, exceptionMessage); | ||
|
||
[NonEvent] | ||
public void FailedToReadEnvironmentVariables(Exception ex) | ||
{ | ||
if (IsEnabled(EventLevel.Warning)) | ||
{ | ||
FailedToReadEnvironmentVariables(ex.FlattenException().ToInvariantString()); | ||
} | ||
} | ||
|
||
[Event(2, Message = "Failed to read environment variables due to an exception. This may prevent the Exporter from initializing. {0}", Level = EventLevel.Warning)] | ||
public void FailedToReadEnvironmentVariables(string errorMessage) => WriteEvent(2, errorMessage); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
sdk/monitor/Azure.Monitor.OpenTelemetry.LiveMetrics/src/Properties/AssemblyInfo.cs
This file contains 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("Azure.Monitor.OpenTelemetry.LiveMetrics.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] | ||
|
||
// Moq | ||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] |
25 changes: 25 additions & 0 deletions
25
...itor.OpenTelemetry.LiveMetrics.Tests/Azure.Monitor.OpenTelemetry.LiveMetrics.Tests.csproj
This file contains 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="xunit" /> | ||
<PackageReference Include="xunit.runner.visualstudio" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" /> | ||
<PackageReference Include="Moq" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="$(AzureCoreTestFramework)" /> | ||
<ProjectReference Include="..\..\src\Azure.Monitor.OpenTelemetry.LiveMetrics.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="..\..\..\Azure.Monitor.OpenTelemetry.Exporter\tests\Azure.Monitor.OpenTelemetry.Exporter.Tests\CommonTestFramework\EventSourceTestHelper.cs" LinkBase="CommonTestFramework" /> | ||
<Compile Include="..\..\..\Azure.Monitor.OpenTelemetry.Exporter\tests\Azure.Monitor.OpenTelemetry.Exporter.Tests\CommonTestFramework\TestEventListener.cs" LinkBase="CommonTestFramework" /> | ||
</ItemGroup> | ||
|
||
</Project> |
22 changes: 22 additions & 0 deletions
22
...ests/Azure.Monitor.OpenTelemetry.LiveMetrics.Tests/LiveMetricsExporterEventSourceTests.cs
This file contains 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using Azure.Monitor.OpenTelemetry.Exporter.Tests.CommonTestFramework; | ||
using Azure.Monitor.OpenTelemetry.LiveMetrics.Internals.Diagnostics; | ||
using Xunit; | ||
|
||
namespace Azure.Monitor.OpenTelemetry.LiveMetrics.Tests | ||
{ | ||
public class LiveMetricsExporterEventSourceTests | ||
{ | ||
/// <summary> | ||
/// This test uses reflection to invoke every Event method in our EventSource class. | ||
/// This validates that parameters are logged and helps to confirm that EventIds are correct. | ||
/// </summary> | ||
[Fact] | ||
public void EventSourceTest_LiveMetricsExporterEventSource() | ||
{ | ||
EventSourceTestHelper.MethodsAreImplementedConsistentlyWithTheirAttributes(LiveMetricsExporterEventSource.Log); | ||
} | ||
} | ||
} |
This file contains 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