Search in sources :

Example 1 with MonitorBase

use of com.microsoft.applicationinsights.agent.internal.exporter.models.MonitorBase in project ApplicationInsights-Java by microsoft.

the class TelemetryClient method initTelemetry.

private void initTelemetry(TelemetryItem telemetry, MonitorDomain data, String telemetryName, String baseType) {
    telemetry.setVersion(1);
    telemetry.setName(telemetryName);
    telemetry.setInstrumentationKey(instrumentationKey);
    telemetry.setTags(new HashMap<>(globalTags));
    data.setVersion(2);
    MonitorBase monitorBase = new MonitorBase();
    telemetry.setData(monitorBase);
    monitorBase.setBaseType(baseType);
    monitorBase.setBaseData(data);
}
Also used : MonitorBase(com.microsoft.applicationinsights.agent.internal.exporter.models.MonitorBase)

Example 2 with MonitorBase

use of com.microsoft.applicationinsights.agent.internal.exporter.models.MonitorBase in project ApplicationInsights-Java by microsoft.

the class TestUtils method createMetricTelemetry.

public static TelemetryItem createMetricTelemetry(String name, int value, String instrumentationKey) {
    TelemetryItem telemetry = new TelemetryItem();
    telemetry.setVersion(1);
    telemetry.setName("Metric");
    telemetry.setInstrumentationKey(instrumentationKey);
    Map<String, String> tags = new HashMap<>();
    tags.put("ai.internal.sdkVersion", "test_version");
    tags.put("ai.internal.nodeName", "test_role_name");
    tags.put("ai.cloud.roleInstance", "test_cloud_name");
    telemetry.setTags(tags);
    MetricsData data = new MetricsData();
    List<MetricDataPoint> dataPoints = new ArrayList<>();
    MetricDataPoint dataPoint = new MetricDataPoint();
    dataPoint.setDataPointType(DataPointType.MEASUREMENT);
    dataPoint.setName(name);
    dataPoint.setValue(value);
    dataPoint.setCount(1);
    dataPoints.add(dataPoint);
    Map<String, String> properties = new HashMap<>();
    properties.put("state", "blocked");
    data.setMetrics(dataPoints);
    data.setProperties(properties);
    MonitorBase monitorBase = new MonitorBase();
    monitorBase.setBaseType("MetricData");
    monitorBase.setBaseData(data);
    telemetry.setData(monitorBase);
    telemetry.setTime(FormattedTime.offSetDateTimeFromNow());
    return telemetry;
}
Also used : MetricsData(com.microsoft.applicationinsights.agent.internal.exporter.models.MetricsData) HashMap(java.util.HashMap) TelemetryItem(com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryItem) MetricDataPoint(com.microsoft.applicationinsights.agent.internal.exporter.models.MetricDataPoint) ArrayList(java.util.ArrayList) MonitorBase(com.microsoft.applicationinsights.agent.internal.exporter.models.MonitorBase)

Aggregations

MonitorBase (com.microsoft.applicationinsights.agent.internal.exporter.models.MonitorBase)2 MetricDataPoint (com.microsoft.applicationinsights.agent.internal.exporter.models.MetricDataPoint)1 MetricsData (com.microsoft.applicationinsights.agent.internal.exporter.models.MetricsData)1 TelemetryItem (com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryItem)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1