Skip to content

Commit 9fdc73e

Browse files
authored
Emit Profiler start/stop events (#1706)
1 parent 5038420 commit 9fdc73e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

core/src/main/java/com/microsoft/applicationinsights/internal/profiler/ProfilerServiceInitializer.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import com.microsoft.applicationinsights.profiler.config.AlertConfigParser;
3434
import com.microsoft.applicationinsights.profiler.config.ServiceProfilerServiceConfig;
3535
import com.microsoft.applicationinsights.telemetry.EventTelemetry;
36+
import com.microsoft.applicationinsights.telemetry.TraceTelemetry;
3637
import org.apache.http.impl.client.CloseableHttpClient;
3738
import org.slf4j.Logger;
3839
import org.slf4j.LoggerFactory;
@@ -162,19 +163,23 @@ static UploadCompleteHandler sendServiceProfilerIndex(TelemetryClient telemetryC
162163
event.getProperties().putAll(done.getServiceProfilerIndex().getProperties());
163164
event.getMetrics().putAll(done.getServiceProfilerIndex().getMetrics());
164165
telemetryClient.track(event);
166+
// This is an event that the backend specifically looks for to track when a profile is complete
167+
telemetryClient.track(new TraceTelemetry("StopProfiler succeeded."));
165168
};
166169
}
167170

168171
static AlertingSubsystem createAlertMonitor(
169172
ScheduledExecutorService alertServiceExecutorService,
170173
TelemetryClient telemetryClient,
171174
GcEventMonitor.GcEventMonitorConfiguration gcEventMonitorConfiguration) {
172-
return AlertingServiceFactory.create(alertAction(), TelemetryObservers.INSTANCE, telemetryClient, alertServiceExecutorService, gcEventMonitorConfiguration);
175+
return AlertingServiceFactory.create(alertAction(telemetryClient), TelemetryObservers.INSTANCE, telemetryClient, alertServiceExecutorService, gcEventMonitorConfiguration);
173176
}
174177

175-
private static Consumer<AlertBreach> alertAction() {
178+
private static Consumer<AlertBreach> alertAction(TelemetryClient telemetryClient) {
176179
return alert -> {
177180
if (profilerService != null) {
181+
// This is an event that the backend specifically looks for to track when a profile is started
182+
telemetryClient.track(new TraceTelemetry("StartProfiler triggered."));
178183
profilerService.getProfiler().accept(alert);
179184
}
180185
};

0 commit comments

Comments
 (0)