use of com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryItem in project ApplicationInsights-Java by microsoft.
the class BytecodeUtilImpl method trackPageView.
@Override
public void trackPageView(Date timestamp, String name, URI uri, long totalMillis, Map<String, String> properties, Map<String, String> tags, Map<String, Double> metrics, String instrumentationKey) {
if (Strings.isNullOrEmpty(name)) {
return;
}
TelemetryItem telemetry = new TelemetryItem();
PageViewData data = new PageViewData();
TelemetryClient.getActive().initPageViewTelemetry(telemetry, data);
data.setName(name);
if (uri != null) {
data.setUrl(uri.toString());
}
data.setDuration(FormattedDuration.fromMillis(totalMillis));
data.setMeasurements(metrics);
if (!properties.isEmpty()) {
Map<String, String> existingProperties = data.getProperties();
if (existingProperties == null) {
data.setProperties(properties);
} else {
existingProperties.putAll(properties);
}
}
if (timestamp != null) {
telemetry.setTime(FormattedTime.offSetDateTimeFromDate(timestamp));
} else {
telemetry.setTime(FormattedTime.offSetDateTimeFromNow());
}
selectivelySetTags(telemetry, tags);
if (instrumentationKey != null) {
telemetry.setInstrumentationKey(instrumentationKey);
}
track(telemetry, true);
}
use of com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryItem in project ApplicationInsights-Java by microsoft.
the class TelemetryChannel method send.
public CompletableResultCode send(List<TelemetryItem> telemetryItems) {
Map<String, List<TelemetryItem>> instrumentationKeyMap = new HashMap<>();
List<CompletableResultCode> resultCodeList = new ArrayList<>();
for (TelemetryItem telemetryItem : telemetryItems) {
String instrumentationKey = telemetryItem.getInstrumentationKey();
if (!instrumentationKeyMap.containsKey(instrumentationKey)) {
instrumentationKeyMap.put(instrumentationKey, new ArrayList<>());
}
instrumentationKeyMap.get(instrumentationKey).add(telemetryItem);
}
for (String instrumentationKey : instrumentationKeyMap.keySet()) {
resultCodeList.add(internalSendByInstrumentationKey(instrumentationKeyMap.get(instrumentationKey), instrumentationKey));
}
return CompletableResultCode.ofAll(resultCodeList);
}
use of com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryItem in project ApplicationInsights-Java by microsoft.
the class TelemetryUtil method createMetricsTelemetry.
public static TelemetryItem createMetricsTelemetry(TelemetryClient telemetryClient, String name, double value) {
TelemetryItem telemetry = new TelemetryItem();
MetricsData data = new MetricsData();
MetricDataPoint point = new MetricDataPoint();
telemetryClient.initMetricTelemetry(telemetry, data, point);
point.setName(name);
point.setValue(value);
point.setDataPointType(DataPointType.MEASUREMENT);
telemetry.setTime(FormattedTime.offSetDateTimeFromNow());
return telemetry;
}
use of com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryItem in project ApplicationInsights-Java by microsoft.
the class OshiPerformanceCounter method send.
private static void send(TelemetryClient telemetryClient, double value, String metricName) {
TelemetryItem telemetry = TelemetryUtil.createMetricsTelemetry(telemetryClient, metricName, value);
telemetryClient.trackAsync(telemetry);
}
use of com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryItem in project ApplicationInsights-Java by microsoft.
the class ProcessMemoryPerformanceCounter method report.
@Override
public void report(TelemetryClient telemetryClient) {
MemoryMXBean memoryData = ManagementFactory.getMemoryMXBean();
MemoryUsage heapMemoryUsage = memoryData.getHeapMemoryUsage();
MemoryUsage nonHeapMemoryUsage = memoryData.getNonHeapMemoryUsage();
double memoryBytes = (double) heapMemoryUsage.getUsed();
memoryBytes += (double) nonHeapMemoryUsage.getUsed();
logger.trace("Performance Counter: {}: {}", PROCESS_MEM_PC_METRICS_NAME, memoryBytes);
TelemetryItem telemetry = TelemetryUtil.createMetricsTelemetry(telemetryClient, PROCESS_MEM_PC_METRICS_NAME, memoryBytes);
telemetryClient.trackAsync(telemetry);
}
Aggregations