Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<!-- Azure Monitor OpenTelemetry distro (stable) -->
<PackageVersion Include="Azure.Monitor.OpenTelemetry.AspNetCore" Version="1.5.0" />
<!-- Azure Monitor OTel Profiler (Preview/prerelease — pin exact version; review on every bump) -->
<PackageVersion Include="Azure.Monitor.OpenTelemetry.Profiler" Version="1.0.1-beta.1" />
<PackageVersion Include="Assent" Version="3.0.1" />
<PackageVersion Include="coverlet.collector" Version="10.0.0" />
<PackageVersion Include="AwesomeAssertions" Version="9.4.0" />
Expand Down
5 changes: 5 additions & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<add key="dotnet-libraries" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-libraries/nuget/v3/index.json" />
<add key="dotnet5" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json" />
<add key="MachineLearning" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/MachineLearning/nuget/v3/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
<disabledPackageSources>
<clear />
Expand All @@ -25,5 +26,9 @@
<packageSource key="dotnet-eng">
<package pattern="*" />
</packageSource>
<packageSource key="nuget.org">
<package pattern="Azure.Monitor.*" />
<package pattern="OpenTelemetry.*" />
</packageSource>
</packageSourceMapping>
</configuration>
2 changes: 2 additions & 0 deletions src/Microsoft.TryDotNet/Microsoft.TryDotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Monitor.OpenTelemetry.AspNetCore" />
<PackageReference Include="Azure.Monitor.OpenTelemetry.Profiler" />
<PackageReference Include="AwesomeAssertions" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" />
<PackageReference Include="Microsoft.DotNet.Interactive.CSharpProject" />
Expand Down
18 changes: 18 additions & 0 deletions src/Microsoft.TryDotNet/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using System.Reflection;
using System.Text;
using System.Text.Json;
using Azure.Monitor.OpenTelemetry.AspNetCore;
using Azure.Monitor.OpenTelemetry.Profiler;
using Microsoft.DotNet.Interactive;
using Microsoft.DotNet.Interactive.Connection;
using Microsoft.DotNet.Interactive.CSharpProject;
Expand All @@ -22,13 +24,22 @@ namespace Microsoft.TryDotNet;

public class Program
{
private const string AppInsightsConnectionStringEnvVar = "APPLICATIONINSIGHTS_CONNECTION_STRING";

private static Prebuild? _consolePrebuild;
private static bool _loggingEnabled;

public static async Task Main(string[] args)
{
StartLogging();

if (string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable(AppInsightsConnectionStringEnvVar)))
{
Console.WriteLine(
$"WARNING: {AppInsightsConnectionStringEnvVar} is not set. " +
"Application Insights telemetry and Profiler will be inactive.");
}

await EnsurePrebuildIsReadyAsync();

var app = await CreateWebApplicationAsync(new WebApplicationOptions { Args = args });
Expand Down Expand Up @@ -64,6 +75,13 @@ public static async Task<WebApplication> CreateWebApplicationAsync(WebApplicatio
});
});

if (!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable(AppInsightsConnectionStringEnvVar)))
{
builder.Services.AddOpenTelemetry()
.UseAzureMonitor()
.AddAzureMonitorProfiler();
}

builder.Services.AddResponseCompression(compressionOptions =>
{
compressionOptions.EnableForHttps = true;
Expand Down
7 changes: 7 additions & 0 deletions src/Microsoft.TryDotNet/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
},
"OpenTelemetry": {
"LogLevel": {
"Default": "Warning",
"Azure.Monitor.OpenTelemetry.Profiler": "Information",
"Microsoft.ServiceProfiler": "Information"
}
}
},
"AllowedHosts": "*"
Expand Down
Loading