add aspire for otel

This commit is contained in:
Matt Parker
2025-09-29 19:07:38 +10:00
parent b7029e7dce
commit e0ddcc55f2
16 changed files with 358 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
using Ardalis.GuardClauses;
using System.Diagnostics;
using Ardalis.GuardClauses;
using Microsoft.VisualStudio.SolutionPersistence.Model;
using Microsoft.VisualStudio.SolutionPersistence.Serializer;
@@ -9,6 +10,7 @@ public static class IntermediateMapper
internal static async Task<IntermediateSolutionModel> GetIntermediateModel(string solutionFilePath,
CancellationToken cancellationToken = default)
{
using var _ = SharpIdeOtel.Source.StartActivity();
var serializer = SolutionSerializers.GetSerializerByMoniker(solutionFilePath);
Guard.Against.Null(serializer, nameof(serializer));
var vsSolution = await serializer.OpenAsync(solutionFilePath, cancellationToken);

View File

@@ -6,6 +6,7 @@ public static class VsPersistenceMapper
{
public static async Task<SharpIdeSolutionModel> GetSolutionModel(string solutionFilePath, CancellationToken cancellationToken = default)
{
using var _ = SharpIdeOtel.Source.StartActivity();
var timer = Stopwatch.StartNew();
// This intermediate model is pretty much useless, but I have left it around as we grab the project nodes with it, which we might use later.
var intermediateModel = await IntermediateMapper.GetIntermediateModel(solutionFilePath, cancellationToken);

View File

@@ -0,0 +1,10 @@
using System.Diagnostics;
using System.Diagnostics.Metrics;
namespace SharpIDE.Application;
public static class SharpIdeOtel
{
public static readonly ActivitySource Source = new("SharpIde");
public static readonly Meter Meter = new("SharpIde");
}