use of com.microsoft.applicationinsights.agent.internal.telemetry.TelemetryClient in project ApplicationInsights-Java by microsoft.
the class RpConfigurationPollingTest method shouldUpdate.
@Test
void shouldUpdate() throws URISyntaxException {
// given
RpConfiguration rpConfiguration = new RpConfiguration();
rpConfiguration.connectionString = "InstrumentationKey=11111111-1111-1111-1111-111111111111";
rpConfiguration.sampling.percentage = 90;
rpConfiguration.configPath = Paths.get(RpConfigurationPollingTest.class.getResource("/applicationinsights-rp.json").toURI());
rpConfiguration.lastModifiedTime = 0;
TelemetryClient telemetryClient = TelemetryClient.createForTest();
telemetryClient.setConnectionString("InstrumentationKey=00000000-0000-0000-0000-000000000000");
AppIdSupplier appIdSupplier = new AppIdSupplier(telemetryClient);
BytecodeUtilImpl.samplingPercentage = 100;
// pre-check
assertThat(telemetryClient.getInstrumentationKey()).isEqualTo("00000000-0000-0000-0000-000000000000");
assertThat(BytecodeUtilImpl.samplingPercentage).isEqualTo(100);
assertThat(getCurrentSamplingPercentage()).isEqualTo(100);
// when
new RpConfigurationPolling(rpConfiguration, new Configuration(), telemetryClient, appIdSupplier).run();
// then
assertThat(telemetryClient.getInstrumentationKey()).isEqualTo("00000000-0000-0000-0000-000000000000");
assertThat(BytecodeUtilImpl.samplingPercentage).isEqualTo(10);
assertThat(getCurrentSamplingPercentage()).isEqualTo(10);
}
use of com.microsoft.applicationinsights.agent.internal.telemetry.TelemetryClient in project ApplicationInsights-Java by microsoft.
the class RpConfigurationPollingTest method shouldBePopulatedByEnvVars.
@Test
void shouldBePopulatedByEnvVars() throws URISyntaxException {
// given
RpConfiguration rpConfiguration = new RpConfiguration();
rpConfiguration.connectionString = "InstrumentationKey=11111111-1111-1111-1111-111111111111";
rpConfiguration.sampling.percentage = 90;
rpConfiguration.configPath = Paths.get(RpConfigurationPollingTest.class.getResource("/applicationinsights-rp.json").toURI());
rpConfiguration.lastModifiedTime = 0;
TelemetryClient telemetryClient = TelemetryClient.createForTest();
telemetryClient.setConnectionString("InstrumentationKey=00000000-0000-0000-0000-000000000000");
AppIdSupplier appIdSupplier = new AppIdSupplier(telemetryClient);
BytecodeUtilImpl.samplingPercentage = 100;
envVars.set("APPLICATIONINSIGHTS_CONNECTION_STRING", "InstrumentationKey=00000000-0000-0000-0000-000000000000");
envVars.set("APPLICATIONINSIGHTS_SAMPLING_PERCENTAGE", "90");
// pre-check
assertThat(telemetryClient.getInstrumentationKey()).isEqualTo("00000000-0000-0000-0000-000000000000");
assertThat(BytecodeUtilImpl.samplingPercentage).isEqualTo(100);
assertThat(getCurrentSamplingPercentage()).isEqualTo(100);
// when
new RpConfigurationPolling(rpConfiguration, new Configuration(), telemetryClient, appIdSupplier).run();
// then
assertThat(telemetryClient.getInstrumentationKey()).isEqualTo("00000000-0000-0000-0000-000000000000");
assertThat(BytecodeUtilImpl.samplingPercentage).isEqualTo(100);
assertThat(getCurrentSamplingPercentage()).isEqualTo(100);
}
use of com.microsoft.applicationinsights.agent.internal.telemetry.TelemetryClient in project ApplicationInsights-Java by microsoft.
the class QuickPulseIntegrationTests method getQuickPulsePingSender.
private QuickPulsePingSender getQuickPulsePingSender() {
TelemetryClient telemetryClient = TelemetryClient.createForTest();
telemetryClient.setConnectionString(connectionString);
return new QuickPulsePingSender(getHttpPipeline(), telemetryClient, "machine1", "instance1", "qpid123");
}
use of com.microsoft.applicationinsights.agent.internal.telemetry.TelemetryClient in project ApplicationInsights-Java by microsoft.
the class QuickPulseIntegrationTests method getQuickPulsePingSenderWithValidator.
private QuickPulsePingSender getQuickPulsePingSenderWithValidator(HttpPipelinePolicy validator) {
TelemetryClient telemetryClient = TelemetryClient.createForTest();
telemetryClient.setConnectionString(connectionString);
return new QuickPulsePingSender(getHttpPipeline(validator), telemetryClient, "machine1", "instance1", "qpid123");
}
use of com.microsoft.applicationinsights.agent.internal.telemetry.TelemetryClient in project ApplicationInsights-Java by microsoft.
the class QuickPulsePingSenderTests method endpointChangesWithRedirectHeaderAndGetNewPingInterval.
@Test
void endpointChangesWithRedirectHeaderAndGetNewPingInterval() {
Map<String, String> headers = new HashMap<>();
headers.put("x-ms-qps-service-polling-interval-hint", "1000");
headers.put("x-ms-qps-service-endpoint-redirect", "https://new.endpoint.com");
headers.put("x-ms-qps-subscribed", "true");
HttpHeaders httpHeaders = new HttpHeaders(headers);
TelemetryClient telemetryClient = TelemetryClient.createForTest();
telemetryClient.setInstrumentationKey("fake-ikey");
HttpPipeline httpPipeline = new HttpPipelineBuilder().httpClient(request -> Mono.just(new MockHttpResponse(request, 200, httpHeaders))).build();
QuickPulsePingSender quickPulsePingSender = new QuickPulsePingSender(httpPipeline, telemetryClient, "machine1", "instance1", "qpid123");
QuickPulseHeaderInfo quickPulseHeaderInfo = quickPulsePingSender.ping(null);
assertThat(QuickPulseStatus.QP_IS_ON).isEqualTo(quickPulseHeaderInfo.getQuickPulseStatus());
assertThat(1000).isEqualTo(quickPulseHeaderInfo.getQpsServicePollingInterval());
assertThat("https://new.endpoint.com").isEqualTo(quickPulseHeaderInfo.getQpsServiceEndpointRedirect());
}
Aggregations