Search in sources :

Example 1 with RemoteDependencyData

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

the class QuickPulseTestBase method createRemoteDependencyTelemetry.

public static TelemetryItem createRemoteDependencyTelemetry(String name, String command, long durationMillis, boolean success) {
    TelemetryItem telemetry = new TelemetryItem();
    RemoteDependencyData data = new RemoteDependencyData();
    TelemetryClient.createForTest().initRemoteDependencyTelemetry(telemetry, data);
    Map<String, String> properties = new HashMap<>();
    properties.put("customProperty", "customValue");
    data.setProperties(properties);
    data.setName(name);
    data.setData(command);
    data.setDuration(FormattedDuration.fromMillis(durationMillis));
    data.setSuccess(success);
    return telemetry;
}
Also used : HashMap(java.util.HashMap) TelemetryItem(com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryItem) RemoteDependencyData(com.microsoft.applicationinsights.agent.internal.exporter.models.RemoteDependencyData)

Example 2 with RemoteDependencyData

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

the class Exporter method exportRemoteDependency.

private void exportRemoteDependency(SpanData span, boolean inProc) {
    TelemetryItem telemetry = new TelemetryItem();
    RemoteDependencyData data = new RemoteDependencyData();
    telemetryClient.initRemoteDependencyTelemetry(telemetry, data);
    float samplingPercentage = getSamplingPercentage(span.getSpanContext().getTraceState());
    // set standard properties
    setOperationTags(telemetry, span);
    setTime(telemetry, span.getStartEpochNanos());
    setSampleRate(telemetry, samplingPercentage);
    setExtraAttributes(telemetry, data, span.getAttributes());
    addLinks(data, span.getLinks());
    // set dependency-specific properties
    data.setId(span.getSpanId());
    data.setName(getDependencyName(span));
    data.setDuration(FormattedDuration.fromNanos(span.getEndEpochNanos() - span.getStartEpochNanos()));
    data.setSuccess(getSuccess(span));
    if (inProc) {
        data.setType("InProc");
    } else {
        applySemanticConventions(span, data);
    }
    // export
    telemetryClient.trackAsync(telemetry);
    exportEvents(span, null, samplingPercentage);
}
Also used : TelemetryItem(com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryItem) RemoteDependencyData(com.microsoft.applicationinsights.agent.internal.exporter.models.RemoteDependencyData)

Example 3 with RemoteDependencyData

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

the class TelemetryUtil method getProperties.

// TODO (trask) Azure SDK: can we move getProperties up to MonitorDomain, or if not, a common
// interface?
public static Map<String, String> getProperties(MonitorDomain data) {
    if (data instanceof AvailabilityData) {
        AvailabilityData availabilityData = (AvailabilityData) data;
        Map<String, String> properties = availabilityData.getProperties();
        if (properties == null) {
            properties = new HashMap<>();
            availabilityData.setProperties(properties);
        }
        return properties;
    } else if (data instanceof MessageData) {
        MessageData messageData = (MessageData) data;
        Map<String, String> properties = messageData.getProperties();
        if (properties == null) {
            properties = new HashMap<>();
            messageData.setProperties(properties);
        }
        return properties;
    } else if (data instanceof MetricsData) {
        MetricsData metricsData = (MetricsData) data;
        Map<String, String> properties = metricsData.getProperties();
        if (properties == null) {
            properties = new HashMap<>();
            metricsData.setProperties(properties);
        }
        return properties;
    } else if (data instanceof PageViewData) {
        PageViewData pageViewData = (PageViewData) data;
        Map<String, String> properties = pageViewData.getProperties();
        if (properties == null) {
            properties = new HashMap<>();
            pageViewData.setProperties(properties);
        }
        return properties;
    } else if (data instanceof PageViewPerfData) {
        PageViewPerfData pageViewPerfData = (PageViewPerfData) data;
        Map<String, String> properties = pageViewPerfData.getProperties();
        if (properties == null) {
            properties = new HashMap<>();
            pageViewPerfData.setProperties(properties);
        }
        return properties;
    } else if (data instanceof RemoteDependencyData) {
        RemoteDependencyData remoteDependencyData = (RemoteDependencyData) data;
        Map<String, String> properties = remoteDependencyData.getProperties();
        if (properties == null) {
            properties = new HashMap<>();
            remoteDependencyData.setProperties(properties);
        }
        return properties;
    } else if (data instanceof RequestData) {
        RequestData requestData = (RequestData) data;
        Map<String, String> properties = requestData.getProperties();
        if (properties == null) {
            properties = new HashMap<>();
            requestData.setProperties(properties);
        }
        return properties;
    } else if (data instanceof TelemetryEventData) {
        TelemetryEventData eventData = (TelemetryEventData) data;
        Map<String, String> properties = eventData.getProperties();
        if (properties == null) {
            properties = new HashMap<>();
            eventData.setProperties(properties);
        }
        return properties;
    } else if (data instanceof TelemetryExceptionData) {
        TelemetryExceptionData exceptionData = (TelemetryExceptionData) data;
        Map<String, String> properties = exceptionData.getProperties();
        if (properties == null) {
            properties = new HashMap<>();
            exceptionData.setProperties(properties);
        }
        return properties;
    } else {
        throw new IllegalArgumentException("Unexpected type: " + data.getClass().getName());
    }
}
Also used : AvailabilityData(com.microsoft.applicationinsights.agent.internal.exporter.models.AvailabilityData) PageViewPerfData(com.microsoft.applicationinsights.agent.internal.exporter.models.PageViewPerfData) HashMap(java.util.HashMap) MessageData(com.microsoft.applicationinsights.agent.internal.exporter.models.MessageData) RemoteDependencyData(com.microsoft.applicationinsights.agent.internal.exporter.models.RemoteDependencyData) PageViewData(com.microsoft.applicationinsights.agent.internal.exporter.models.PageViewData) MetricsData(com.microsoft.applicationinsights.agent.internal.exporter.models.MetricsData) RequestData(com.microsoft.applicationinsights.agent.internal.exporter.models.RequestData) HashMap(java.util.HashMap) Map(java.util.Map) TelemetryExceptionData(com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryExceptionData) TelemetryEventData(com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryEventData)

Example 4 with RemoteDependencyData

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

the class BytecodeUtilImpl method trackDependency.

@Override
public void trackDependency(Date timestamp, String name, String id, String resultCode, @Nullable Long totalMillis, boolean success, String commandName, String type, String target, Map<String, String> properties, Map<String, String> tags, Map<String, Double> metrics, String instrumentationKey) {
    if (Strings.isNullOrEmpty(name)) {
        return;
    }
    TelemetryItem telemetry = new TelemetryItem();
    RemoteDependencyData data = new RemoteDependencyData();
    TelemetryClient.getActive().initRemoteDependencyTelemetry(telemetry, data);
    data.setName(name);
    if (id == null) {
        data.setId(AiLegacyPropagator.generateSpanId());
    } else {
        data.setId(id);
    }
    data.setResultCode(resultCode);
    if (totalMillis != null) {
        data.setDuration(FormattedDuration.fromMillis(totalMillis));
    }
    data.setSuccess(success);
    data.setData(commandName);
    data.setType(type);
    data.setTarget(target);
    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);
}
Also used : TelemetryItem(com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryItem) RemoteDependencyData(com.microsoft.applicationinsights.agent.internal.exporter.models.RemoteDependencyData)

Aggregations

RemoteDependencyData (com.microsoft.applicationinsights.agent.internal.exporter.models.RemoteDependencyData)4 TelemetryItem (com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryItem)3 HashMap (java.util.HashMap)2 AvailabilityData (com.microsoft.applicationinsights.agent.internal.exporter.models.AvailabilityData)1 MessageData (com.microsoft.applicationinsights.agent.internal.exporter.models.MessageData)1 MetricsData (com.microsoft.applicationinsights.agent.internal.exporter.models.MetricsData)1 PageViewData (com.microsoft.applicationinsights.agent.internal.exporter.models.PageViewData)1 PageViewPerfData (com.microsoft.applicationinsights.agent.internal.exporter.models.PageViewPerfData)1 RequestData (com.microsoft.applicationinsights.agent.internal.exporter.models.RequestData)1 TelemetryEventData (com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryEventData)1 TelemetryExceptionData (com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryExceptionData)1 Map (java.util.Map)1