diff --git a/src/CodingWithCalvin.BreakpointNotifier/BreakpointNotifierPackage.cs b/src/CodingWithCalvin.BreakpointNotifier/BreakpointNotifierPackage.cs index 918230a..0f5b765 100644 --- a/src/CodingWithCalvin.BreakpointNotifier/BreakpointNotifierPackage.cs +++ b/src/CodingWithCalvin.BreakpointNotifier/BreakpointNotifierPackage.cs @@ -1,6 +1,7 @@ -using System; +using System; using System.Runtime.InteropServices; using System.Threading; +using CodingWithCalvin.Otel4Vsix; using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Shell.Interop; using Task = System.Threading.Tasks.Task; @@ -20,7 +21,31 @@ IProgress progress { await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); + var builder = VsixTelemetry.Configure() + .WithServiceName(VsixInfo.DisplayName) + .WithServiceVersion(VsixInfo.Version) + .WithVisualStudioAttributes(this) + .WithEnvironmentAttributes(); + +#if !DEBUG + builder + .WithOtlpHttp("https://api.honeycomb.io") + .WithHeader("x-honeycomb-team", HoneycombConfig.ApiKey); +#endif + + builder.Initialize(); + DebuggerEvents.Initialize(); } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + VsixTelemetry.Shutdown(); + } + + base.Dispose(disposing); + } } } diff --git a/src/CodingWithCalvin.BreakpointNotifier/CodingWithCalvin.BreakpointNotifier.csproj b/src/CodingWithCalvin.BreakpointNotifier/CodingWithCalvin.BreakpointNotifier.csproj index d070a83..edfe429 100644 --- a/src/CodingWithCalvin.BreakpointNotifier/CodingWithCalvin.BreakpointNotifier.csproj +++ b/src/CodingWithCalvin.BreakpointNotifier/CodingWithCalvin.BreakpointNotifier.csproj @@ -8,11 +8,8 @@ bin/$(Configuration)/ - - True - - + diff --git a/src/CodingWithCalvin.BreakpointNotifier/DebuggerEvents.cs b/src/CodingWithCalvin.BreakpointNotifier/DebuggerEvents.cs index c82cb5c..f87578e 100644 --- a/src/CodingWithCalvin.BreakpointNotifier/DebuggerEvents.cs +++ b/src/CodingWithCalvin.BreakpointNotifier/DebuggerEvents.cs @@ -1,5 +1,7 @@ -using System; +using System; +using System.Collections.Generic; using System.Windows.Forms; +using CodingWithCalvin.Otel4Vsix; using Microsoft; using Microsoft.VisualStudio; using Microsoft.VisualStudio.Debugger.Interop; @@ -28,8 +30,7 @@ public static DebuggerEvents Initialize() public int OnModeChange(DBGMODE dbgmodeNew) { - // No longer showing message here - we use IDebugEventCallback2 instead - // to specifically detect breakpoint hits vs. step operations + VsixTelemetry.LogInformation("Debugger mode changed to {Mode}", dbgmodeNew.ToString()); return VSConstants.S_OK; } @@ -44,7 +45,21 @@ public int Event( { if (pEvent is IDebugBreakpointEvent2) { - MessageBox.Show("Breakpoint Hit!"); + using var activity = VsixTelemetry.StartCommandActivity("BreakpointNotifier.BreakpointHit"); + + try + { + VsixTelemetry.LogInformation("Breakpoint hit detected"); + MessageBox.Show("Breakpoint Hit!"); + } + catch (Exception ex) + { + activity?.RecordError(ex); + VsixTelemetry.TrackException(ex, new Dictionary + { + { "operation.name", "BreakpointHit" } + }); + } } return VSConstants.S_OK; diff --git a/src/CodingWithCalvin.BreakpointNotifier/HoneycombConfig.cs b/src/CodingWithCalvin.BreakpointNotifier/HoneycombConfig.cs new file mode 100644 index 0000000..118e354 --- /dev/null +++ b/src/CodingWithCalvin.BreakpointNotifier/HoneycombConfig.cs @@ -0,0 +1,7 @@ +namespace CodingWithCalvin.BreakpointNotifier +{ + internal static class HoneycombConfig + { + public const string ApiKey = "PLACEHOLDER"; + } +}