Add ILogger and OTEL
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Features" Version="5.3.0-1.25521.106" />
|
||||
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="5.3.0-1.25521.106" />
|
||||
<PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="10.0.0-rc.2.25502.107" />
|
||||
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="10.0.0-rc.2.25502.107" />
|
||||
<PackageVersion Include="Microsoft.Extensions.ObjectPool" Version="8.0.0" />
|
||||
<PackageVersion Include="Microsoft.AspNetCore.Razor.Utilities.Shared" Version="10.0.0-preview.25521.106" />
|
||||
<PackageVersion Include="Microsoft.CodeAnalysis.Features" Version="5.3.0-1.25521.106" />
|
||||
@@ -58,4 +59,4 @@
|
||||
<PackageVersion Include="Microsoft.CodeAnalysis.ExternalAccess.Razor.Features" Version="5.3.0-1.25521.106" />
|
||||
<PackageVersion Include="Microsoft.CodeAnalysis.Remote.ServiceHub" Version="5.3.0-1.25521.106" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -15,6 +15,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
||||
Directory.Packages.props = Directory.Packages.props
|
||||
NotesToUsers.md = NotesToUsers.md
|
||||
.globalconfig = .globalconfig
|
||||
nuget.config = nuget.config
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpIDE.Photino", "src\SharpIDE.Photino\SharpIDE.Photino.csproj", "{E35167E1-0FF4-4194-97A8-CC95EDA224CD}"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<add key="roslyn-compiler" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" />
|
||||
<add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" />
|
||||
<add key="ide-services" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vssdk/nuget/v3/index.json" />
|
||||
<add key="msft_consumption" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/msft_consumption/nuget/v3/index.json" />
|
||||
<!-- <add key="msft_consumption" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/msft_consumption/nuget/v3/index.json" /> -->
|
||||
<add key="vs_impl" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vs-impl/nuget/v3/index.json" />
|
||||
</packageSources>
|
||||
</configuration>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using Godot;
|
||||
using System.Reflection;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SharpIDE.Application.Features.Analysis;
|
||||
using SharpIDE.Application.Features.Build;
|
||||
using SharpIDE.Application.Features.FilePersistence;
|
||||
@@ -33,6 +35,16 @@ public partial class DiAutoload : Node
|
||||
services.AddScoped<RoslynAnalysis>();
|
||||
services.AddScoped<IdeFileOperationsService>();
|
||||
services.AddScoped<SharpIdeSolutionModificationService>();
|
||||
services.AddLogging(builder =>
|
||||
{
|
||||
builder.AddConsole();
|
||||
builder.AddOpenTelemetry(logging =>
|
||||
{
|
||||
logging.IncludeFormattedMessage = true;
|
||||
logging.IncludeScopes = true;
|
||||
});
|
||||
});
|
||||
services.AddGodotOpenTelemetry();
|
||||
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
GetTree().NodeAdded += OnNodeAdded;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<ProjectReference Include="..\SharpIDE.Application\SharpIDE.Application.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" />
|
||||
<PackageReference Include="ObservableCollections" />
|
||||
<PackageReference Include="ObservableCollections.R3" />
|
||||
<PackageReference Include="R3" />
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using OpenTelemetry;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using OpenTelemetry;
|
||||
using OpenTelemetry.Metrics;
|
||||
using OpenTelemetry.Resources;
|
||||
using OpenTelemetry.Trace;
|
||||
|
||||
namespace Microsoft.Extensions.Hosting;
|
||||
@@ -17,12 +17,9 @@ public static class GodotServiceDefaults
|
||||
Console.WriteLine("OTEL_EXPORTER_OTLP_ENDPOINT is not set, skipping OpenTelemetry setup.");
|
||||
return;
|
||||
}
|
||||
var endpointUri = new Uri(endpoint!);
|
||||
var resource = ResourceBuilder.CreateDefault()
|
||||
.AddService("sharpide-godot");
|
||||
var endpointUri = new Uri(endpoint);
|
||||
|
||||
_tracerProvider = Sdk.CreateTracerProviderBuilder()
|
||||
.SetResourceBuilder(resource)
|
||||
.AddSource("SharpIde")
|
||||
.AddOtlpExporter(options =>
|
||||
{
|
||||
@@ -32,7 +29,6 @@ public static class GodotServiceDefaults
|
||||
.Build();
|
||||
|
||||
_meterProvider = Sdk.CreateMeterProviderBuilder()
|
||||
.SetResourceBuilder(resource)
|
||||
.AddMeter("SharpIde")
|
||||
.AddRuntimeInstrumentation()
|
||||
.AddOtlpExporter(options =>
|
||||
@@ -42,4 +38,19 @@ public static class GodotServiceDefaults
|
||||
})
|
||||
.Build();
|
||||
}
|
||||
|
||||
public static void AddGodotOpenTelemetry(this IServiceCollection services)
|
||||
{
|
||||
services.AddOpenTelemetry();
|
||||
services.AddOpenTelemetryExporters();
|
||||
}
|
||||
|
||||
private static void AddOpenTelemetryExporters(this IServiceCollection services)
|
||||
{
|
||||
var useOtlpExporter = !string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("OTEL_EXPORTER_OTLP_ENDPOINT"));
|
||||
if (useOtlpExporter)
|
||||
{
|
||||
services.AddOpenTelemetry().UseOtlpExporter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user