use of com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryExceptionData 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());
}
}
use of com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryExceptionData in project ApplicationInsights-Java by microsoft.
the class Exporter method trackException.
private void trackException(String errorStack, SpanData span, @Nullable String operationName, float samplingPercentage) {
TelemetryItem telemetry = new TelemetryItem();
TelemetryExceptionData data = new TelemetryExceptionData();
telemetryClient.initExceptionTelemetry(telemetry, data);
// set standard properties
setOperationId(telemetry, span.getTraceId());
setOperationParentId(telemetry, span.getSpanId());
if (operationName != null) {
setOperationName(telemetry, operationName);
} else {
setOperationName(telemetry, span.getAttributes());
}
setTime(telemetry, span.getEndEpochNanos());
setSampleRate(telemetry, samplingPercentage);
// set exception-specific properties
data.setExceptions(Exceptions.minimalParse(errorStack));
telemetryClient.trackAsync(telemetry);
}
use of com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryExceptionData in project ApplicationInsights-Java by microsoft.
the class Exporter method trackTraceAsException.
private void trackTraceAsException(SpanData span, String errorStack) {
TelemetryItem telemetry = new TelemetryItem();
TelemetryExceptionData data = new TelemetryExceptionData();
telemetryClient.initExceptionTelemetry(telemetry, data);
Attributes attributes = span.getAttributes();
// set standard properties
setOperationTags(telemetry, span);
setTime(telemetry, span.getStartEpochNanos());
setSampleRate(telemetry, span);
setExtraAttributes(telemetry, data, attributes);
// set exception-specific properties
String level = attributes.get(AI_LOG_LEVEL_KEY);
String loggerName = attributes.get(AI_LOGGER_NAME_KEY);
String threadName = attributes.get(SemanticAttributes.THREAD_NAME);
data.setExceptions(Exceptions.minimalParse(errorStack));
data.setSeverityLevel(toSeverityLevel(level));
TelemetryUtil.getProperties(data).put("Logger Message", span.getName());
setLoggerProperties(data, level, loggerName, threadName);
// export
telemetryClient.trackAsync(telemetry);
}
use of com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryExceptionData in project ApplicationInsights-Java by microsoft.
the class QuickPulseTestBase method createExceptionTelemetry.
public static TelemetryItem createExceptionTelemetry(Exception exception) {
TelemetryItem telemetry = new TelemetryItem();
TelemetryExceptionData data = new TelemetryExceptionData();
TelemetryClient.createForTest().initExceptionTelemetry(telemetry, data);
data.setExceptions(getExceptions(exception));
return telemetry;
}
use of com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryExceptionData in project ApplicationInsights-Java by microsoft.
the class BytecodeUtilImpl method trackException.
@Override
public void trackException(Date timestamp, Exception exception, Map<String, String> properties, Map<String, String> tags, Map<String, Double> metrics, String instrumentationKey) {
if (exception == null) {
return;
}
TelemetryItem telemetry = new TelemetryItem();
TelemetryExceptionData data = new TelemetryExceptionData();
TelemetryClient.getActive().initExceptionTelemetry(telemetry, data);
data.setExceptions(TelemetryUtil.getExceptions(exception));
data.setSeverityLevel(SeverityLevel.ERROR);
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);
}
Aggregations