Skip to content

Commit 76839dc

Browse files
authored
feat(telemetry): add Otel4Vsix integration (#22)
- Add CodingWithCalvin.Otel4Vsix package reference - Configure telemetry in BreakpointNotifierPackage with Honeycomb export - Add HoneycombConfig.cs for API key placeholder - Instrument debugger events with activities and logging - Add proper telemetry shutdown in Dispose - Remove explicit DeployExtension (VsixSdk handles this)
1 parent 44cbd37 commit 76839dc

4 files changed

Lines changed: 53 additions & 9 deletions

File tree

src/CodingWithCalvin.BreakpointNotifier/BreakpointNotifierPackage.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
using System;
1+
using System;
22
using System.Runtime.InteropServices;
33
using System.Threading;
4+
using CodingWithCalvin.Otel4Vsix;
45
using Microsoft.VisualStudio.Shell;
56
using Microsoft.VisualStudio.Shell.Interop;
67
using Task = System.Threading.Tasks.Task;
@@ -20,7 +21,31 @@ IProgress<ServiceProgressData> progress
2021
{
2122
await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
2223

24+
var builder = VsixTelemetry.Configure()
25+
.WithServiceName(VsixInfo.DisplayName)
26+
.WithServiceVersion(VsixInfo.Version)
27+
.WithVisualStudioAttributes(this)
28+
.WithEnvironmentAttributes();
29+
30+
#if !DEBUG
31+
builder
32+
.WithOtlpHttp("https://api.honeycomb.io")
33+
.WithHeader("x-honeycomb-team", HoneycombConfig.ApiKey);
34+
#endif
35+
36+
builder.Initialize();
37+
2338
DebuggerEvents.Initialize();
2439
}
40+
41+
protected override void Dispose(bool disposing)
42+
{
43+
if (disposing)
44+
{
45+
VsixTelemetry.Shutdown();
46+
}
47+
48+
base.Dispose(disposing);
49+
}
2550
}
2651
}

src/CodingWithCalvin.BreakpointNotifier/CodingWithCalvin.BreakpointNotifier.csproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@
88
<OutputPath>bin/$(Configuration)/</OutputPath>
99
</PropertyGroup>
1010

11-
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
12-
<DeployExtension>True</DeployExtension>
13-
</PropertyGroup>
14-
1511
<ItemGroup>
12+
<PackageReference Include="CodingWithCalvin.Otel4Vsix" Version="0.2.2" />
1613
<PackageReference Include="Microsoft.VisualStudio.SDK" Version="17.14.40265" />
1714
</ItemGroup>
1815

src/CodingWithCalvin.BreakpointNotifier/DebuggerEvents.cs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
using System;
1+
using System;
2+
using System.Collections.Generic;
23
using System.Windows.Forms;
4+
using CodingWithCalvin.Otel4Vsix;
35
using Microsoft;
46
using Microsoft.VisualStudio;
57
using Microsoft.VisualStudio.Debugger.Interop;
@@ -28,8 +30,7 @@ public static DebuggerEvents Initialize()
2830

2931
public int OnModeChange(DBGMODE dbgmodeNew)
3032
{
31-
// No longer showing message here - we use IDebugEventCallback2 instead
32-
// to specifically detect breakpoint hits vs. step operations
33+
VsixTelemetry.LogInformation("Debugger mode changed to {Mode}", dbgmodeNew.ToString());
3334
return VSConstants.S_OK;
3435
}
3536

@@ -44,7 +45,21 @@ public int Event(
4445
{
4546
if (pEvent is IDebugBreakpointEvent2)
4647
{
47-
MessageBox.Show("Breakpoint Hit!");
48+
using var activity = VsixTelemetry.StartCommandActivity("BreakpointNotifier.BreakpointHit");
49+
50+
try
51+
{
52+
VsixTelemetry.LogInformation("Breakpoint hit detected");
53+
MessageBox.Show("Breakpoint Hit!");
54+
}
55+
catch (Exception ex)
56+
{
57+
activity?.RecordError(ex);
58+
VsixTelemetry.TrackException(ex, new Dictionary<string, object>
59+
{
60+
{ "operation.name", "BreakpointHit" }
61+
});
62+
}
4863
}
4964

5065
return VSConstants.S_OK;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace CodingWithCalvin.BreakpointNotifier
2+
{
3+
internal static class HoneycombConfig
4+
{
5+
public const string ApiKey = "PLACEHOLDER";
6+
}
7+
}

0 commit comments

Comments
 (0)