From 7304a19863c750ee7348d4477a9178de3ad20c27 Mon Sep 17 00:00:00 2001 From: "Calvin A. Allen" Date: Tue, 6 Jan 2026 09:40:28 -0500 Subject: [PATCH 1/2] feat(telemetry): add Otel4Vsix integration - Add CodingWithCalvin.Otel4Vsix package reference - Configure telemetry in OpenBinFolderPackage with Honeycomb export - Add HoneycombConfig.cs for API key placeholder - Instrument OpenPath and OpenProjectBinFolder with activities - Add proper telemetry shutdown in Dispose - Remove explicit DeployExtension (VsixSdk handles this) --- .../CodingWithCalvin.OpenBinFolder.csproj | 5 +- .../Commands/OpenBinFolderCommand.cs | 87 +++++++++++++------ .../HoneycombConfig.cs | 7 ++ .../OpenBinFolderPackage.cs | 27 +++++- 4 files changed, 94 insertions(+), 32 deletions(-) create mode 100644 src/CodingWithCalvin.OpenBinFolder/HoneycombConfig.cs diff --git a/src/CodingWithCalvin.OpenBinFolder/CodingWithCalvin.OpenBinFolder.csproj b/src/CodingWithCalvin.OpenBinFolder/CodingWithCalvin.OpenBinFolder.csproj index 8fac116..ad1664e 100644 --- a/src/CodingWithCalvin.OpenBinFolder/CodingWithCalvin.OpenBinFolder.csproj +++ b/src/CodingWithCalvin.OpenBinFolder/CodingWithCalvin.OpenBinFolder.csproj @@ -8,11 +8,8 @@ bin/$(Configuration)/ - - True - - + diff --git a/src/CodingWithCalvin.OpenBinFolder/Commands/OpenBinFolderCommand.cs b/src/CodingWithCalvin.OpenBinFolder/Commands/OpenBinFolderCommand.cs index 0779eb6..0fca304 100644 --- a/src/CodingWithCalvin.OpenBinFolder/Commands/OpenBinFolderCommand.cs +++ b/src/CodingWithCalvin.OpenBinFolder/Commands/OpenBinFolderCommand.cs @@ -1,7 +1,9 @@ -using System; +using System; +using System.Collections.Generic; using System.ComponentModel.Design; using System.IO; using System.Windows.Forms; +using CodingWithCalvin.Otel4Vsix; using EnvDTE; using EnvDTE80; using Microsoft.VisualStudio.Shell; @@ -44,39 +46,48 @@ private void OpenPath(object sender, EventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); - if (!(ServiceProvider.GetService(typeof(DTE)) is DTE2 dte)) - { - throw new ArgumentNullException(nameof(dte)); - } + using var activity = VsixTelemetry.StartCommandActivity("OpenBinFolder.OpenPath"); - foreach ( - UIHierarchyItem selectedItem in (Array) - dte.ToolWindows.SolutionExplorer.SelectedItems - ) + try { - switch (selectedItem.Object) + if (!(ServiceProvider.GetService(typeof(DTE)) is DTE2 dte)) + { + throw new ArgumentNullException(nameof(dte)); + } + + foreach ( + UIHierarchyItem selectedItem in (Array) + dte.ToolWindows.SolutionExplorer.SelectedItems + ) { - case Project project: - try - { + switch (selectedItem.Object) + { + case Project project: OpenProjectBinFolder(project); - } - catch (Exception ex) - { - MessageBox.Show( - $@" - Unable to determine output path for selected project - {Environment.NewLine} - {Environment.NewLine} - Exception: {ex.Message}" - ); - } - - break; + break; + } } + + VsixTelemetry.LogInformation("Bin folder opened successfully"); } + catch (Exception ex) + { + activity?.RecordError(ex); + VsixTelemetry.TrackException(ex, new Dictionary + { + { "operation.name", "OpenPath" } + }); + throw; + } + } - void OpenProjectBinFolder(Project project) + private void OpenProjectBinFolder(Project project) + { + ThreadHelper.ThrowIfNotOnUIThread(); + + using var activity = VsixTelemetry.StartCommandActivity("OpenBinFolder.OpenProjectBinFolder"); + + try { var projectPath = Path.GetDirectoryName(project.FullName) @@ -88,9 +99,31 @@ void OpenProjectBinFolder(Project project) var projectBinPath = Path.Combine(projectPath, projectOutputPath); + activity?.SetTag("project.name", project.Name); + activity?.SetTag("project.binPath", projectBinPath); + System.Diagnostics.Process.Start( Directory.Exists(projectBinPath) ? projectBinPath : projectPath ); + + VsixTelemetry.LogInformation("Opened bin folder for project {ProjectName}", project.Name); + } + catch (Exception ex) + { + activity?.RecordError(ex); + VsixTelemetry.TrackException(ex, new Dictionary + { + { "operation.name", "OpenProjectBinFolder" }, + { "project.name", project.Name } + }); + + MessageBox.Show( + $@" + Unable to determine output path for selected project + {Environment.NewLine} + {Environment.NewLine} + Exception: {ex.Message}" + ); } } } diff --git a/src/CodingWithCalvin.OpenBinFolder/HoneycombConfig.cs b/src/CodingWithCalvin.OpenBinFolder/HoneycombConfig.cs new file mode 100644 index 0000000..3271e46 --- /dev/null +++ b/src/CodingWithCalvin.OpenBinFolder/HoneycombConfig.cs @@ -0,0 +1,7 @@ +namespace CodingWithCalvin.OpenBinFolder +{ + internal static class HoneycombConfig + { + public const string ApiKey = "PLACEHOLDER"; + } +} diff --git a/src/CodingWithCalvin.OpenBinFolder/OpenBinFolderPackage.cs b/src/CodingWithCalvin.OpenBinFolder/OpenBinFolderPackage.cs index dfb6e59..3504c88 100644 --- a/src/CodingWithCalvin.OpenBinFolder/OpenBinFolderPackage.cs +++ b/src/CodingWithCalvin.OpenBinFolder/OpenBinFolderPackage.cs @@ -1,7 +1,8 @@ -using System; +using System; using System.Runtime.InteropServices; using System.Threading; using CodingWithCalvin.OpenBinFolder.Commands; +using CodingWithCalvin.Otel4Vsix; using Microsoft.VisualStudio.Shell; 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(); + OpenBinFolderCommand.Initialize(this); } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + VsixTelemetry.Shutdown(); + } + + base.Dispose(disposing); + } } } From 3f1f9681ad928b1e1d22763e80d75116613e2b7f Mon Sep 17 00:00:00 2001 From: "Calvin A. Allen" Date: Tue, 6 Jan 2026 10:54:00 -0500 Subject: [PATCH 2/2] fix(telemetry): remove sensitive data from telemetry Remove project names and file paths from telemetry tags and logs to avoid sending potentially sensitive information. --- .../Commands/OpenBinFolderCommand.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/CodingWithCalvin.OpenBinFolder/Commands/OpenBinFolderCommand.cs b/src/CodingWithCalvin.OpenBinFolder/Commands/OpenBinFolderCommand.cs index 0fca304..f0807f0 100644 --- a/src/CodingWithCalvin.OpenBinFolder/Commands/OpenBinFolderCommand.cs +++ b/src/CodingWithCalvin.OpenBinFolder/Commands/OpenBinFolderCommand.cs @@ -99,14 +99,11 @@ private void OpenProjectBinFolder(Project project) var projectBinPath = Path.Combine(projectPath, projectOutputPath); - activity?.SetTag("project.name", project.Name); - activity?.SetTag("project.binPath", projectBinPath); - - System.Diagnostics.Process.Start( + System.Diagnostics.Process.Start( Directory.Exists(projectBinPath) ? projectBinPath : projectPath ); - VsixTelemetry.LogInformation("Opened bin folder for project {ProjectName}", project.Name); + VsixTelemetry.LogInformation("Opened bin folder for project"); } catch (Exception ex) { @@ -114,8 +111,7 @@ private void OpenProjectBinFolder(Project project) VsixTelemetry.TrackException(ex, new Dictionary { { "operation.name", "OpenProjectBinFolder" }, - { "project.name", project.Name } - }); + }); MessageBox.Show( $@"