Search in sources :

Example 51 with TelemetryItem

use of com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryItem in project ApplicationInsights-Java by microsoft.

the class QuickPulseDataCollectorTests method exceptionTelemetryIsCounted.

@Test
void exceptionTelemetryIsCounted() {
    TelemetryClient telemetryClient = TelemetryClient.createForTest();
    telemetryClient.setInstrumentationKey(FAKE_INSTRUMENTATION_KEY);
    QuickPulseDataCollector.INSTANCE.setQuickPulseStatus(QuickPulseStatus.QP_IS_ON);
    QuickPulseDataCollector.INSTANCE.enable(telemetryClient);
    TelemetryItem telemetry = createExceptionTelemetry(new Exception());
    telemetry.setInstrumentationKey(FAKE_INSTRUMENTATION_KEY);
    QuickPulseDataCollector.INSTANCE.add(telemetry);
    FinalCounters counters = QuickPulseDataCollector.INSTANCE.peek();
    assertThat(counters.exceptions).isEqualTo(1);
    telemetry = createExceptionTelemetry(new Exception());
    telemetry.setInstrumentationKey(FAKE_INSTRUMENTATION_KEY);
    QuickPulseDataCollector.INSTANCE.add(telemetry);
    counters = QuickPulseDataCollector.INSTANCE.getAndRestart();
    assertThat(counters.exceptions).isEqualTo(2);
    assertCountersReset(QuickPulseDataCollector.INSTANCE.peek());
}
Also used : TelemetryItem(com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryItem) FinalCounters(com.microsoft.applicationinsights.agent.internal.quickpulse.QuickPulseDataCollector.FinalCounters) TelemetryClient(com.microsoft.applicationinsights.agent.internal.telemetry.TelemetryClient) Test(org.junit.jupiter.api.Test)

Aggregations

TelemetryItem (com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryItem)51 Test (org.junit.jupiter.api.Test)13 ArrayList (java.util.ArrayList)9 CompletableResultCode (io.opentelemetry.sdk.common.CompletableResultCode)8 MetricsData (com.microsoft.applicationinsights.agent.internal.exporter.models.MetricsData)7 TelemetryClient (com.microsoft.applicationinsights.agent.internal.telemetry.TelemetryClient)7 HashMap (java.util.HashMap)7 MetricDataPoint (com.microsoft.applicationinsights.agent.internal.exporter.models.MetricDataPoint)6 MessageData (com.microsoft.applicationinsights.agent.internal.exporter.models.MessageData)5 TelemetryExceptionData (com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryExceptionData)4 RemoteDependencyData (com.microsoft.applicationinsights.agent.internal.exporter.models.RemoteDependencyData)3 RequestData (com.microsoft.applicationinsights.agent.internal.exporter.models.RequestData)3 TelemetryEventData (com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryEventData)3 FinalCounters (com.microsoft.applicationinsights.agent.internal.quickpulse.QuickPulseDataCollector.FinalCounters)3 Attributes (io.opentelemetry.api.common.Attributes)3 SemanticAttributes (io.opentelemetry.semconv.trace.attributes.SemanticAttributes)3 MemoryUsage (java.lang.management.MemoryUsage)3 Date (java.util.Date)3 HttpRequest (com.azure.core.http.HttpRequest)1 SerializedString (com.fasterxml.jackson.core.io.SerializedString)1