use of com.microsoft.applicationinsights.agent.internal.telemetry.TelemetryClient in project ApplicationInsights-Java by microsoft.
the class QuickPulsePingSenderTests method endpointIsFormattedCorrectlyWhenUsingConnectionString.
@Test
void endpointIsFormattedCorrectlyWhenUsingConnectionString() throws URISyntaxException {
TelemetryClient telemetryClient = TelemetryClient.createForTest();
telemetryClient.setConnectionString("InstrumentationKey=testing-123");
QuickPulsePingSender quickPulsePingSender = new QuickPulsePingSender(null, telemetryClient, null, null, null);
String quickPulseEndpoint = quickPulsePingSender.getQuickPulseEndpoint();
String endpointUrl = quickPulsePingSender.getQuickPulsePingUri(quickPulseEndpoint);
URI uri = new URI(endpointUrl);
assertThat(uri).isNotNull();
assertThat(endpointUrl).endsWith("/ping?ikey=testing-123");
assertThat(endpointUrl).isEqualTo("https://rt.services.visualstudio.com/QuickPulseService.svc/ping?ikey=testing-123");
}
use of com.microsoft.applicationinsights.agent.internal.telemetry.TelemetryClient in project ApplicationInsights-Java by microsoft.
the class QuickPulsePingSenderTests method endpointIsFormattedCorrectlyWhenUsingInstrumentationKey.
@Test
void endpointIsFormattedCorrectlyWhenUsingInstrumentationKey() throws URISyntaxException {
TelemetryClient telemetryClient = TelemetryClient.createForTest();
telemetryClient.setInstrumentationKey("A-test-instrumentation-key");
QuickPulsePingSender quickPulsePingSender = new QuickPulsePingSender(null, telemetryClient, null, null, null);
String quickPulseEndpoint = quickPulsePingSender.getQuickPulseEndpoint();
String endpointUrl = quickPulsePingSender.getQuickPulsePingUri(quickPulseEndpoint);
URI uri = new URI(endpointUrl);
assertThat(uri).isNotNull();
assertThat(endpointUrl).endsWith(// from resources/ApplicationInsights.xml
"/ping?ikey=A-test-instrumentation-key");
assertThat(endpointUrl).isEqualTo("https://rt.services.visualstudio.com/QuickPulseService.svc/ping?ikey=A-test-instrumentation-key");
}
use of com.microsoft.applicationinsights.agent.internal.telemetry.TelemetryClient in project ApplicationInsights-Java by microsoft.
the class QuickPulseDataCollectorTests method emptyCountsAndDurationsAfterEnable.
@Test
void emptyCountsAndDurationsAfterEnable() {
TelemetryClient telemetryClient = TelemetryClient.createForTest();
telemetryClient.setInstrumentationKey(FAKE_INSTRUMENTATION_KEY);
QuickPulseDataCollector.INSTANCE.enable(telemetryClient);
FinalCounters counters = QuickPulseDataCollector.INSTANCE.peek();
assertCountersReset(counters);
}
use of com.microsoft.applicationinsights.agent.internal.telemetry.TelemetryClient 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());
}
use of com.microsoft.applicationinsights.agent.internal.telemetry.TelemetryClient in project ApplicationInsights-Java by microsoft.
the class QuickPulseDataCollectorTests method nullCountersAfterDisable.
@Test
void nullCountersAfterDisable() {
TelemetryClient telemetryClient = TelemetryClient.createForTest();
telemetryClient.setInstrumentationKey(FAKE_INSTRUMENTATION_KEY);
QuickPulseDataCollector.INSTANCE.enable(telemetryClient);
QuickPulseDataCollector.INSTANCE.disable();
assertThat(QuickPulseDataCollector.INSTANCE.peek()).isNull();
}
Aggregations