/** * Constructs new telemetry client proxy instance. * @param instrumentationKey The instrumentation key for sending the events. */ public LogTelemetryClientProxy(String instrumentationKey) { this(new TelemetryClient(), instrumentationKey); }
/** * Constructs new telemetry client proxy instance. * @param instrumentationKey The instrumentation key for sending the events. */ public LogTelemetryClientProxy(String instrumentationKey) { this(new TelemetryClient(), instrumentationKey); }
/** * Constructs new telemetry client proxy instance. * @param instrumentationKey The instrumentation key for sending the events. */ public LogTelemetryClientProxy(String instrumentationKey) { this(new TelemetryClient(), instrumentationKey); }
public AppInsightsProxy(final TelemetryConfiguration config) { // InstrumentationKey will be read from ApplicationInsights.xml client = new TelemetryClient(); if (config == null) { throw new NullPointerException(); } configuration = config; defaultProperties = configuration.getTelemetryProperties(); }
public TelemetryTracker() { this.client = new TelemetryClient(); this.properties = new HashMap<>(); this.properties.put(PROPERTY_VERSION, PROJECT_INFO); this.properties.put(PROPERTY_INSTALLATION_ID, getHashMac()); }
public AppInsightsProxy(final TelemetryConfiguration config) { // InstrumentationKey will be read from ApplicationInsights.xml client = new TelemetryClient(); if (config == null) { throw new NullPointerException(); } configuration = config; defaultProperties = configuration.getTelemetryProperties(); }
private static TelemetryClient buildTelemetryClient(String instrumentationKey) { TelemetryClient client = new TelemetryClient(); if (!isValid(instrumentationKey)) { log.warn("Telemetry instrumentationKey {} is invalid", instrumentationKey); throw new IllegalArgumentException("Telemetry instrumentationKey is invalid"); } client.getContext().setInstrumentationKey(instrumentationKey); return client; }
private static TelemetryClient buildTelemetryClient(String instrumentationKey) { TelemetryClient client = new TelemetryClient(); if (!isValid(instrumentationKey)) { log.warn("Telemetry instrumentationKey {} is invalid", instrumentationKey); throw new IllegalArgumentException("Telemetry instrumentationKey is invalid"); } client.getContext().setInstrumentationKey(instrumentationKey); return client; }
@Test public void testMethodsOnTelemetryAreCalledWhenTracking() { TelemetryChannel mockChannel = Mockito.mock(TelemetryChannel.class); configuration.setChannel(mockChannel); TelemetryContext mockContext = new TelemetryContext(); Telemetry mockTelemetry = Mockito.mock(Telemetry.class); Mockito.doReturn(mockContext).when(mockTelemetry).getContext(); TelemetryClient telemetryClient = new TelemetryClient(configuration); telemetryClient.track(mockTelemetry); Mockito.verify(mockChannel, Mockito.times(1)).send(mockTelemetry); Mockito.verify(mockTelemetry, Mockito.times(1)).setTimestamp(any(Date.class)); }
@Test public void performanceCounterTelemetryIsNotSubjectToSampling() { List<Telemetry> dependencyTelemetry = getListOfTelemetry("com.microsoft.applicationinsights.telemetry.PerformanceCounterTelemetry",100); List<Telemetry> itemsToSend = new ArrayList<Telemetry>(); List<List<Telemetry>> telemetryListCollection = new ArrayList<List<Telemetry>>(); telemetryListCollection.add(dependencyTelemetry); TelemetryConfiguration configuration = createConfiguration(itemsToSend); TelemetryClient client = new TelemetryClient(configuration); testNoSampling(client, telemetryListCollection, itemsToSend, null, null, 10.0); }
@Test public void sessionStateTelemetryIsNotSubjectToSampling() { List<Telemetry> dependencyTelemetry = getListOfTelemetry("com.microsoft.applicationinsights.telemetry.SessionStateTelemetry",100); List<Telemetry> itemsToSend = new ArrayList<Telemetry>(); List<List<Telemetry>> telemetryListCollection = new ArrayList<List<Telemetry>>(); telemetryListCollection.add(dependencyTelemetry); TelemetryConfiguration configuration = createConfiguration(itemsToSend); TelemetryClient client = new TelemetryClient(configuration); testNoSampling(client, telemetryListCollection, itemsToSend, null, null, 10.0); }
@Test public void metricTelemetryIsNotSubjectToSampling() { List<Telemetry> dependencyTelemetry = getListOfTelemetry("com.microsoft.applicationinsights.telemetry.MetricTelemetry",100); List<Telemetry> itemsToSend = new ArrayList<Telemetry>(); List<List<Telemetry>> telemetryListCollection = new ArrayList<List<Telemetry>>(); telemetryListCollection.add(dependencyTelemetry); TelemetryConfiguration configuration = createConfiguration(itemsToSend); TelemetryClient client = new TelemetryClient(configuration); testNoSampling(client, telemetryListCollection, itemsToSend, null, null, 10.0); }
@Test public void dependencyCanBeExcludedFromSampling() { List<Telemetry> dependencyTelemetry = getListOfTelemetry("com.microsoft.applicationinsights.telemetry.RemoteDependencyTelemetry",100); List<Telemetry> itemsToSend = new ArrayList<Telemetry>(); List<List<Telemetry>> telemetryListCollection = new ArrayList<List<Telemetry>>(); telemetryListCollection.add(dependencyTelemetry); List<String> excludeTypes = new ArrayList<String>() {{add("Dependency");}}; TelemetryConfiguration configuration = createConfiguration(itemsToSend); TelemetryClient client = new TelemetryClient(configuration); testNoSampling(client, telemetryListCollection, itemsToSend, null, excludeTypes, 10.0); }
@Test public void pageViewCanBeExcludedFromSampling() { List<Telemetry> dependencyTelemetry = getListOfTelemetry("com.microsoft.applicationinsights.telemetry.PageViewTelemetry",100); List<Telemetry> itemsToSend = new ArrayList<Telemetry>(); List<List<Telemetry>> telemetryListCollection = new ArrayList<List<Telemetry>>(); telemetryListCollection.add(dependencyTelemetry); List<String> excludeTypes = new ArrayList<String>() {{add("PageView");}}; TelemetryConfiguration configuration = createConfiguration(itemsToSend); TelemetryClient client = new TelemetryClient(configuration); testNoSampling(client, telemetryListCollection, itemsToSend, null, excludeTypes, 10.0); }
@Test public void exceptionCanBeExcludedFromSampling() { List<Telemetry> dependencyTelemetry = getListOfTelemetry("com.microsoft.applicationinsights.telemetry.ExceptionTelemetry",100); List<Telemetry> itemsToSend = new ArrayList<Telemetry>(); List<List<Telemetry>> telemetryListCollection = new ArrayList<List<Telemetry>>(); List<String> excludeTypes = new ArrayList<String>() {{add("Exception");}}; telemetryListCollection.add(dependencyTelemetry); TelemetryConfiguration configuration = createConfiguration(itemsToSend); TelemetryClient client = new TelemetryClient(configuration); testNoSampling(client, telemetryListCollection, itemsToSend, null, excludeTypes, 10.0); }
@Test public void noSamplingTracksSamplingRate() { List<Telemetry> dependencyTelemetry = getListOfTelemetry("com.microsoft.applicationinsights.telemetry.RequestTelemetry",100); List<List<Telemetry>> telemetryCollectionList = new ArrayList<List<Telemetry>>(); telemetryCollectionList.add(dependencyTelemetry); List<Telemetry> itemsToSend = new ArrayList<Telemetry>(); List<String> includeTypes = new ArrayList<String>() {{add("Request");}}; TelemetryConfiguration configuration = createConfiguration(itemsToSend); TelemetryClient client = new TelemetryClient(configuration); testSampling(client, telemetryCollectionList, itemsToSend, includeTypes, null, 100.0); }
@Test public void requestCanBeExcludedFromSampling() { List<Telemetry> dependencyTelemetry = getListOfTelemetry("com.microsoft.applicationinsights.telemetry.RequestTelemetry",100); List<Telemetry> itemsToSend = new ArrayList<Telemetry>(); List<List<Telemetry>> telemetryListCollection = new ArrayList<List<Telemetry>>(); List<String> excludeTypes = new ArrayList<String>() {{add("Request");}}; telemetryListCollection.add(dependencyTelemetry); TelemetryConfiguration configuration = createConfiguration(itemsToSend); TelemetryClient client = new TelemetryClient(configuration); testNoSampling(client, telemetryListCollection, itemsToSend, null, excludeTypes, 10.0); }
@Test public void traceCanBeExcludedFromSampling() { List<Telemetry> dependencyTelemetry = getListOfTelemetry("com.microsoft.applicationinsights.telemetry.TraceTelemetry",100); List<Telemetry> itemsToSend = new ArrayList<Telemetry>(); List<List<Telemetry>> telemetryListCollection = new ArrayList<List<Telemetry>>(); telemetryListCollection.add(dependencyTelemetry); List<String> excludeTypes = new ArrayList<String>() {{add("Trace");}}; TelemetryConfiguration configuration = createConfiguration(itemsToSend); TelemetryClient client = new TelemetryClient(configuration); testNoSampling(client, telemetryListCollection, itemsToSend, null, excludeTypes, 10.0); }
@Test public void unknownIncludedTypesAreIgnored() { List<Telemetry> dependencyTelemetry = getListOfTelemetry("com.microsoft.applicationinsights.telemetry.RemoteDependencyTelemetry",100); List<List<Telemetry>> telemetryCollectionList = new ArrayList<List<Telemetry>>(); telemetryCollectionList.add(dependencyTelemetry); List<Telemetry> itemsToSend = new ArrayList<Telemetry>(); List<String> includeTypes = new ArrayList<String>() {{add("aaa"); add("bbb");}}; TelemetryConfiguration configuration = createConfiguration(itemsToSend); TelemetryClient client = new TelemetryClient(configuration); testSampling(client, telemetryCollectionList, itemsToSend, includeTypes, null, 10.0); }
@Test public void unknownExcludedTypesAreIgnored() { List<Telemetry> dependencyTelemetry = getListOfTelemetry("com.microsoft.applicationinsights.telemetry.RemoteDependencyTelemetry",100); List<List<Telemetry>> telemetryCollectionList = new ArrayList<List<Telemetry>>(); telemetryCollectionList.add(dependencyTelemetry); List<Telemetry> itemsToSend = new ArrayList<Telemetry>(); List<String> excludeTypes = new ArrayList<String>() {{add("aaa"); add("bbb");}}; TelemetryConfiguration configuration = createConfiguration(itemsToSend); TelemetryClient client = new TelemetryClient(configuration); testSampling(client, telemetryCollectionList, itemsToSend, null, excludeTypes, 10.0); }