use of com.microsoft.applicationinsights.agent.internal.exporter.models.MetricDataPoint in project ApplicationInsights-Java by microsoft.
the class BytecodeUtilImpl method trackMetric.
// TODO do not track if perf counter (?)
@Override
public void trackMetric(Date timestamp, String name, double value, Integer count, Double min, Double max, Double stdDev, Map<String, String> properties, Map<String, String> tags, String instrumentationKey) {
if (Strings.isNullOrEmpty(name)) {
return;
}
TelemetryItem telemetry = new TelemetryItem();
MetricsData data = new MetricsData();
MetricDataPoint point = new MetricDataPoint();
TelemetryClient.getActive().initMetricTelemetry(telemetry, data, point);
point.setName(name);
point.setValue(value);
point.setCount(count);
point.setMin(min);
point.setMax(max);
point.setStdDev(stdDev);
if (count != null || min != null || max != null || stdDev != null) {
point.setDataPointType(DataPointType.AGGREGATION);
} else {
point.setDataPointType(DataPointType.MEASUREMENT);
}
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, false);
}
use of com.microsoft.applicationinsights.agent.internal.exporter.models.MetricDataPoint 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.MetricDataPoint in project ApplicationInsights-Java by microsoft.
the class AlertingServiceFactory method addObserver.
private static void addObserver(AlertingSubsystem alertingSubsystem, TelemetryObservers telemetryObservers) {
telemetryObservers.addObserver(telemetry -> {
MonitorDomain data = telemetry.getData().getBaseData();
if (!(data instanceof MetricsData)) {
return;
}
MetricDataPoint point = ((MetricsData) data).getMetrics().get(0);
AlertMetricType alertMetricType = null;
if (point.getName().equals(TOTAL_CPU_PC_METRIC_NAME)) {
alertMetricType = AlertMetricType.CPU;
}
if (alertMetricType != null) {
alertingSubsystem.track(alertMetricType, point.getValue());
}
});
}
Aggregations