Search in sources :

Example 1 with LocalFileCache

use of com.microsoft.applicationinsights.agent.internal.localstorage.LocalFileCache in project ApplicationInsights-Java by microsoft.

the class TelemetryClient method getStatsbeatChannelBatcher.

public BatchSpanProcessor getStatsbeatChannelBatcher() {
    if (statsbeatChannelBatcher == null) {
        synchronized (channelInitLock) {
            if (statsbeatChannelBatcher == null) {
                File statsbeatFolder;
                LocalFileLoader localFileLoader = null;
                LocalFileWriter localFileWriter = null;
                if (!readOnlyFileSystem) {
                    statsbeatFolder = LocalStorageUtils.getOfflineStatsbeatFolder();
                    LocalFileCache localFileCache = new LocalFileCache(statsbeatFolder);
                    localFileLoader = new LocalFileLoader(localFileCache, statsbeatFolder, null);
                    localFileWriter = new LocalFileWriter(localFileCache, statsbeatFolder, null);
                }
                TelemetryChannel channel = TelemetryChannel.create(endpointProvider.getStatsbeatEndpointUrl(), localFileWriter, ikeyEndpointMap, statsbeatModule, true, null);
                if (!readOnlyFileSystem) {
                    LocalFileSender.start(localFileLoader, channel);
                }
                statsbeatChannelBatcher = BatchSpanProcessor.builder(channel).build("statsbeat");
            }
        }
    }
    return statsbeatChannelBatcher;
}
Also used : LocalFileLoader(com.microsoft.applicationinsights.agent.internal.localstorage.LocalFileLoader) LocalFileCache(com.microsoft.applicationinsights.agent.internal.localstorage.LocalFileCache) LocalFileWriter(com.microsoft.applicationinsights.agent.internal.localstorage.LocalFileWriter) File(java.io.File)

Example 2 with LocalFileCache

use of com.microsoft.applicationinsights.agent.internal.localstorage.LocalFileCache in project ApplicationInsights-Java by microsoft.

the class TelemetryChannelTest method getTelemetryChannel.

private TelemetryChannel getTelemetryChannel() throws MalformedURLException {
    List<HttpPipelinePolicy> policies = new ArrayList<>();
    policies.add(new RedirectPolicy(Cache.bounded(5)));
    HttpPipelineBuilder pipelineBuilder = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])).httpClient(recordingHttpClient);
    LocalFileCache localFileCache = new LocalFileCache(tempFolder);
    StatsbeatModule mockedStatsModule = Mockito.mock(StatsbeatModule.class);
    when(mockedStatsModule.getNetworkStatsbeat()).thenReturn(Mockito.mock(NetworkStatsbeat.class));
    return new TelemetryChannel(pipelineBuilder.build(), new URL(END_POINT_URL), new LocalFileWriter(localFileCache, tempFolder, null), mockedStatsModule, false);
}
Also used : HttpPipelinePolicy(com.azure.core.http.policy.HttpPipelinePolicy) RedirectPolicy(com.microsoft.applicationinsights.agent.internal.httpclient.RedirectPolicy) LocalFileCache(com.microsoft.applicationinsights.agent.internal.localstorage.LocalFileCache) NetworkStatsbeat(com.microsoft.applicationinsights.agent.internal.statsbeat.NetworkStatsbeat) HttpPipelineBuilder(com.azure.core.http.HttpPipelineBuilder) LocalFileWriter(com.microsoft.applicationinsights.agent.internal.localstorage.LocalFileWriter) StatsbeatModule(com.microsoft.applicationinsights.agent.internal.statsbeat.StatsbeatModule) ArrayList(java.util.ArrayList) URL(java.net.URL)

Example 3 with LocalFileCache

use of com.microsoft.applicationinsights.agent.internal.localstorage.LocalFileCache in project ApplicationInsights-Java by microsoft.

the class TelemetryClient method initChannelBatcher.

private BatchSpanProcessor initChannelBatcher(int exportQueueCapacity, int maxExportBatchSize, String queueName) {
    LocalFileLoader localFileLoader = null;
    LocalFileWriter localFileWriter = null;
    if (!readOnlyFileSystem) {
        File telemetryFolder = LocalStorageUtils.getOfflineTelemetryFolder();
        LocalFileCache localFileCache = new LocalFileCache(telemetryFolder);
        localFileLoader = new LocalFileLoader(localFileCache, telemetryFolder, statsbeatModule.getNonessentialStatsbeat());
        localFileWriter = new LocalFileWriter(localFileCache, telemetryFolder, statsbeatModule.getNonessentialStatsbeat());
    }
    TelemetryChannel channel = TelemetryChannel.create(endpointProvider.getIngestionEndpointUrl(), localFileWriter, ikeyEndpointMap, statsbeatModule, false, aadAuthentication);
    if (!readOnlyFileSystem) {
        LocalFileSender.start(localFileLoader, channel);
    }
    return BatchSpanProcessor.builder(channel).setMaxQueueSize(exportQueueCapacity).setMaxExportBatchSize(maxExportBatchSize).setMaxPendingExports(100).build(queueName);
}
Also used : LocalFileLoader(com.microsoft.applicationinsights.agent.internal.localstorage.LocalFileLoader) LocalFileCache(com.microsoft.applicationinsights.agent.internal.localstorage.LocalFileCache) LocalFileWriter(com.microsoft.applicationinsights.agent.internal.localstorage.LocalFileWriter) File(java.io.File)

Aggregations

LocalFileCache (com.microsoft.applicationinsights.agent.internal.localstorage.LocalFileCache)3 LocalFileWriter (com.microsoft.applicationinsights.agent.internal.localstorage.LocalFileWriter)3 LocalFileLoader (com.microsoft.applicationinsights.agent.internal.localstorage.LocalFileLoader)2 File (java.io.File)2 HttpPipelineBuilder (com.azure.core.http.HttpPipelineBuilder)1 HttpPipelinePolicy (com.azure.core.http.policy.HttpPipelinePolicy)1 RedirectPolicy (com.microsoft.applicationinsights.agent.internal.httpclient.RedirectPolicy)1 NetworkStatsbeat (com.microsoft.applicationinsights.agent.internal.statsbeat.NetworkStatsbeat)1 StatsbeatModule (com.microsoft.applicationinsights.agent.internal.statsbeat.StatsbeatModule)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1