Skip to content

Commit 4325c06

Browse files
committed
app insights debugging 5
1 parent 753df61 commit 4325c06

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

‎src/PerfProblemSimulator/Controllers/AdminController.cs‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,20 +148,34 @@ public IActionResult TestAppInsights()
148148
{
149149
try
150150
{
151-
_telemetryClient.TrackEvent("TestEvent", new Dictionary<string, string>
151+
// Try simplest possible TrackEvent first (no properties)
152+
_telemetryClient.TrackEvent("TestEvent_Simple");
153+
diagnostics.TestEventSent = true;
154+
155+
// Now try with properties
156+
var props = new Dictionary<string, string>
152157
{
153158
["TestId"] = testId.ToString(),
154-
["Source"] = "AdminController.TestAppInsights"
155-
});
159+
["Source"] = "AdminController"
160+
};
161+
_telemetryClient.TrackEvent("TestEvent_WithProps", props);
162+
163+
// Also try TrackTrace
164+
_telemetryClient.TrackTrace($"TestTrace - TestId: {testId}");
165+
156166
_telemetryClient.Flush();
157167
Thread.Sleep(500);
158168

159-
diagnostics.TestEventSent = true;
160-
_logger.LogWarning("🧪 TEST EVENT sent - TestId: {TestId}", testId);
169+
_logger.LogWarning("🧪 TEST EVENTS sent - TestId: {TestId}", testId);
161170
}
162171
catch (Exception ex)
163172
{
164-
diagnostics.Error = $"TrackEvent threw: {ex.Message}";
173+
diagnostics.Error = $"Telemetry threw: {ex.GetType().Name}: {ex.Message}";
174+
// Include inner exception if present
175+
if (ex.InnerException != null)
176+
{
177+
diagnostics.Error += $" Inner: {ex.InnerException.Message}";
178+
}
165179
}
166180
}
167181
else

0 commit comments

Comments
 (0)