first phase: new data objects and refactor of the Telemetries and serializer
This commit is contained in:
Родитель
ff7591eb7f
Коммит
20876aa77c
|
@ -5,7 +5,7 @@ import java.io.StringWriter;
|
|||
import java.util.Collection;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonWriter;
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
@ -42,7 +42,7 @@ public final class GzipTelemetrySerializer implements TelemetrySerializer {
|
|||
try {
|
||||
int counter = 0;
|
||||
StringWriter writer = new StringWriter();
|
||||
JsonWriter jsonWriter = new com.microsoft.applicationinsights.implementation.JsonWriter(writer);
|
||||
JsonTelemetryDataSerializer jsonWriter = new JsonTelemetryDataSerializer(writer);
|
||||
|
||||
// The format is:
|
||||
// 1. Telemetry is written in Json
|
||||
|
@ -57,11 +57,14 @@ public final class GzipTelemetrySerializer implements TelemetrySerializer {
|
|||
++counter;
|
||||
|
||||
telemetry.serialize(jsonWriter);
|
||||
jsonWriter.close();
|
||||
|
||||
String asJson = writer.toString();
|
||||
zipStream.write(asJson.getBytes());
|
||||
|
||||
if (counter < telemetries.size()) {
|
||||
writer.getBuffer().setLength(0);
|
||||
jsonWriter.reset(writer);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.io.IOException;
|
|||
import java.io.StringWriter;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
import com.microsoft.applicationinsights.implementation.JsonWriter;
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
|
@ -38,7 +39,8 @@ public class SimpleHttpChannel implements TelemetryChannel
|
|||
{
|
||||
// Establish the payload.
|
||||
StringWriter writer = new StringWriter();
|
||||
item.serialize(new JsonWriter(writer));
|
||||
// item.serialize(new JsonWriter(writer));
|
||||
item.serialize(new JsonTelemetryDataSerializer(writer));
|
||||
|
||||
// Send it.
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.microsoft.applicationinsights.channel;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
import com.microsoft.applicationinsights.implementation.JsonWriter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -25,7 +26,8 @@ public class StdOutChannel implements TelemetryChannel
|
|||
public void send(Telemetry item) {
|
||||
try {
|
||||
StringWriter writer = new StringWriter();
|
||||
item.serialize(new JsonWriter(writer));
|
||||
// item.serialize(new JsonWriter(writer));
|
||||
item.serialize(new JsonTelemetryDataSerializer(writer));
|
||||
System.out.println("TELEMETRY: " + writer.toString());
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace(System.err);
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package com.microsoft.applicationinsights.channel;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
@ -80,12 +83,11 @@ public final class TransmissionNetworkOutput implements TransmissionOutput {
|
|||
response = httpClient.execute(request);
|
||||
|
||||
HttpEntity respEntity = response.getEntity();
|
||||
if (respEntity != null) {
|
||||
respEntity.getContent().close();
|
||||
}
|
||||
int code = response.getStatusLine().getStatusCode();
|
||||
if (code != 200) {
|
||||
// TODO: check more and log
|
||||
if (respEntity != null) {
|
||||
logError(respEntity);
|
||||
}
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace(System.err);
|
||||
|
@ -104,6 +106,20 @@ public final class TransmissionNetworkOutput implements TransmissionOutput {
|
|||
return true;
|
||||
}
|
||||
|
||||
private void logError(HttpEntity respEntity) {
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
inputStream = respEntity.getContent();
|
||||
InputStreamReader streamReader = new InputStreamReader(inputStream, "UTF-8");
|
||||
BufferedReader reader = new BufferedReader(streamReader);
|
||||
String responseLine = reader.readLine();
|
||||
respEntity.getContent().close();
|
||||
// TODO: check more and log
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private HttpPost createTransmissionPostRequest(Transmission transmission) {
|
||||
HttpPost request = new HttpPost(serverUri);
|
||||
request.addHeader(CONTENT_TYPE_HEADER, transmission.getWebContentType());
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
package com.microsoft.applicationinsights.datacontracts;
|
||||
|
||||
import com.microsoft.applicationinsights.channel.Telemetry;
|
||||
import com.microsoft.applicationinsights.implementation.schemav2.Data;
|
||||
import com.microsoft.applicationinsights.implementation.schemav2.Envelope;
|
||||
import com.microsoft.applicationinsights.implementation.schemav2.SendableData;
|
||||
import com.microsoft.applicationinsights.util.LocalStringsUtils;
|
||||
import com.microsoft.applicationinsights.util.MapUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
@ -10,47 +15,58 @@ import java.util.Map;
|
|||
/**
|
||||
* Superclass for all telemetry data classes.
|
||||
*/
|
||||
public abstract class BaseTelemetry implements Telemetry
|
||||
public abstract class BaseTelemetry<T extends SendableData> implements Telemetry
|
||||
{
|
||||
private TelemetryContext context;
|
||||
private Date timestamp;
|
||||
private Date timestamp;
|
||||
|
||||
protected BaseTelemetry()
|
||||
{
|
||||
protected BaseTelemetry() {
|
||||
}
|
||||
|
||||
protected void initialize(Map<String, String> properties)
|
||||
{
|
||||
protected void initialize(Map<String, String> properties) {
|
||||
this.context = new TelemetryContext(properties, new HashMap<String, String>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getTimestamp()
|
||||
{
|
||||
public Date getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTimestamp(Date date)
|
||||
{
|
||||
public void setTimestamp(Date date) {
|
||||
this.timestamp = date;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TelemetryContext getContext()
|
||||
{
|
||||
public TelemetryContext getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getProperties()
|
||||
{
|
||||
public Map<String, String> getProperties() {
|
||||
return this.context.getProperties();
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void sanitize();
|
||||
public void sanitize() {
|
||||
MapUtil.sanitizeProperties(this.getProperties());
|
||||
additionalSanitize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void serialize(JsonWriter writer) throws IOException;
|
||||
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
|
||||
Envelope envelope = new Envelope();
|
||||
|
||||
envelope.setIKey(context.getInstrumentationKey());
|
||||
envelope.setData(new Data<T>(getData()));
|
||||
envelope.setTime(LocalStringsUtils.getDateFormatter().format(getTimestamp()));
|
||||
envelope.setTags(context.getProperties());
|
||||
|
||||
envelope.serialize(writer);
|
||||
}
|
||||
|
||||
protected abstract void additionalSanitize();
|
||||
|
||||
protected abstract T getData();
|
||||
}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package com.microsoft.applicationinsights.datacontracts;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import com.microsoft.applicationinsights.extensibility.model.EventData;
|
||||
import com.microsoft.applicationinsights.implementation.schemav2.*;
|
||||
import com.microsoft.applicationinsights.util.LocalStringsUtils;
|
||||
import com.microsoft.applicationinsights.util.MapUtil;
|
||||
|
||||
|
@ -12,79 +11,44 @@ import com.google.common.base.Strings;
|
|||
/**
|
||||
* Telemetry used to track events.
|
||||
*/
|
||||
public class EventTelemetry extends BaseTelemetry
|
||||
{
|
||||
public class EventTelemetry extends BaseTelemetry<EventData> {
|
||||
private final EventData data;
|
||||
|
||||
public EventTelemetry()
|
||||
{
|
||||
public EventTelemetry() {
|
||||
super();
|
||||
this.data = new EventData();
|
||||
initialize(this.data.getProperties());
|
||||
}
|
||||
|
||||
public EventTelemetry(String name)
|
||||
{
|
||||
public EventTelemetry(String name) {
|
||||
this();
|
||||
this.setName(name);
|
||||
}
|
||||
|
||||
public Map<String,Double> getMetrics()
|
||||
{
|
||||
public Map<String,Double> getMetrics() {
|
||||
return this.data.getMeasurements();
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
public String getName() {
|
||||
return this.data.getName();
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
if (Strings.isNullOrEmpty(name))
|
||||
public void setName(String name) {
|
||||
if (Strings.isNullOrEmpty(name)) {
|
||||
throw new IllegalArgumentException("The event name cannot be null or empty");
|
||||
}
|
||||
|
||||
this.data.setName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sanitize()
|
||||
{
|
||||
protected void additionalSanitize() {
|
||||
this.data.setName(LocalStringsUtils.sanitize(this.data.getName(), 1024));
|
||||
MapUtil.sanitizeProperties(this.getProperties());
|
||||
MapUtil.sanitizeMeasurements(this.getMetrics());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(JsonWriter writer) throws IOException
|
||||
{
|
||||
writer.writeStartObject();
|
||||
|
||||
writer.writeProperty("ver", 1);
|
||||
writer.writeProperty("name", "Microsoft.ApplicationInsights.Event");
|
||||
writer.writeProperty("time", this.getTimestamp());
|
||||
|
||||
getContext().serialize(writer);
|
||||
|
||||
writer.writePropertyName("data");
|
||||
|
||||
{
|
||||
writer.writeStartObject();
|
||||
|
||||
writer.writeProperty("type", "Microsoft.ApplicationInsights.EventData");
|
||||
|
||||
writer.writePropertyName("item");
|
||||
{
|
||||
writer.writeStartObject();
|
||||
writer.writeProperty("ver", this.data.getVer());
|
||||
writer.writeProperty("name", LocalStringsUtils.populateRequiredStringWithNullValue(this.data.getName(), "name", EventTelemetry.class.getName()));
|
||||
writer.writeMetricsProperty("measurements", this.data.getMeasurements());
|
||||
writer.writeProperty("properties", this.data.getProperties());
|
||||
writer.writeEndObject();
|
||||
}
|
||||
|
||||
writer.writeEndObject();
|
||||
}
|
||||
|
||||
writer.writeEndObject();
|
||||
protected EventData getData() {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package com.microsoft.applicationinsights.datacontracts;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.microsoft.applicationinsights.extensibility.model.ExceptionData;
|
||||
import com.microsoft.applicationinsights.extensibility.model.ExceptionDetails;
|
||||
import com.microsoft.applicationinsights.extensibility.model.StackFrame;
|
||||
import com.microsoft.applicationinsights.implementation.schemav2.ExceptionData;
|
||||
import com.microsoft.applicationinsights.implementation.schemav2.ExceptionDetails;
|
||||
import com.microsoft.applicationinsights.implementation.schemav2.StackFrame;
|
||||
import com.microsoft.applicationinsights.util.LocalStringsUtils;
|
||||
import com.microsoft.applicationinsights.util.MapUtil;
|
||||
|
||||
|
@ -16,206 +15,80 @@ import com.google.common.base.Strings;
|
|||
/**
|
||||
* Telemetry used to track events.
|
||||
*/
|
||||
public class ExceptionTelemetry extends BaseTelemetry
|
||||
{
|
||||
public class ExceptionTelemetry extends BaseTelemetry<ExceptionData> {
|
||||
private final ExceptionData data;
|
||||
private Exception exception;
|
||||
|
||||
private ExceptionTelemetry()
|
||||
{
|
||||
private ExceptionTelemetry() {
|
||||
super();
|
||||
this.data = new ExceptionData();
|
||||
initialize(this.data.getProperties());
|
||||
this.setExceptionHandledAt(ExceptionHandledAt.Unhandled);
|
||||
}
|
||||
|
||||
public ExceptionTelemetry(Exception exception)
|
||||
{
|
||||
public ExceptionTelemetry(Exception exception) {
|
||||
this();
|
||||
this.setException(exception);
|
||||
|
||||
}
|
||||
|
||||
public Exception getException()
|
||||
{
|
||||
public Exception getException() {
|
||||
return exception;
|
||||
}
|
||||
|
||||
public void setException(Exception exception)
|
||||
{
|
||||
public void setException(Exception exception) {
|
||||
this.exception = exception;
|
||||
updateException(exception);
|
||||
}
|
||||
|
||||
public ExceptionHandledAt getExceptionHandledAt()
|
||||
{
|
||||
public ExceptionHandledAt getExceptionHandledAt() {
|
||||
return Enum.valueOf(ExceptionHandledAt.class, this.data.getHandledAt());
|
||||
}
|
||||
|
||||
public void setExceptionHandledAt(ExceptionHandledAt value)
|
||||
{
|
||||
public void setExceptionHandledAt(ExceptionHandledAt value) {
|
||||
this.data.setHandledAt(value.toString());
|
||||
}
|
||||
|
||||
public Map<String,Double> getMetrics()
|
||||
{
|
||||
public Map<String,Double> getMetrics() {
|
||||
return this.data.getMeasurements();
|
||||
}
|
||||
|
||||
public List<ExceptionDetails> getExceptions()
|
||||
{
|
||||
public List<ExceptionDetails> getExceptions() {
|
||||
return this.data.getExceptions();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void sanitize()
|
||||
{
|
||||
MapUtil.sanitizeProperties(this.getProperties());
|
||||
protected void additionalSanitize() {
|
||||
MapUtil.sanitizeMeasurements(this.getMetrics());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(JsonWriter writer) throws IOException
|
||||
{
|
||||
writer.writeStartObject();
|
||||
|
||||
writer.writeProperty("ver", 1);
|
||||
writer.writeProperty("name", "Microsoft.ApplicationInsights.Exception");
|
||||
writer.writeProperty("time", this.getTimestamp());
|
||||
|
||||
getContext().serialize(writer);
|
||||
|
||||
writer.writePropertyName("data");
|
||||
|
||||
{
|
||||
writer.writeStartObject();
|
||||
|
||||
writer.writeProperty("type", "Microsoft.ApplicationInsights.ExceptionData");
|
||||
|
||||
writer.writePropertyName("item");
|
||||
{
|
||||
writer.writeStartObject();
|
||||
|
||||
writer.writeProperty("ver", this.data.getVer());
|
||||
writer.writeProperty("handledAt",
|
||||
LocalStringsUtils.populateRequiredStringWithNullValue(this.data.getHandledAt(), "handledAt", ExceptionTelemetry.class.getName()));
|
||||
writer.writeMetricsProperty("measurements", this.data.getMeasurements());
|
||||
writer.writeProperty("properties", this.data.getProperties());
|
||||
|
||||
writer.writePropertyName("exceptions");
|
||||
{
|
||||
writer.writeStartArray();
|
||||
|
||||
serialize(this.getExceptions(), writer);
|
||||
|
||||
writer.writeEndArray();
|
||||
}
|
||||
|
||||
writer.writeEndObject();
|
||||
}
|
||||
|
||||
writer.writeEndObject();
|
||||
}
|
||||
|
||||
writer.writeEndObject();
|
||||
protected ExceptionData getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
private void serialize(List<ExceptionDetails> exceptions, JsonWriter writer) throws IOException
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
for (ExceptionDetails exceptionDetails : exceptions)
|
||||
{
|
||||
if (index++ != 0)
|
||||
writer.writeComma();
|
||||
|
||||
writer.writeStartObject();
|
||||
|
||||
writer.writeProperty("id", exceptionDetails.getId());
|
||||
if (exceptionDetails.getOuterId() != 0)
|
||||
writer.writeProperty("outerId", exceptionDetails.getOuterId());
|
||||
|
||||
writer.writeProperty("typeName",
|
||||
LocalStringsUtils.populateRequiredStringWithNullValue(exceptionDetails.getTypeName(), "typeName", ExceptionTelemetry.class.getName()));
|
||||
writer.writeProperty("message",
|
||||
LocalStringsUtils.populateRequiredStringWithNullValue(exceptionDetails.getMessage(), "message", ExceptionTelemetry.class.getName()));
|
||||
|
||||
if (exceptionDetails.getHasFullStack())
|
||||
writer.writeProperty("hasFullStack", exceptionDetails.getHasFullStack());
|
||||
|
||||
writer.writeProperty("stack", exceptionDetails.getStack());
|
||||
|
||||
if (exceptionDetails.getParsedStack().size() > 0)
|
||||
{
|
||||
writer.writePropertyName("parsedStack");
|
||||
{
|
||||
writer.writeStartArray();
|
||||
|
||||
int frameIdx = 0;
|
||||
|
||||
for (StackFrame frame: exceptionDetails.getParsedStack())
|
||||
{
|
||||
if (frameIdx++ != 0)
|
||||
writer.writeComma();
|
||||
|
||||
writer.writeStartObject();
|
||||
|
||||
serialize(frame, writer);
|
||||
|
||||
writer.writeEndObject();
|
||||
}
|
||||
|
||||
writer.writeEndArray();
|
||||
}
|
||||
}
|
||||
|
||||
writer.writeEndObject();
|
||||
}
|
||||
}
|
||||
|
||||
private void serialize(StackFrame frame, JsonWriter writer) throws IOException
|
||||
{
|
||||
writer.writeProperty("level", frame.getLevel());
|
||||
writer.writeProperty(
|
||||
"method",
|
||||
LocalStringsUtils.populateRequiredStringWithNullValue(frame.getMethod(), "StackFrameMethod", ExceptionTelemetry.class.getName()));
|
||||
writer.writeProperty("fileName", frame.getFileName());
|
||||
|
||||
// 0 means it is unavailable
|
||||
if (frame.getLine() != 0)
|
||||
{
|
||||
writer.writeProperty("line", frame.getLine());
|
||||
}
|
||||
}
|
||||
|
||||
private void updateException(Exception exception)
|
||||
{
|
||||
private void updateException(Exception exception) {
|
||||
ArrayList<ExceptionDetails> exceptions = new ArrayList<ExceptionDetails>();
|
||||
convertExceptionTree(exception, null, exceptions);
|
||||
|
||||
this.data.setExceptions(exceptions);
|
||||
}
|
||||
|
||||
private static void convertExceptionTree(Throwable exception, ExceptionDetails parentExceptionDetails, List<ExceptionDetails> exceptions)
|
||||
{
|
||||
if (exception == null)
|
||||
private static void convertExceptionTree(Throwable exception, ExceptionDetails parentExceptionDetails, List<ExceptionDetails> exceptions) {
|
||||
if (exception == null) {
|
||||
exception = new Exception("");
|
||||
}
|
||||
|
||||
ExceptionDetails exceptionDetails = createWithStackInfo(exception, parentExceptionDetails);
|
||||
exceptions.add(exceptionDetails);
|
||||
|
||||
if (exception.getCause() != null)
|
||||
{
|
||||
if (exception.getCause() != null) {
|
||||
convertExceptionTree(exception.getCause(), exceptionDetails, exceptions);
|
||||
}
|
||||
}
|
||||
|
||||
private static ExceptionDetails createWithStackInfo(Throwable exception, ExceptionDetails parentExceptionDetails)
|
||||
{
|
||||
if (exception == null)
|
||||
{
|
||||
private static ExceptionDetails createWithStackInfo(Throwable exception, ExceptionDetails parentExceptionDetails) {
|
||||
if (exception == null) {
|
||||
throw new IllegalArgumentException("exception cannot be null");
|
||||
}
|
||||
|
||||
|
@ -224,22 +97,23 @@ public class ExceptionTelemetry extends BaseTelemetry
|
|||
exceptionDetails.setTypeName(exception.getClass().getName());
|
||||
exceptionDetails.setMessage(exception.getMessage());
|
||||
|
||||
if (parentExceptionDetails != null)
|
||||
if (parentExceptionDetails != null) {
|
||||
exceptionDetails.setOuterId(parentExceptionDetails.getId());
|
||||
}
|
||||
|
||||
StackTraceElement[] trace = exception.getStackTrace();
|
||||
|
||||
if (trace != null && trace.length > 0)
|
||||
{
|
||||
if (trace != null && trace.length > 0) {
|
||||
List<StackFrame> stack = exceptionDetails.getParsedStack();
|
||||
|
||||
// We need to present the stack trace in reverse order.
|
||||
|
||||
for (int idx = 0; idx < trace.length; idx++)
|
||||
{
|
||||
for (int idx = 0; idx < trace.length; idx++) {
|
||||
StackTraceElement elem = trace[idx];
|
||||
|
||||
if (elem.isNativeMethod()) continue;
|
||||
if (elem.isNativeMethod()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String className = elem.getClassName();
|
||||
|
||||
|
@ -248,10 +122,13 @@ public class ExceptionTelemetry extends BaseTelemetry
|
|||
frame.setFileName(elem.getFileName());
|
||||
frame.setLine(elem.getLineNumber());
|
||||
|
||||
if (!Strings.isNullOrEmpty(className))
|
||||
if (!Strings.isNullOrEmpty(className)) {
|
||||
frame.setMethod(elem.getClassName() + "." + elem.getMethodName());
|
||||
else
|
||||
}
|
||||
else {
|
||||
frame.setMethod(elem.getMethodName());
|
||||
}
|
||||
|
||||
stack.add(frame);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package com.microsoft.applicationinsights.datacontracts;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import com.microsoft.applicationinsights.extensibility.model.RequestData;
|
||||
import com.microsoft.applicationinsights.implementation.schemav2.RequestData;
|
||||
import com.microsoft.applicationinsights.util.LocalStringsUtils;
|
||||
import com.microsoft.applicationinsights.util.MapUtil;
|
||||
|
||||
|
@ -15,15 +14,13 @@ import com.google.common.base.Strings;
|
|||
/**
|
||||
* Telemetry used to track events.
|
||||
*/
|
||||
public class HttpRequestTelemetry extends BaseTelemetry
|
||||
{
|
||||
public class HttpRequestTelemetry extends BaseTelemetry<RequestData> {
|
||||
private final RequestData data;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the RequestTelemetry class.
|
||||
*/
|
||||
public HttpRequestTelemetry()
|
||||
{
|
||||
public HttpRequestTelemetry() {
|
||||
super();
|
||||
this.data = new RequestData();
|
||||
initialize(this.data.getProperties());
|
||||
|
@ -40,29 +37,27 @@ public class HttpRequestTelemetry extends BaseTelemetry
|
|||
* @param responseCode The HTTP response code.
|
||||
* @param success 'true' if the request was a success, 'false' otherwise.
|
||||
*/
|
||||
public HttpRequestTelemetry(String name, Date timestamp, long duration, String responseCode, boolean success)
|
||||
{
|
||||
public HttpRequestTelemetry(String name, Date timestamp, long duration, String responseCode, boolean success) {
|
||||
this();
|
||||
this.setName(name);
|
||||
this.setTimestamp(timestamp);
|
||||
this.setDuration(duration);
|
||||
this.setResponseCode(responseCode);
|
||||
this.setSuccess(success);
|
||||
|
||||
this.setTimestamp(timestamp);
|
||||
this.data.setStartTime(LocalStringsUtils.getDateFormatter().format(timestamp));
|
||||
}
|
||||
|
||||
Map<String, Double> getMetrics()
|
||||
{
|
||||
Map<String, Double> getMetrics() {
|
||||
return this.data.getMeasurements();
|
||||
}
|
||||
|
||||
|
||||
public String getName()
|
||||
{
|
||||
public String getName() {
|
||||
return this.data.getName();
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
public void setName(String name) {
|
||||
if (Strings.isNullOrEmpty(name)) {
|
||||
throw new IllegalArgumentException("The event name cannot be null or empty");
|
||||
}
|
||||
|
@ -74,116 +69,66 @@ public class HttpRequestTelemetry extends BaseTelemetry
|
|||
return this.data.getId();
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
public void setId(String id) {
|
||||
this.data.setId(id);
|
||||
}
|
||||
|
||||
public String getResponseCode()
|
||||
{
|
||||
public String getResponseCode() {
|
||||
return this.data.getResponseCode();
|
||||
}
|
||||
|
||||
public void setResponseCode(String responseCode)
|
||||
{
|
||||
public void setResponseCode(String responseCode) {
|
||||
// Validate
|
||||
int code = Integer.parseInt(responseCode);
|
||||
setSuccess(code < 400);
|
||||
this.data.setResponseCode(responseCode);
|
||||
}
|
||||
|
||||
public boolean isSuccess()
|
||||
{
|
||||
public boolean isSuccess() {
|
||||
return this.data.getSuccess();
|
||||
}
|
||||
|
||||
public void setSuccess(boolean success)
|
||||
{
|
||||
public void setSuccess(boolean success) {
|
||||
this.data.setSuccess(success);
|
||||
}
|
||||
|
||||
public void setDuration(long milliSeconds)
|
||||
{
|
||||
public void setDuration(long milliSeconds) {
|
||||
this.data.setDuration(LocalStringsUtils.formatDuration(milliSeconds));
|
||||
}
|
||||
|
||||
public URL getUrl() throws MalformedURLException
|
||||
{
|
||||
public URL getUrl() throws MalformedURLException {
|
||||
if (LocalStringsUtils.isNullOrEmpty(this.data.getUrl())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new URL(this.data.getUrl());
|
||||
}
|
||||
|
||||
public void setUrl(URL url)
|
||||
{
|
||||
public void setUrl(URL url) {
|
||||
this.data.setUrl(url.toString());
|
||||
}
|
||||
|
||||
public void setUrl(String url) throws MalformedURLException
|
||||
{
|
||||
public void setUrl(String url) throws MalformedURLException {
|
||||
URL u = new URL(url); // to validate and normalize
|
||||
this.data.setUrl(u.toString());
|
||||
}
|
||||
|
||||
public String getHttpMethod()
|
||||
{
|
||||
public String getHttpMethod() {
|
||||
return this.data.getHttpMethod();
|
||||
}
|
||||
|
||||
public void setHttpMethod(String httpMethod)
|
||||
{
|
||||
public void setHttpMethod(String httpMethod) {
|
||||
this.data.setHttpMethod(httpMethod);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sanitize()
|
||||
{
|
||||
protected void additionalSanitize() {
|
||||
this.data.setName(LocalStringsUtils.sanitize(this.data.getName(), 1024));
|
||||
MapUtil.sanitizeProperties(this.getProperties());
|
||||
MapUtil.sanitizeMeasurements(this.getMetrics());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(JsonWriter writer) throws IOException
|
||||
{
|
||||
writer.writeStartObject();
|
||||
|
||||
writer.writeProperty("ver", 1);
|
||||
writer.writeProperty("name", "Microsoft.ApplicationInsights.Request");
|
||||
writer.writeProperty("time", this.getTimestamp());
|
||||
|
||||
getContext().serialize(writer);
|
||||
|
||||
writer.writePropertyName("data");
|
||||
|
||||
{
|
||||
writer.writeStartObject();
|
||||
|
||||
writer.writeProperty("type", "Microsoft.ApplicationInsights.RequestData");
|
||||
|
||||
writer.writePropertyName("item");
|
||||
{
|
||||
writer.writeStartObject();
|
||||
writer.writeProperty("ver", this.data.getVer());
|
||||
writer.writeProperty("id",
|
||||
LocalStringsUtils.populateRequiredStringWithNullValue(this.data.getId(), "id", HttpRequestTelemetry.class.getName()));
|
||||
writer.writeProperty("name", this.data.getName());
|
||||
writer.writeProperty("startTime", this.getTimestamp());
|
||||
writer.writeProperty("duration", this.data.getDuration());
|
||||
writer.writeProperty("success", this.data.getSuccess());
|
||||
writer.writeProperty("responseCode",
|
||||
LocalStringsUtils.populateRequiredStringWithNullValue(this.data.getResponseCode(), "responseCode", HttpRequestTelemetry.class.getName()));
|
||||
writer.writeProperty("url", this.data.getUrl());
|
||||
writer.writeMetricsProperty("measurements", this.data.getMeasurements());
|
||||
writer.writeProperty("httpMethod", this.data.getHttpMethod());
|
||||
writer.writeProperty("properties", this.data.getProperties());
|
||||
writer.writeEndObject();
|
||||
}
|
||||
|
||||
writer.writeEndObject();
|
||||
}
|
||||
|
||||
writer.writeEndObject();
|
||||
protected RequestData getData() {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package com.microsoft.applicationinsights.datacontracts;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Created by gupele on 12/25/2014.
|
||||
*/
|
||||
public interface IJsonPropertiesContainer {
|
||||
void serialize(StringBuilder stringBuilder) throws IOException;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.microsoft.applicationinsights.datacontracts;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Created by gupele on 12/24/2014.
|
||||
*/
|
||||
public interface IJsonSerializable {
|
||||
void serialize(JsonTelemetryDataSerializer serializer) throws IOException;
|
||||
}
|
|
@ -10,5 +10,5 @@ public interface JsonSerializable
|
|||
/**
|
||||
* Writes JSON representation of the object to the specified writer.
|
||||
*/
|
||||
void serialize(JsonWriter writer) throws IOException;
|
||||
void serialize(JsonTelemetryDataSerializer serializer) throws IOException;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,276 @@
|
|||
package com.microsoft.applicationinsights.datacontracts;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import com.microsoft.applicationinsights.util.LocalStringsUtils;
|
||||
|
||||
/**
|
||||
* Created by gupele on 12/24/2014.
|
||||
*/
|
||||
public class JsonTelemetryDataSerializer {
|
||||
|
||||
private final static String JSON_SEPARATOR = ",";
|
||||
private final static String JSON_START_OBJECT = "{";
|
||||
private final static String JSON_CLOSE_OBJECT = "}";
|
||||
private final static String JSON_START_ARRAY = "[";
|
||||
private final static String JSON_CLOSE_ARRAY = "]";
|
||||
private final static String JSON_COMMA = "\"";
|
||||
private final static String JSON_NAME_VALUE_SEPARATOR = ":";
|
||||
private final static String JSON_EMPTY_OBJECT = "{}";
|
||||
|
||||
private Writer out;
|
||||
|
||||
private String separator = "";
|
||||
|
||||
public JsonTelemetryDataSerializer(Writer out) throws IOException {
|
||||
reset(out);
|
||||
}
|
||||
|
||||
public void reset(Writer out) throws IOException {
|
||||
separator = "";
|
||||
this.out = out;
|
||||
this.out.write(JSON_START_OBJECT);
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
out.write(JSON_CLOSE_OBJECT);
|
||||
out.close();
|
||||
}
|
||||
|
||||
public void write(String name, int value) throws IOException {
|
||||
writeName(name);
|
||||
out.write(JSON_COMMA);
|
||||
out.write(String.valueOf(value));
|
||||
out.write(JSON_COMMA);
|
||||
separator = JSON_SEPARATOR;
|
||||
}
|
||||
|
||||
public void write(String name, Integer value) throws IOException {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
writeName(name);
|
||||
out.write(JSON_COMMA);
|
||||
out.write(String.valueOf(value));
|
||||
out.write(JSON_COMMA);
|
||||
separator = JSON_SEPARATOR;
|
||||
}
|
||||
|
||||
public void write(String name, double value) throws IOException {
|
||||
writeName(name);
|
||||
out.write(JSON_COMMA);
|
||||
out.write(String.valueOf(value));
|
||||
out.write(JSON_COMMA);
|
||||
separator = JSON_SEPARATOR;
|
||||
}
|
||||
|
||||
public void write(String name, Double value) throws IOException {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
writeName(name);
|
||||
out.write(JSON_COMMA);
|
||||
out.write(String.valueOf(value));
|
||||
out.write(JSON_COMMA);
|
||||
separator = JSON_SEPARATOR;
|
||||
}
|
||||
|
||||
public void write(String name, short value) throws IOException {
|
||||
writeName(name);
|
||||
out.write(JSON_COMMA);
|
||||
out.write(String.valueOf(value));
|
||||
out.write(JSON_COMMA);
|
||||
separator = JSON_SEPARATOR;
|
||||
}
|
||||
|
||||
public void write(String name, Short value) throws IOException {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
writeName(name);
|
||||
out.write(JSON_COMMA);
|
||||
out.write(String.valueOf(value));
|
||||
out.write(JSON_COMMA);
|
||||
separator = JSON_SEPARATOR;
|
||||
}
|
||||
|
||||
public void write(String name, long value) throws IOException {
|
||||
writeName(name);
|
||||
out.write(JSON_COMMA);
|
||||
out.write(String.valueOf(value));
|
||||
out.write(JSON_COMMA);
|
||||
separator = JSON_SEPARATOR;
|
||||
}
|
||||
|
||||
public void write(String name, Long value) throws IOException {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
writeName(name);
|
||||
out.write(JSON_COMMA);
|
||||
out.write(String.valueOf(value));
|
||||
out.write(JSON_COMMA);
|
||||
separator = JSON_SEPARATOR;
|
||||
}
|
||||
|
||||
public void write(String name, boolean value) throws IOException {
|
||||
writeName(name);
|
||||
out.write(JSON_COMMA);
|
||||
out.write(String.valueOf(value));
|
||||
out.write(JSON_COMMA);
|
||||
separator = JSON_SEPARATOR;
|
||||
}
|
||||
|
||||
public void write(String name, Boolean value) throws IOException {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
writeName(name);
|
||||
out.write(JSON_COMMA);
|
||||
out.write(String.valueOf(value));
|
||||
out.write(JSON_COMMA);
|
||||
separator = JSON_SEPARATOR;
|
||||
}
|
||||
|
||||
public void write(String name, Date value) throws IOException {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
writeName(name);
|
||||
write(LocalStringsUtils.getDateFormatter().format(value));
|
||||
separator = JSON_SEPARATOR;
|
||||
}
|
||||
|
||||
public void write(String name, String value) throws IOException {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
writeName(name);
|
||||
out.write(JSON_COMMA);
|
||||
out.write(value);
|
||||
out.write(JSON_COMMA);
|
||||
separator = JSON_SEPARATOR;
|
||||
}
|
||||
|
||||
public <T extends JsonSerializable> void write(String name, T value) throws IOException {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String jsonStringToAppend = createJsonFor(value);
|
||||
if (Strings.isNullOrEmpty(jsonStringToAppend)) {
|
||||
return;
|
||||
}
|
||||
|
||||
writeName(name);
|
||||
out.write(jsonStringToAppend);
|
||||
|
||||
separator = JSON_SEPARATOR;
|
||||
}
|
||||
|
||||
public <T> void write(String name, Map<String, T> map) throws IOException {
|
||||
if (map == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
writeName(name);
|
||||
try {
|
||||
if (map == null || map.size() < 1) {
|
||||
out.write("null");
|
||||
} else {
|
||||
out.write(JSON_START_OBJECT);
|
||||
|
||||
separator = "";
|
||||
for (Map.Entry<String, T> entry : map.entrySet()) {
|
||||
writeName(entry.getKey());
|
||||
write(entry.getValue());
|
||||
separator = JSON_SEPARATOR;
|
||||
}
|
||||
|
||||
out.write(JSON_CLOSE_OBJECT);
|
||||
}
|
||||
} finally {
|
||||
separator = JSON_SEPARATOR;
|
||||
}
|
||||
}
|
||||
|
||||
public <T> void write(String name, List<T> list) throws IOException {
|
||||
if (list == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
writeName(name);
|
||||
try {
|
||||
if (list == null || list.size() < 1) {
|
||||
out.write("null");
|
||||
} else {
|
||||
out.write(JSON_START_ARRAY);
|
||||
separator = "";
|
||||
for (T item : list) {
|
||||
out.write(separator);
|
||||
write(item);
|
||||
separator = JSON_SEPARATOR;
|
||||
}
|
||||
|
||||
out.write(JSON_CLOSE_ARRAY);
|
||||
}
|
||||
} finally {
|
||||
separator = JSON_SEPARATOR;
|
||||
}
|
||||
}
|
||||
|
||||
private <T> void write(T item) throws IOException {
|
||||
if (item instanceof JsonSerializable) {
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
JsonTelemetryDataSerializer temp = new JsonTelemetryDataSerializer(new BufferedWriter(stringWriter));
|
||||
|
||||
String jsonStringToAppend = createJsonFor((JsonSerializable)item);
|
||||
if (Strings.isNullOrEmpty(jsonStringToAppend)) {
|
||||
return;
|
||||
}
|
||||
|
||||
out.write(jsonStringToAppend);
|
||||
} else {
|
||||
out.write(JSON_COMMA);
|
||||
out.write(String.valueOf(item));
|
||||
out.write(JSON_COMMA);
|
||||
}
|
||||
}
|
||||
|
||||
private <T extends JsonSerializable> String createJsonFor(T value) throws IOException {
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
JsonTelemetryDataSerializer temp = new JsonTelemetryDataSerializer(new BufferedWriter(stringWriter));
|
||||
|
||||
value.serialize(temp);
|
||||
temp.close();
|
||||
String jsonStringToAppend = stringWriter.toString();
|
||||
if (Strings.isNullOrEmpty(jsonStringToAppend) || JSON_EMPTY_OBJECT.equals(jsonStringToAppend)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return jsonStringToAppend;
|
||||
}
|
||||
|
||||
private void writeName(String name) throws IOException {
|
||||
out.write(separator);
|
||||
out.write(JSON_COMMA);
|
||||
out.write(name);
|
||||
out.write(JSON_COMMA);
|
||||
out.write(JSON_NAME_VALUE_SEPARATOR);
|
||||
}
|
||||
}
|
|
@ -1,24 +1,21 @@
|
|||
package com.microsoft.applicationinsights.datacontracts;
|
||||
|
||||
import java.io.IOException;
|
||||
import com.microsoft.applicationinsights.implementation.schemav2.DataPoint;
|
||||
import com.microsoft.applicationinsights.implementation.schemav2.DataPointType;
|
||||
|
||||
import com.microsoft.applicationinsights.extensibility.model.DataPoint;
|
||||
import com.microsoft.applicationinsights.extensibility.model.MetricData;
|
||||
import com.microsoft.applicationinsights.implementation.schemav2.MetricData;
|
||||
import com.microsoft.applicationinsights.util.LocalStringsUtils;
|
||||
import com.microsoft.applicationinsights.util.MapUtil;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
/**
|
||||
* Telemetry used to track events.
|
||||
*/
|
||||
public class MetricTelemetry extends BaseTelemetry
|
||||
{
|
||||
public class MetricTelemetry extends BaseTelemetry<MetricData> {
|
||||
private final MetricData data;
|
||||
private final DataPoint metric;
|
||||
private final DataPoint metric;
|
||||
|
||||
public MetricTelemetry()
|
||||
{
|
||||
public MetricTelemetry() {
|
||||
super();
|
||||
this.data = new MetricData();
|
||||
this.metric = new DataPoint();
|
||||
|
@ -26,114 +23,74 @@ public class MetricTelemetry extends BaseTelemetry
|
|||
this.data.getMetrics().add(this.metric);
|
||||
}
|
||||
|
||||
public MetricTelemetry(String name, double value)
|
||||
{
|
||||
public MetricTelemetry(String name, double value) {
|
||||
this();
|
||||
this.setName(name);
|
||||
this.metric.setValue(value);
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
public String getName() {
|
||||
return this.metric.getName();
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
public void setName(String name) {
|
||||
if (Strings.isNullOrEmpty(name)) {
|
||||
throw new IllegalArgumentException("The metric name cannot be null or empty");
|
||||
}
|
||||
|
||||
this.metric.setName(name);
|
||||
}
|
||||
|
||||
public double getValue() { return this.metric.getValue(); }
|
||||
public double getValue() {
|
||||
return this.metric.getValue();
|
||||
}
|
||||
|
||||
public void setValue(double value) { this.metric.setValue(value); }
|
||||
public void setValue(double value) {
|
||||
this.metric.setValue(value);
|
||||
}
|
||||
|
||||
public Integer getCount() { return this.metric.getCount();}
|
||||
public void setCount(Integer count) {
|
||||
this.metric.setCount(count); updateKind();
|
||||
}
|
||||
|
||||
public void setCount(Integer count) { this.metric.setCount(count); updateKind();}
|
||||
public void setMin(Double value) {
|
||||
this.metric.setMin(value); updateKind();
|
||||
}
|
||||
|
||||
public Double getMin() { return this.metric.getMin();}
|
||||
public Double getMax() {
|
||||
return this.metric.getMax();
|
||||
}
|
||||
|
||||
public void setMin(Double value) { this.metric.setMin(value); updateKind();}
|
||||
public void setMax(Double value) {
|
||||
this.metric.setMax(value); updateKind();
|
||||
}
|
||||
|
||||
public Double getMax() { return this.metric.getMax();}
|
||||
|
||||
public void setMax(Double value) { this.metric.setMax(value); updateKind();}
|
||||
|
||||
public Double getStandardDeviation() { return this.metric.getStdDev();}
|
||||
|
||||
public void setStandardDeviation(Double value) { this.metric.setStdDev(value); updateKind();}
|
||||
public void setStandardDeviation(Double value) {
|
||||
this.metric.setStdDev(value); updateKind();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sanitize()
|
||||
{
|
||||
protected void additionalSanitize() {
|
||||
this.metric.setName(LocalStringsUtils.sanitize(this.metric.getName(), 1024));
|
||||
MapUtil.sanitizeProperties(this.getProperties());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(JsonWriter writer) throws IOException
|
||||
{
|
||||
writer.writeStartObject();
|
||||
|
||||
writer.writeProperty("ver", 1);
|
||||
writer.writeProperty("name", "Microsoft.ApplicationInsights.Metric");
|
||||
writer.writeProperty("time", this.getTimestamp());
|
||||
|
||||
getContext().serialize(writer);
|
||||
|
||||
writer.writePropertyName("data");
|
||||
|
||||
{
|
||||
writer.writeStartObject();
|
||||
|
||||
writer.writeProperty("type", "Microsoft.ApplicationInsights.MetricData");
|
||||
writer.writePropertyName("item");
|
||||
|
||||
{
|
||||
writer.writeStartObject();
|
||||
writer.writeProperty("ver", this.data.getVer());
|
||||
writer.writePropertyName("metrics");
|
||||
|
||||
{
|
||||
writer.writeStartArray();
|
||||
writer.writeStartObject();
|
||||
writer.writeProperty("name", LocalStringsUtils.populateRequiredStringWithNullValue(this.metric.getName(), "name", MetricTelemetry.class.getName()));
|
||||
writer.writeProperty("kind", this.metric.getKind());
|
||||
writer.writeProperty("value", this.metric.getValue());
|
||||
writer.writeProperty("count", this.metric.getCount());
|
||||
writer.writeProperty("min", this.metric.getMin());
|
||||
writer.writeProperty("max", this.metric.getMax());
|
||||
writer.writeProperty("stdDev", this.metric.getStdDev());
|
||||
writer.writeEndObject();
|
||||
writer.writeEndArray();
|
||||
}
|
||||
|
||||
writer.writeProperty("properties", this.data.getProperties());
|
||||
|
||||
writer.writeEndObject();
|
||||
}
|
||||
|
||||
writer.writeEndObject();
|
||||
}
|
||||
|
||||
writer.writeEndObject();
|
||||
protected MetricData getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
private void updateKind()
|
||||
{
|
||||
private void updateKind() {
|
||||
boolean isAggregation =
|
||||
(metric.getCount() != null) ||
|
||||
(metric.getMin() != null) ||
|
||||
(metric.getMax() != null) ||
|
||||
(metric.getStdDev() != null);
|
||||
|
||||
if ((metric.getCount() != null) && metric.getCount() == 1)
|
||||
if ((metric.getCount() != null) && metric.getCount() == 1) {
|
||||
// Singular data point. This is not an aggregation.
|
||||
isAggregation = false;
|
||||
}
|
||||
|
||||
this.metric.setKind(isAggregation ? "Aggregation" : "Measurement");
|
||||
this.metric.setKind(isAggregation ? DataPointType.Aggregation : DataPointType.Measurement);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,151 +1,54 @@
|
|||
package com.microsoft.applicationinsights.datacontracts;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.microsoft.applicationinsights.extensibility.model.DependencyKind;
|
||||
import com.microsoft.applicationinsights.extensibility.model.RddSourceType;
|
||||
import com.microsoft.applicationinsights.extensibility.model.RemoteDependencyData;
|
||||
import com.microsoft.applicationinsights.implementation.schemav2.RemoteDependencyData;
|
||||
import com.microsoft.applicationinsights.util.LocalStringsUtils;
|
||||
import com.microsoft.applicationinsights.util.MapUtil;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
/**
|
||||
* Telemetry used to track events.
|
||||
*/
|
||||
public class RemoteDependencyTelemetry extends BaseTelemetry
|
||||
{
|
||||
public class RemoteDependencyTelemetry extends BaseTelemetry<RemoteDependencyData> {
|
||||
private final RemoteDependencyData data;
|
||||
|
||||
public RemoteDependencyTelemetry()
|
||||
{
|
||||
public RemoteDependencyTelemetry() {
|
||||
super();
|
||||
this.data = new RemoteDependencyData();
|
||||
initialize(this.data.getProperties());
|
||||
}
|
||||
|
||||
public RemoteDependencyTelemetry(String name)
|
||||
{
|
||||
public RemoteDependencyTelemetry(String name) {
|
||||
this();
|
||||
this.setName(name);
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
public String getName() {
|
||||
return this.data.getName();
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
if (Strings.isNullOrEmpty(name))
|
||||
public void setName(String name) {
|
||||
if (Strings.isNullOrEmpty(name)) {
|
||||
throw new IllegalArgumentException("The event name cannot be null or empty");
|
||||
}
|
||||
|
||||
this.data.setName(name);
|
||||
}
|
||||
|
||||
public DependencyKind getDependencyKind()
|
||||
{
|
||||
return this.data.getDependencyKind();
|
||||
}
|
||||
|
||||
public void setDependencyKind(DependencyKind dependencyKind)
|
||||
{
|
||||
this.data.setDependencyKind(dependencyKind);
|
||||
}
|
||||
|
||||
public double getValue()
|
||||
{
|
||||
public double getValue() {
|
||||
return this.data.getValue();
|
||||
}
|
||||
|
||||
public void setValue(double value)
|
||||
{
|
||||
public void setValue(double value) {
|
||||
this.data.setValue(value);
|
||||
}
|
||||
|
||||
public Integer getCount()
|
||||
{
|
||||
return this.data.getCount();
|
||||
}
|
||||
|
||||
public void setCount(Integer count)
|
||||
{
|
||||
this.data.setCount(count);
|
||||
}
|
||||
|
||||
public Boolean getSuccess()
|
||||
{
|
||||
return this.data.getSuccess();
|
||||
}
|
||||
|
||||
public void setSuccess(Boolean success)
|
||||
{
|
||||
this.data.setSuccess(success);
|
||||
}
|
||||
|
||||
public Boolean getAsync()
|
||||
{
|
||||
return this.data.getAsync();
|
||||
}
|
||||
|
||||
public void setAsync(Boolean async)
|
||||
{
|
||||
this.data.setAsync(async);
|
||||
}
|
||||
|
||||
public RddSourceType getRddSource()
|
||||
{
|
||||
return this.data.getRddSource();
|
||||
}
|
||||
|
||||
public void setRddSource(RddSourceType rddSource)
|
||||
{
|
||||
this.data.setRddSource(rddSource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sanitize()
|
||||
{
|
||||
protected void additionalSanitize() {
|
||||
this.data.setName(LocalStringsUtils.sanitize(this.data.getName(), 1024));
|
||||
MapUtil.sanitizeProperties(this.getProperties());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(JsonWriter writer) throws IOException
|
||||
{
|
||||
writer.writeStartObject();
|
||||
|
||||
writer.writeProperty("ver", 1);
|
||||
writer.writeProperty("name", "Microsoft.ApplicationInsights.RemoteDependency");
|
||||
writer.writeProperty("time", this.getTimestamp());
|
||||
|
||||
getContext().serialize(writer);
|
||||
|
||||
writer.writePropertyName("data");
|
||||
|
||||
{
|
||||
writer.writeStartObject();
|
||||
|
||||
writer.writeProperty("type", "Microsoft.ApplicationInsights.RemoteDependencyData");
|
||||
|
||||
writer.writePropertyName("item");
|
||||
{
|
||||
writer.writeStartObject();
|
||||
writer.writeProperty("ver", this.data.getVer());
|
||||
writer.writeProperty("name", this.data.getName());
|
||||
writer.writeProperty("kind", this.data.getKind());
|
||||
writer.writeProperty("value", this.data.getValue());
|
||||
writer.writeProperty("count", this.data.getCount());
|
||||
writer.writeProperty("dependencyKind", this.data.getDependencyKind().toString());
|
||||
writer.writeProperty("success", this.data.getSuccess());
|
||||
writer.writeProperty("async", this.data.getAsync());
|
||||
writer.writeProperty("source", this.data.getRddSource().getValue());
|
||||
writer.writeProperty("properties", this.data.getProperties());
|
||||
writer.writeEndObject();
|
||||
}
|
||||
|
||||
writer.writeEndObject();
|
||||
}
|
||||
|
||||
writer.writeEndObject();
|
||||
protected RemoteDependencyData getData() {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,13 @@ import java.io.IOException;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.microsoft.applicationinsights.implementation.*;
|
||||
import com.microsoft.applicationinsights.implementation.ComponentContext;
|
||||
import com.microsoft.applicationinsights.implementation.DeviceContext;
|
||||
import com.microsoft.applicationinsights.implementation.SessionContext;
|
||||
import com.microsoft.applicationinsights.implementation.UserContext;
|
||||
import com.microsoft.applicationinsights.implementation.OperationContext;
|
||||
import com.microsoft.applicationinsights.implementation.LocationContext;
|
||||
import com.microsoft.applicationinsights.implementation.InternalContext;
|
||||
import com.microsoft.applicationinsights.util.MapUtil;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
@ -12,8 +18,7 @@ import com.google.common.base.Strings;
|
|||
/**
|
||||
* Represents a context for sending telemetry to the Application Insights service.
|
||||
*/
|
||||
public class TelemetryContext implements JsonSerializable
|
||||
{
|
||||
public class TelemetryContext implements JsonSerializable {
|
||||
private Map<String,String> properties;
|
||||
private Map<String,String> tags;
|
||||
|
||||
|
@ -26,108 +31,116 @@ public class TelemetryContext implements JsonSerializable
|
|||
private LocationContext location;
|
||||
private InternalContext internal;
|
||||
|
||||
public TelemetryContext()
|
||||
{
|
||||
public TelemetryContext() {
|
||||
// TODO: create a SnapshottingMap, just like the .NET version has.
|
||||
this(new HashMap<String, String>(), new HashMap<String, String>());
|
||||
}
|
||||
|
||||
public TelemetryContext(Map<String, String> properties, Map<String, String> tags)
|
||||
{
|
||||
if (properties == null)
|
||||
public TelemetryContext(Map<String, String> properties, Map<String, String> tags) {
|
||||
if (properties == null) {
|
||||
throw new IllegalArgumentException("properties cannot be null");
|
||||
if (tags == null)
|
||||
}
|
||||
|
||||
if (tags == null) {
|
||||
throw new IllegalArgumentException("tags cannot be null");
|
||||
}
|
||||
|
||||
this.properties = properties;
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public ComponentContext getComponent()
|
||||
{
|
||||
if (component == null) component = new ComponentContext(tags);
|
||||
public ComponentContext getComponent() {
|
||||
if (component == null) {
|
||||
component = new ComponentContext(tags);
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
public DeviceContext getDevice()
|
||||
{
|
||||
if (device == null) device = new DeviceContext(tags);
|
||||
public DeviceContext getDevice() {
|
||||
if (device == null) {
|
||||
device = new DeviceContext(tags);
|
||||
}
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
public SessionContext getSession()
|
||||
{
|
||||
if (session == null) session = new SessionContext(tags);
|
||||
public SessionContext getSession() {
|
||||
if (session == null) {
|
||||
session = new SessionContext(tags);
|
||||
}
|
||||
|
||||
return session;
|
||||
}
|
||||
|
||||
public UserContext getUser()
|
||||
{
|
||||
if (user == null) user = new UserContext(tags);
|
||||
public UserContext getUser() {
|
||||
if (user == null) {
|
||||
user = new UserContext(tags);
|
||||
}
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
public OperationContext getOperation()
|
||||
{
|
||||
if (operation == null) operation = new OperationContext(tags);
|
||||
public OperationContext getOperation() {
|
||||
if (operation == null) {
|
||||
operation = new OperationContext(tags);
|
||||
}
|
||||
|
||||
return operation;
|
||||
}
|
||||
|
||||
public LocationContext getLocation()
|
||||
{
|
||||
if (location == null) location = new LocationContext(tags);
|
||||
public LocationContext getLocation() {
|
||||
if (location == null) {
|
||||
location = new LocationContext(tags);
|
||||
}
|
||||
|
||||
return location;
|
||||
}
|
||||
|
||||
public InternalContext getInternal()
|
||||
{
|
||||
if (internal == null) internal = new InternalContext(tags);
|
||||
public InternalContext getInternal() {
|
||||
if (internal == null) {
|
||||
internal = new InternalContext(tags);
|
||||
}
|
||||
|
||||
return internal;
|
||||
}
|
||||
|
||||
public String getInstrumentationKey()
|
||||
{
|
||||
public String getInstrumentationKey() {
|
||||
return instrumentationKey;
|
||||
}
|
||||
|
||||
public void setInstrumentationKey(String instrumentationKey)
|
||||
{
|
||||
public void setInstrumentationKey(String instrumentationKey) {
|
||||
this.instrumentationKey = instrumentationKey;
|
||||
}
|
||||
|
||||
public Map<String, String> getProperties()
|
||||
{
|
||||
public Map<String, String> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public Map<String, String> getTags()
|
||||
{
|
||||
public Map<String, String> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(JsonWriter writer) throws IOException
|
||||
{
|
||||
writer.writeProperty("iKey", this.getInstrumentationKey());
|
||||
writer.writeProperty("device", this.getDevice());
|
||||
writer.writeProperty("application", this.getComponent());
|
||||
writer.writeProperty("user", this.getUser());
|
||||
writer.writeProperty("operation", this.getOperation());
|
||||
writer.writeProperty("session", this.getSession());
|
||||
writer.writeProperty("location", this.getLocation());
|
||||
writer.writeProperty("internal", this.getInternal());
|
||||
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
writer.write("iKey", this.getInstrumentationKey());
|
||||
writer.write("device", this.getDevice());
|
||||
writer.write("application", this.getComponent());
|
||||
writer.write("user", this.getUser());
|
||||
writer.write("operation", this.getOperation());
|
||||
writer.write("session", this.getSession());
|
||||
writer.write("location", this.getLocation());
|
||||
writer.write("internal", this.getInternal());
|
||||
}
|
||||
|
||||
public void Initialize(TelemetryContext source)
|
||||
{
|
||||
public void Initialize(TelemetryContext source) {
|
||||
if (!Strings.isNullOrEmpty(source.getInstrumentationKey()))
|
||||
setInstrumentationKey(source.getInstrumentationKey());
|
||||
|
||||
if (source.tags != null && source.tags.size() > 0)
|
||||
{
|
||||
if (source.tags != null && source.tags.size() > 0) {
|
||||
MapUtil.copy(source.tags, this.tags);
|
||||
}
|
||||
if (source.properties != null && source.properties.size() > 0)
|
||||
{
|
||||
if (source.properties != null && source.properties.size() > 0) {
|
||||
MapUtil.copy(source.properties, this.properties);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,78 +1,36 @@
|
|||
package com.microsoft.applicationinsights.datacontracts;
|
||||
|
||||
import com.microsoft.applicationinsights.extensibility.model.MessageData;
|
||||
import com.microsoft.applicationinsights.implementation.schemav2.MessageData;
|
||||
import com.microsoft.applicationinsights.util.LocalStringsUtils;
|
||||
import com.microsoft.applicationinsights.util.MapUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Telemetry used to track events.
|
||||
*/
|
||||
public class TraceTelemetry extends BaseTelemetry
|
||||
{
|
||||
public class TraceTelemetry extends BaseTelemetry<MessageData> {
|
||||
private final MessageData data;
|
||||
|
||||
public TraceTelemetry()
|
||||
{
|
||||
public TraceTelemetry() {
|
||||
super();
|
||||
this.data = new MessageData();
|
||||
initialize(this.data.getProperties());
|
||||
}
|
||||
|
||||
public TraceTelemetry(String message)
|
||||
{
|
||||
public TraceTelemetry(String message) {
|
||||
this();
|
||||
this.setMessage(message);
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return this.data.getMessage();
|
||||
}
|
||||
|
||||
public void setMessage(String message)
|
||||
{
|
||||
public void setMessage(String message) {
|
||||
this.data.setMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sanitize()
|
||||
{
|
||||
protected void additionalSanitize() {
|
||||
this.data.setMessage(LocalStringsUtils.sanitize(this.data.getMessage(), 32768));
|
||||
MapUtil.sanitizeProperties(this.getProperties());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(JsonWriter writer) throws IOException
|
||||
{
|
||||
writer.writeStartObject();
|
||||
|
||||
writer.writeProperty("ver", 1);
|
||||
writer.writeProperty("name", "Microsoft.ApplicationInsights.Message");
|
||||
writer.writeProperty("time", this.getTimestamp());
|
||||
|
||||
getContext().serialize(writer);
|
||||
|
||||
writer.writePropertyName("data");
|
||||
|
||||
{
|
||||
writer.writeStartObject();
|
||||
|
||||
writer.writeProperty("type", "Microsoft.ApplicationInsights.MessageData");
|
||||
|
||||
writer.writePropertyName("item");
|
||||
{
|
||||
writer.writeStartObject();
|
||||
writer.writeProperty("ver", this.data.getVer());
|
||||
writer.writeProperty("message", LocalStringsUtils.populateRequiredStringWithNullValue(this.data.getMessage(), "message", TraceTelemetry.class.getName()));
|
||||
writer.writeProperty("properties", this.data.getProperties());
|
||||
writer.writeEndObject();
|
||||
}
|
||||
|
||||
writer.writeEndObject();
|
||||
}
|
||||
|
||||
writer.writeEndObject();
|
||||
protected MessageData getData() {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package com.microsoft.applicationinsights.implementation;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.*;
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonSerializable;
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
import com.microsoft.applicationinsights.extensibility.model.ContextTagKeys;
|
||||
import com.microsoft.applicationinsights.util.MapUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
public class ComponentContext implements JsonSerializable
|
||||
{
|
||||
public class ComponentContext implements JsonSerializable {
|
||||
private final Map<String, String> tags;
|
||||
|
||||
public ComponentContext(Map<String, String> tags)
|
||||
|
@ -26,11 +26,8 @@ public class ComponentContext implements JsonSerializable
|
|||
MapUtil.setStringValueOrRemove(tags, ContextTagKeys.getKeys().getApplicationVersion(), version);
|
||||
}
|
||||
|
||||
//@Override
|
||||
public void serialize(com.microsoft.applicationinsights.datacontracts.JsonWriter writer) throws IOException
|
||||
{
|
||||
writer.writeStartObject();
|
||||
writer.writeProperty("version", this.getVersion());
|
||||
writer.writeEndObject();
|
||||
@Override
|
||||
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
writer.write("version", this.getVersion());
|
||||
}
|
||||
}
|
|
@ -118,19 +118,16 @@ public class DeviceContext implements JsonSerializable
|
|||
}
|
||||
|
||||
@Override
|
||||
public void serialize(com.microsoft.applicationinsights.datacontracts.JsonWriter writer) throws IOException
|
||||
{
|
||||
writer.writeStartObject();
|
||||
writer.writeProperty("type", this.getType());
|
||||
writer.writeProperty("id", LocalStringsUtils.populateRequiredStringWithNullValue(this.getId(), "id", DeviceContext.class.getName()));
|
||||
writer.writeProperty("osVersion", this.getOperatingSystem());
|
||||
writer.writeProperty("oemName", this.getOemName());
|
||||
writer.writeProperty("model", this.getModel());
|
||||
writer.writeProperty("network", this.getNetworkType());
|
||||
writer.writeProperty("resolution", this.getScreenResolution());
|
||||
writer.writeProperty("locale", this.getLanguage());
|
||||
writer.writeProperty("roleName", this.getRoleName());
|
||||
writer.writeProperty("roleInstance", this.getRoleInstance());
|
||||
writer.writeEndObject();
|
||||
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
writer.write("type", this.getType());
|
||||
writer.write("id", LocalStringsUtils.populateRequiredStringWithNullValue(this.getId(), "id", DeviceContext.class.getName()));
|
||||
writer.write("osVersion", this.getOperatingSystem());
|
||||
writer.write("oemName", this.getOemName());
|
||||
writer.write("model", this.getModel());
|
||||
writer.write("network", this.getNetworkType());
|
||||
writer.write("resolution", this.getScreenResolution());
|
||||
writer.write("locale", this.getLanguage());
|
||||
writer.write("roleName", this.getRoleName());
|
||||
writer.write("roleInstance", this.getRoleInstance());
|
||||
}
|
||||
}
|
|
@ -7,8 +7,7 @@ import com.microsoft.applicationinsights.util.MapUtil;
|
|||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
public class InternalContext implements JsonSerializable
|
||||
{
|
||||
public class InternalContext implements JsonSerializable {
|
||||
private final Map<String, String> tags;
|
||||
|
||||
public InternalContext(Map<String, String> tags)
|
||||
|
@ -21,27 +20,21 @@ public class InternalContext implements JsonSerializable
|
|||
return MapUtil.getValueOrNull(tags, ContextTagKeys.getKeys().getInternalSdkVersion());
|
||||
}
|
||||
|
||||
public void setSdkVersion(String version)
|
||||
{
|
||||
public void setSdkVersion(String version) {
|
||||
MapUtil.setStringValueOrRemove(tags, ContextTagKeys.getKeys().getInternalSdkVersion(), version);
|
||||
}
|
||||
|
||||
String getAgentVersion()
|
||||
{
|
||||
String getAgentVersion() {
|
||||
return MapUtil.getValueOrNull(tags, ContextTagKeys.getKeys().getInternalAgentVersion());
|
||||
}
|
||||
|
||||
public void setAgentVersion(String version)
|
||||
{
|
||||
public void setAgentVersion(String version) {
|
||||
MapUtil.setStringValueOrRemove(tags, ContextTagKeys.getKeys().getInternalAgentVersion(), version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(com.microsoft.applicationinsights.datacontracts.JsonWriter writer) throws IOException
|
||||
{
|
||||
writer.writeStartObject();
|
||||
writer.writeProperty("sdkVersion", getSdkVersion());
|
||||
writer.writeProperty("agentVersion", getAgentVersion());
|
||||
writer.writeEndObject();
|
||||
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
writer.write("sdkVersion", this.getSdkVersion());
|
||||
writer.write("agentVersion", this.getAgentVersion());
|
||||
}
|
||||
}
|
|
@ -116,7 +116,7 @@ public class JsonWriter implements com.microsoft.applicationinsights.datacontrac
|
|||
public void writeProperty(String name, JsonSerializable value) throws IOException {
|
||||
if (!isNullOrEmpty(value)) {
|
||||
writePropertyName(name);
|
||||
value.serialize(this);
|
||||
//value.serialize(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ public class JsonWriter implements com.microsoft.applicationinsights.datacontrac
|
|||
}
|
||||
|
||||
emptyObjectDetector.setEmpty(true);
|
||||
value.serialize(emptyObjectDetector);
|
||||
//value.serialize(emptyObjectDetector);
|
||||
return emptyObjectDetector.isEmpty();
|
||||
}
|
||||
|
||||
|
@ -268,7 +268,7 @@ public class JsonWriter implements com.microsoft.applicationinsights.datacontrac
|
|||
@Override
|
||||
public void writeProperty(String name, JsonSerializable value) throws IOException {
|
||||
if (value != null) {
|
||||
value.serialize(this);
|
||||
//value.serialize(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,7 @@ import com.microsoft.applicationinsights.util.MapUtil;
|
|||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
public class LocationContext implements JsonSerializable
|
||||
{
|
||||
public class LocationContext implements JsonSerializable {
|
||||
private final Map<String, String> tags;
|
||||
|
||||
public LocationContext(Map<String, String> tags)
|
||||
|
@ -24,20 +23,15 @@ public class LocationContext implements JsonSerializable
|
|||
return MapUtil.getValueOrNull(tags, ContextTagKeys.getKeys().getLocationIP());
|
||||
}
|
||||
|
||||
public void setIp(String value)
|
||||
{
|
||||
if (!Strings.isNullOrEmpty(value) && isIPV4(value))
|
||||
{
|
||||
public void setIp(String value) {
|
||||
if (!Strings.isNullOrEmpty(value) && isIPV4(value)) {
|
||||
MapUtil.setStringValueOrRemove(tags, ContextTagKeys.getKeys().getLocationIP(), value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(com.microsoft.applicationinsights.datacontracts.JsonWriter writer) throws IOException
|
||||
{
|
||||
writer.writeStartObject();
|
||||
writer.writeProperty("ip", this.getIp());
|
||||
writer.writeEndObject();
|
||||
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
writer.write("ip", this.getIp());
|
||||
}
|
||||
|
||||
private boolean isIPV4(String ip) {
|
||||
|
|
|
@ -2,13 +2,13 @@ package com.microsoft.applicationinsights.implementation;
|
|||
|
||||
import com.microsoft.applicationinsights.datacontracts.*;
|
||||
import com.microsoft.applicationinsights.extensibility.model.ContextTagKeys;
|
||||
import com.microsoft.applicationinsights.util.LocalStringsUtils;
|
||||
import com.microsoft.applicationinsights.util.MapUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
public class OperationContext implements JsonSerializable
|
||||
{
|
||||
public class OperationContext implements JsonSerializable {
|
||||
private final Map<String, String> tags;
|
||||
|
||||
public OperationContext(Map<String, String> tags)
|
||||
|
@ -21,27 +21,21 @@ public class OperationContext implements JsonSerializable
|
|||
return MapUtil.getValueOrNull(tags, ContextTagKeys.getKeys().getOperationId());
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
public void setId(String id) {
|
||||
MapUtil.setStringValueOrRemove(tags, ContextTagKeys.getKeys().getOperationId(), id);
|
||||
}
|
||||
|
||||
String getName()
|
||||
{
|
||||
String getName() {
|
||||
return MapUtil.getValueOrNull(tags, ContextTagKeys.getKeys().getOperationName());
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
public void setName(String name) {
|
||||
MapUtil.setStringValueOrRemove(tags, ContextTagKeys.getKeys().getOperationName(), name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(com.microsoft.applicationinsights.datacontracts.JsonWriter writer) throws IOException
|
||||
{
|
||||
writer.writeStartObject();
|
||||
writer.writeProperty("id", this.getId());
|
||||
writer.writeProperty("name", this.getName());
|
||||
writer.writeEndObject();
|
||||
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
writer.write("id", LocalStringsUtils.populateRequiredStringWithNullValue(this.getId(), "id", DeviceContext.class.getName()));
|
||||
writer.write("name", this.getName());
|
||||
}
|
||||
}
|
|
@ -7,52 +7,41 @@ import com.microsoft.applicationinsights.util.MapUtil;
|
|||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
public class SessionContext implements JsonSerializable
|
||||
{
|
||||
public class SessionContext implements JsonSerializable {
|
||||
private final Map<String, String> tags;
|
||||
|
||||
public SessionContext(Map<String, String> tags)
|
||||
{
|
||||
public SessionContext(Map<String, String> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
String getId()
|
||||
{
|
||||
String getId() {
|
||||
return MapUtil.getValueOrNull(tags, ContextTagKeys.getKeys().getSessionId());
|
||||
}
|
||||
|
||||
public void setId(String version)
|
||||
{
|
||||
public void setId(String version) {
|
||||
MapUtil.setStringValueOrRemove(tags, ContextTagKeys.getKeys().getSessionId(), version);
|
||||
}
|
||||
|
||||
Boolean getIsFirst()
|
||||
{
|
||||
Boolean getIsFirst() {
|
||||
return MapUtil.getBoolValueOrNull(tags, ContextTagKeys.getKeys().getSessionIsFirst());
|
||||
}
|
||||
|
||||
public void setIsFirst(Boolean version)
|
||||
{
|
||||
public void setIsFirst(Boolean version) {
|
||||
MapUtil.setBoolValueOrRemove(tags, ContextTagKeys.getKeys().getSessionIsFirst(), version);
|
||||
}
|
||||
|
||||
Boolean getIsNewSession()
|
||||
{
|
||||
Boolean getIsNewSession() {
|
||||
return MapUtil.getBoolValueOrNull(tags, ContextTagKeys.getKeys().getSessionIsNew());
|
||||
}
|
||||
|
||||
public void setIsNewSession(Boolean version)
|
||||
{
|
||||
public void setIsNewSession(Boolean version) {
|
||||
MapUtil.setBoolValueOrRemove(tags, ContextTagKeys.getKeys().getSessionIsNew(), version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(com.microsoft.applicationinsights.datacontracts.JsonWriter writer) throws IOException
|
||||
{
|
||||
writer.writeStartObject();
|
||||
writer.writeProperty("id", getId());
|
||||
writer.writeProperty("firstSession", getIsFirst());
|
||||
writer.writeProperty("isNewSession", getIsNewSession());
|
||||
writer.writeEndObject();
|
||||
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
writer.write("id", this.getId());
|
||||
writer.write("firstSession", this.getIsFirst());
|
||||
writer.write("isNewSession", this.getIsNewSession());
|
||||
}
|
||||
}
|
|
@ -8,8 +8,7 @@ import java.io.IOException;
|
|||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
public class UserContext implements JsonSerializable
|
||||
{
|
||||
public class UserContext implements JsonSerializable {
|
||||
private final Map<String,String> tags;
|
||||
|
||||
public UserContext(Map<String, String> tags)
|
||||
|
@ -17,54 +16,43 @@ public class UserContext implements JsonSerializable
|
|||
this.tags = tags;
|
||||
}
|
||||
|
||||
String getId()
|
||||
{
|
||||
String getId() {
|
||||
return MapUtil.getValueOrNull(tags, ContextTagKeys.getKeys().getUserId());
|
||||
}
|
||||
|
||||
public void setId(String version)
|
||||
{
|
||||
public void setId(String version) {
|
||||
MapUtil.setStringValueOrRemove(tags, ContextTagKeys.getKeys().getUserId(), version);
|
||||
}
|
||||
|
||||
String getAccountId()
|
||||
{
|
||||
String getAccountId() {
|
||||
return MapUtil.getValueOrNull(tags, ContextTagKeys.getKeys().getUserAccountId());
|
||||
}
|
||||
|
||||
public void setAccountId(String version)
|
||||
{
|
||||
public void setAccountId(String version) {
|
||||
MapUtil.setStringValueOrRemove(tags, ContextTagKeys.getKeys().getUserAccountId(), version);
|
||||
}
|
||||
|
||||
String getUserAgent()
|
||||
{
|
||||
String getUserAgent() {
|
||||
return MapUtil.getValueOrNull(tags, ContextTagKeys.getKeys().getUserAgent());
|
||||
}
|
||||
|
||||
public void setUserAgent(String version)
|
||||
{
|
||||
public void setUserAgent(String version) {
|
||||
MapUtil.setStringValueOrRemove(tags, ContextTagKeys.getKeys().getUserAgent(), version);
|
||||
}
|
||||
|
||||
Date getAcquisitionDate()
|
||||
{
|
||||
Date getAcquisitionDate() {
|
||||
return MapUtil.getDateValueOrNull(tags, ContextTagKeys.getKeys().getUserAccountAcquisitionDate());
|
||||
}
|
||||
|
||||
public void setgetAcquisitionDate(Date version)
|
||||
{
|
||||
public void setgetAcquisitionDate(Date version) {
|
||||
MapUtil.setDateValueOrRemove(tags, ContextTagKeys.getKeys().getUserAccountAcquisitionDate(), version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(com.microsoft.applicationinsights.datacontracts.JsonWriter writer) throws IOException
|
||||
{
|
||||
writer.writeStartObject();
|
||||
writer.writeProperty("id", this.getId());
|
||||
writer.writeProperty("userAgent", this.getUserAgent());
|
||||
writer.writeProperty("accountId", this.getAccountId());
|
||||
writer.writeProperty("anonUserAcquisitionDate", this.getAcquisitionDate());
|
||||
writer.writeEndObject();
|
||||
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
writer.write("id", this.getId());
|
||||
writer.write("userAgent", this.getUserAgent());
|
||||
writer.write("accountId", this.getAccountId());
|
||||
writer.write("anonUserAcquisitionDate", this.getAcquisitionDate());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonSerializable;
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
/**
|
||||
* Data contract class Application.
|
||||
*/
|
||||
public class Application implements JsonSerializable {
|
||||
/**
|
||||
* Backing field for property Ver.
|
||||
*/
|
||||
private String ver;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the <see cref="Application"/> class.
|
||||
*/
|
||||
public Application()
|
||||
{
|
||||
this.InitializeFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Ver property.
|
||||
*/
|
||||
public String getVer() {
|
||||
return this.ver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Ver property.
|
||||
*/
|
||||
public void setVer(String value) {
|
||||
this.ver = value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds all members of this class to a hashmap
|
||||
* @param map to which the members of this class will be added.
|
||||
*/
|
||||
public void addToHashMap(HashMap<String, String> map)
|
||||
{
|
||||
if (this.ver != null) {
|
||||
map.put("ver", this.ver);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
@Override
|
||||
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
Preconditions.checkNotNull(writer, "writer must be a non-null value");
|
||||
|
||||
this.serializeContent(writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
writer.write("ver", ver);
|
||||
}
|
||||
|
||||
/**
|
||||
* Optionally initializes fields for the current context.
|
||||
*/
|
||||
protected void InitializeFields() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonSerializable;
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
/**
|
||||
* Data contract class Base.
|
||||
*/
|
||||
public abstract class Base implements JsonSerializable, SendableData{
|
||||
/**
|
||||
* Backing field for property BaseType.
|
||||
*/
|
||||
private String baseType;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the <see cref="Base"/> class.
|
||||
*/
|
||||
public Base() {
|
||||
this.InitializeFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the BaseType property.
|
||||
*/
|
||||
public String getBaseType() {
|
||||
return this.baseType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the BaseType property.
|
||||
*/
|
||||
public void setBaseType(String baseType) {
|
||||
this.baseType = baseType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
@Override
|
||||
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
Preconditions.checkNotNull(writer, "writer must be a non-null value");
|
||||
|
||||
this.serializeContent(writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
writer.write("baseType", baseType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Optionally initializes fields for the current context.
|
||||
*/
|
||||
protected void InitializeFields() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
|
||||
/**
|
||||
* Data contract class Data.
|
||||
*/
|
||||
public class Data<TDomain extends SendableData> extends Base implements SendableData {
|
||||
/**
|
||||
* Backing field for property BaseData.
|
||||
*/
|
||||
private TDomain baseData;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the <see cref="Data{TDomain}"/> class.
|
||||
*/
|
||||
public Data() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the <see cref="Data{TDomain}"/> class with base data
|
||||
*/
|
||||
public Data(TDomain baseData) {
|
||||
super();
|
||||
setBaseData(baseData);
|
||||
this.InitializeFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the BaseData property.
|
||||
*/
|
||||
public TDomain getBaseData() {
|
||||
return this.baseData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the BaseData property.
|
||||
*/
|
||||
public void setBaseData(TDomain baseData) {
|
||||
this.baseData = baseData;
|
||||
if (this.baseData != null) {
|
||||
setBaseType(baseData.getBaseTypeName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
super.serializeContent(writer);
|
||||
|
||||
writer.write("baseData", baseData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Optionally initializes fields for the current context.
|
||||
*/
|
||||
protected void InitializeFields() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEnvelopName() {
|
||||
if (baseData != null) {
|
||||
return baseData.getEnvelopName();
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBaseTypeName() {
|
||||
if (baseData != null) {
|
||||
return baseData.getBaseTypeName();
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,200 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonSerializable;
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
/**
|
||||
* Data contract class DataPoint.
|
||||
*/
|
||||
public final class DataPoint implements JsonSerializable, SendableData {
|
||||
/**
|
||||
* Backing field for property Name.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Backing field for property Kind.
|
||||
*/
|
||||
private DataPointType kind = DataPointType.Measurement;
|
||||
|
||||
/**
|
||||
* Backing field for property Value.
|
||||
*/
|
||||
private double value;
|
||||
|
||||
/**
|
||||
* Backing field for property Count.
|
||||
*/
|
||||
private Integer count;
|
||||
|
||||
/**
|
||||
* Backing field for property Min.
|
||||
*/
|
||||
private Double min;
|
||||
|
||||
/**
|
||||
* Backing field for property Max.
|
||||
*/
|
||||
private Double max;
|
||||
|
||||
/**
|
||||
* Backing field for property StdDev.
|
||||
*/
|
||||
private Double stdDev;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the <see cref="DataPoint"/> class.
|
||||
*/
|
||||
public DataPoint()
|
||||
{
|
||||
this.InitializeFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Name property.
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Name property.
|
||||
*/
|
||||
public void setName(String value) {
|
||||
this.name = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Kind property.
|
||||
*/
|
||||
public DataPointType getKind() {
|
||||
return this.kind;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Kind property.
|
||||
*/
|
||||
public void setKind(DataPointType value) {
|
||||
this.kind = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Value property.
|
||||
*/
|
||||
public double getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Value property.
|
||||
*/
|
||||
public void setValue(double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Count property.
|
||||
*/
|
||||
public Integer getCount() {
|
||||
return this.count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Count property.
|
||||
*/
|
||||
public void setCount(Integer value) {
|
||||
this.count = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Min property.
|
||||
*/
|
||||
public Double getMin() {
|
||||
return this.min;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Min property.
|
||||
*/
|
||||
public void setMin(Double value) {
|
||||
this.min = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Max property.
|
||||
*/
|
||||
public Double getMax() {
|
||||
return this.max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Max property.
|
||||
*/
|
||||
public void setMax(Double value) {
|
||||
this.max = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the StdDev property.
|
||||
*/
|
||||
public Double getStdDev() {
|
||||
return this.stdDev;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the StdDev property.
|
||||
*/
|
||||
public void setStdDev(Double value) {
|
||||
this.stdDev = value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
@Override
|
||||
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
Preconditions.checkNotNull(writer, "writer should be a nno-null value");
|
||||
|
||||
serializeContent(writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
writer.write("name", name);
|
||||
|
||||
if (!DataPointType.Measurement.equals(kind)) {
|
||||
writer.write("kind", kind.getValue());
|
||||
}
|
||||
|
||||
writer.write("value", value);
|
||||
writer.write("count", count);
|
||||
writer.write("min", min);
|
||||
writer.write("max", max);
|
||||
writer.write("stdDev", stdDev);
|
||||
}
|
||||
|
||||
/**
|
||||
* Optionally initializes fields for the current context.
|
||||
*/
|
||||
protected void InitializeFields() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEnvelopName() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBaseTypeName() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
/**
|
||||
* Enum DataPointType.
|
||||
*/
|
||||
public enum DataPointType
|
||||
{
|
||||
Measurement(0),
|
||||
Aggregation(1);
|
||||
|
||||
private final int id;
|
||||
|
||||
public int getValue() {
|
||||
return id;
|
||||
}
|
||||
|
||||
DataPointType(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
/**
|
||||
* Enum DependencyKind.
|
||||
*/
|
||||
public enum DependencyKind
|
||||
{
|
||||
Undefind(0),
|
||||
HttpOnly(1),
|
||||
HttpAny(2),
|
||||
SQL(3);
|
||||
|
||||
private final int id;
|
||||
|
||||
public int getValue() {
|
||||
return id;
|
||||
}
|
||||
|
||||
DependencyKind(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
/**
|
||||
* Enum DependencySourceType.
|
||||
*/
|
||||
public enum DependencySourceType {
|
||||
Undefined(0),
|
||||
Aic(1),
|
||||
Apmc(2);
|
||||
|
||||
private final int id;
|
||||
|
||||
public int getValue() {
|
||||
return id;
|
||||
}
|
||||
|
||||
DependencySourceType(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,370 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonSerializable;
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
/**
|
||||
* Data contract class Device.
|
||||
*/
|
||||
public class Device implements JsonSerializable {
|
||||
/**
|
||||
* Backing field for property Id.
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* Backing field for property Ip.
|
||||
*/
|
||||
private String ip;
|
||||
|
||||
/**
|
||||
* Backing field for property Language.
|
||||
*/
|
||||
private String language;
|
||||
|
||||
/**
|
||||
* Backing field for property Locale.
|
||||
*/
|
||||
private String locale;
|
||||
|
||||
/**
|
||||
* Backing field for property Model.
|
||||
*/
|
||||
private String model;
|
||||
|
||||
/**
|
||||
* Backing field for property Network.
|
||||
*/
|
||||
private String network;
|
||||
|
||||
/**
|
||||
* Backing field for property OemName.
|
||||
*/
|
||||
private String oemName;
|
||||
|
||||
/**
|
||||
* Backing field for property Os.
|
||||
*/
|
||||
private String os;
|
||||
|
||||
/**
|
||||
* Backing field for property OsVersion.
|
||||
*/
|
||||
private String osVersion;
|
||||
|
||||
/**
|
||||
* Backing field for property RoleInstance.
|
||||
*/
|
||||
private String roleInstance;
|
||||
|
||||
/**
|
||||
* Backing field for property RoleName.
|
||||
*/
|
||||
private String roleName;
|
||||
|
||||
/**
|
||||
* Backing field for property ScreenResolution.
|
||||
*/
|
||||
private String screenResolution;
|
||||
|
||||
/**
|
||||
* Backing field for property Type.
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* Backing field for property VmName.
|
||||
*/
|
||||
private String vmName;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the <see cref="Device"/> class.
|
||||
*/
|
||||
public Device() {
|
||||
this.InitializeFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Id property.
|
||||
*/
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Id property.
|
||||
*/
|
||||
public void setId(String value) {
|
||||
this.id = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Ip property.
|
||||
*/
|
||||
public String getIp() {
|
||||
return this.ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Ip property.
|
||||
*/
|
||||
public void setIp(String value) {
|
||||
this.ip = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Language property.
|
||||
*/
|
||||
public String getLanguage() {
|
||||
return this.language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Language property.
|
||||
*/
|
||||
public void setLanguage(String value) {
|
||||
this.language = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Locale property.
|
||||
*/
|
||||
public String getLocale() {
|
||||
return this.locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Locale property.
|
||||
*/
|
||||
public void setLocale(String value) {
|
||||
this.locale = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Model property.
|
||||
*/
|
||||
public String getModel() {
|
||||
return this.model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Model property.
|
||||
*/
|
||||
public void setModel(String value) {
|
||||
this.model = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Network property.
|
||||
*/
|
||||
public String getNetwork() {
|
||||
return this.network;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Network property.
|
||||
*/
|
||||
public void setNetwork(String value) {
|
||||
this.network = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the OemName property.
|
||||
*/
|
||||
public String getOemName() {
|
||||
return this.oemName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the OemName property.
|
||||
*/
|
||||
public void setOemName(String value) {
|
||||
this.oemName = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Os property.
|
||||
*/
|
||||
public String getOs() {
|
||||
return this.os;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Os property.
|
||||
*/
|
||||
public void setOs(String value) {
|
||||
this.os = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the OsVersion property.
|
||||
*/
|
||||
public String getOsVersion() {
|
||||
return this.osVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the OsVersion property.
|
||||
*/
|
||||
public void setOsVersion(String value) {
|
||||
this.osVersion = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the RoleInstance property.
|
||||
*/
|
||||
public String getRoleInstance() {
|
||||
return this.roleInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the RoleInstance property.
|
||||
*/
|
||||
public void setRoleInstance(String value) {
|
||||
this.roleInstance = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the RoleName property.
|
||||
*/
|
||||
public String getRoleName() {
|
||||
return this.roleName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the RoleName property.
|
||||
*/
|
||||
public void setRoleName(String value) {
|
||||
this.roleName = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ScreenResolution property.
|
||||
*/
|
||||
public String getScreenResolution() {
|
||||
return this.screenResolution;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ScreenResolution property.
|
||||
*/
|
||||
public void setScreenResolution(String value) {
|
||||
this.screenResolution = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Type property.
|
||||
*/
|
||||
public String getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Type property.
|
||||
*/
|
||||
public void setType(String value) {
|
||||
this.type = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the VmName property.
|
||||
*/
|
||||
public String getVmName() {
|
||||
return this.vmName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the VmName property.
|
||||
*/
|
||||
public void setVmName(String value) {
|
||||
this.vmName = value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds all members of this class to a hashmap
|
||||
* @param map to which the members of this class will be added.
|
||||
*/
|
||||
public void addToHashMap(HashMap<String, String> map)
|
||||
{
|
||||
if (this.id != null) {
|
||||
map.put("id", this.id);
|
||||
}
|
||||
if (this.ip != null) {
|
||||
map.put("ip", this.ip);
|
||||
}
|
||||
if (this.language != null) {
|
||||
map.put("language", this.language);
|
||||
}
|
||||
if (this.locale != null) {
|
||||
map.put("locale", this.locale);
|
||||
}
|
||||
if (this.model != null) {
|
||||
map.put("model", this.model);
|
||||
}
|
||||
if (this.network != null) {
|
||||
map.put("network", this.network);
|
||||
}
|
||||
if (this.oemName != null) {
|
||||
map.put("oemName", this.oemName);
|
||||
}
|
||||
if (this.os != null) {
|
||||
map.put("os", this.os);
|
||||
}
|
||||
if (this.osVersion != null) {
|
||||
map.put("osVersion", this.osVersion);
|
||||
}
|
||||
if (this.roleInstance != null) {
|
||||
map.put("roleInstance", this.roleInstance);
|
||||
}
|
||||
if (this.roleName != null) {
|
||||
map.put("roleName", this.roleName);
|
||||
}
|
||||
if (this.screenResolution != null) {
|
||||
map.put("screenResolution", this.screenResolution);
|
||||
}
|
||||
if (this.type != null) {
|
||||
map.put("type", this.type);
|
||||
}
|
||||
if (this.vmName != null) {
|
||||
map.put("vmName", this.vmName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
Preconditions.checkNotNull(writer, "writer must be a non-null value");
|
||||
|
||||
this.serializeContent(writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
writer.write("id", id);
|
||||
writer.write("ip", ip);
|
||||
writer.write("language", language);
|
||||
writer.write("locale", locale);
|
||||
writer.write("model", model);
|
||||
writer.write("locale", locale);
|
||||
writer.write("network", network);
|
||||
writer.write("oemName", oemName);
|
||||
writer.write("os", os);
|
||||
writer.write("osVersion", osVersion);
|
||||
writer.write("roleInstance", roleInstance);
|
||||
writer.write("roleName", roleName);
|
||||
writer.write("screenResolution", screenResolution);
|
||||
writer.write("type", type);
|
||||
writer.write("vmName", vmName);
|
||||
}
|
||||
|
||||
protected void InitializeFields() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonSerializable;
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
/**
|
||||
* Data contract class Domain.
|
||||
*/
|
||||
public class Domain implements SendableData
|
||||
{
|
||||
/**
|
||||
* Envelope Name for this telemetry.
|
||||
*/
|
||||
private static final String DOMAIN_ENVELOPE_NAME = "Microsoft.ApplicationInsights.Do";
|
||||
|
||||
/**
|
||||
* Base Type for this telemetry.
|
||||
*/
|
||||
private static final String DOMAIN_BASE_TYPE = "Microsoft.ApplicationInsights.Domain";
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the <see cref="Domain"/> class.
|
||||
*/
|
||||
public Domain() {
|
||||
this.InitializeFields();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
@Override
|
||||
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
Preconditions.checkNotNull(writer, "writer must be a non-null value");
|
||||
|
||||
this.serializeContent(writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
}
|
||||
|
||||
protected void InitializeFields() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEnvelopName() {
|
||||
return DOMAIN_ENVELOPE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBaseTypeName() {
|
||||
return DOMAIN_BASE_TYPE;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,349 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonSerializable;
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
/**
|
||||
* Data contract class Envelope.
|
||||
*/
|
||||
public class Envelope implements JsonSerializable
|
||||
{
|
||||
/**
|
||||
* Backing field for property Ver.
|
||||
*/
|
||||
private int ver = 1;
|
||||
|
||||
/**
|
||||
* Backing field for property Name.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Backing field for property Time.
|
||||
*/
|
||||
private String time;
|
||||
|
||||
/**
|
||||
* Backing field for property SampleRate.
|
||||
*/
|
||||
private double sampleRate = 100.0;
|
||||
|
||||
/**
|
||||
* Backing field for property Seq.
|
||||
*/
|
||||
private String seq;
|
||||
|
||||
/**
|
||||
* Backing field for property IKey.
|
||||
*/
|
||||
private String iKey;
|
||||
|
||||
/**
|
||||
* Backing field for property Flags.
|
||||
*/
|
||||
private long flags;
|
||||
|
||||
/**
|
||||
* Backing field for property DeviceId.
|
||||
*/
|
||||
private String deviceId;
|
||||
|
||||
/**
|
||||
* Backing field for property Os.
|
||||
*/
|
||||
private String os;
|
||||
|
||||
/**
|
||||
* Backing field for property OsVer.
|
||||
*/
|
||||
private String osVer;
|
||||
|
||||
/**
|
||||
* Backing field for property AppId.
|
||||
*/
|
||||
private String appId;
|
||||
|
||||
/**
|
||||
* Backing field for property AppVer.
|
||||
*/
|
||||
private String appVer;
|
||||
|
||||
/**
|
||||
* Backing field for property UserId.
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* Backing field for property Tags.
|
||||
*/
|
||||
private Map<String, String> tags;
|
||||
|
||||
/**
|
||||
* Backing field for property Data.
|
||||
*/
|
||||
private Base data;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the <see cref="Envelope"/> class.
|
||||
*/
|
||||
public Envelope() {
|
||||
this.InitializeFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Ver property.
|
||||
*/
|
||||
public int getVer() {
|
||||
return this.ver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Ver property.
|
||||
*/
|
||||
public void setVer(int value) {
|
||||
this.ver = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Name property.
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Name property.
|
||||
*/
|
||||
public void setName(String value) {
|
||||
this.name = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Time property.
|
||||
*/
|
||||
public String getTime() {
|
||||
return this.time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Time property.
|
||||
*/
|
||||
public void setTime(String value) {
|
||||
this.time = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the SampleRate property.
|
||||
*/
|
||||
public double getSampleRate() {
|
||||
return this.sampleRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the SampleRate property.
|
||||
*/
|
||||
public void setSampleRate(double value) {
|
||||
this.sampleRate = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Seq property.
|
||||
*/
|
||||
public String getSeq() {
|
||||
return this.seq;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Seq property.
|
||||
*/
|
||||
public void setSeq(String value) {
|
||||
this.seq = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the IKey property.
|
||||
*/
|
||||
public String getIKey() {
|
||||
return this.iKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the IKey property.
|
||||
*/
|
||||
public void setIKey(String value) {
|
||||
this.iKey = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Flags property.
|
||||
*/
|
||||
public long getFlags() {
|
||||
return this.flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Flags property.
|
||||
*/
|
||||
public void setFlags(long value) {
|
||||
this.flags = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the DeviceId property.
|
||||
*/
|
||||
public String getDeviceId() {
|
||||
return this.deviceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the DeviceId property.
|
||||
*/
|
||||
public void setDeviceId(String value) {
|
||||
this.deviceId = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Os property.
|
||||
*/
|
||||
public String getOs() {
|
||||
return this.os;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Os property.
|
||||
*/
|
||||
public void setOs(String value) {
|
||||
this.os = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the OsVer property.
|
||||
*/
|
||||
public String getOsVer() {
|
||||
return this.osVer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the OsVer property.
|
||||
*/
|
||||
public void setOsVer(String value) {
|
||||
this.osVer = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the AppId property.
|
||||
*/
|
||||
public String getAppId() {
|
||||
return this.appId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the AppId property.
|
||||
*/
|
||||
public void setAppId(String value) {
|
||||
this.appId = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the AppVer property.
|
||||
*/
|
||||
public String getAppVer() {
|
||||
return this.appVer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the AppVer property.
|
||||
*/
|
||||
public void setAppVer(String value) {
|
||||
this.appVer = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the UserId property.
|
||||
*/
|
||||
public String getUserId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the UserId property.
|
||||
*/
|
||||
public void setUserId(String value) {
|
||||
this.userId = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Tags property.
|
||||
*/
|
||||
public Map<String, String> getTags() {
|
||||
if (this.tags == null) {
|
||||
this.tags = new HashMap<String, String>();
|
||||
}
|
||||
|
||||
return this.tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Tags property.
|
||||
*/
|
||||
public void setTags(Map<String, String> value) {
|
||||
this.tags = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Data property.
|
||||
*/
|
||||
public Base getData() {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Data property.
|
||||
*/
|
||||
public void setData(Base value) {
|
||||
this.data = value;
|
||||
this.setName(data.getEnvelopName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
@Override
|
||||
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
Preconditions.checkNotNull(writer, "writer must be a non-null value");
|
||||
|
||||
this.serializeContent(writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
writer.write("ver", ver);
|
||||
writer.write("name", name);
|
||||
writer.write("time", time);
|
||||
writer.write("sampleRate", sampleRate);
|
||||
writer.write("seq", seq);
|
||||
writer.write("iKey", iKey);
|
||||
writer.write("flags", flags);
|
||||
writer.write("deviceId", deviceId);
|
||||
writer.write("os", os);
|
||||
writer.write("osVer", osVer);
|
||||
writer.write("appId", appId);
|
||||
writer.write("appVer", appVer);
|
||||
writer.write("userId", userId);
|
||||
writer.write("tags", tags);
|
||||
writer.write("data", data);
|
||||
}
|
||||
|
||||
protected void InitializeFields() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,142 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
/**
|
||||
* Data contract class EventData.
|
||||
*/
|
||||
public class EventData extends Domain {
|
||||
/**
|
||||
* Envelope Name for this telemetry.
|
||||
*/
|
||||
private static final String EVENT_ENVELOPE_NAME = "Microsoft.ApplicationInsights.Event";
|
||||
|
||||
/**
|
||||
* Base Type for this telemetry.
|
||||
*/
|
||||
private static final String EVENT_BASE_TYPE = "Microsoft.ApplicationInsights.EventData";
|
||||
|
||||
/**
|
||||
* Backing field for property Ver.
|
||||
*/
|
||||
private int ver = 2;
|
||||
|
||||
/**
|
||||
* Backing field for property Name.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Backing field for property Properties.
|
||||
*/
|
||||
private HashMap<String, String> properties;
|
||||
|
||||
/**
|
||||
* Backing field for property Measurements.
|
||||
*/
|
||||
private HashMap<String, Double> measurements;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the <see cref="EventData"/> class.
|
||||
*/
|
||||
public EventData() {
|
||||
this.InitializeFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Ver property.
|
||||
*/
|
||||
public int getVer() {
|
||||
return this.ver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Ver property.
|
||||
*/
|
||||
public void setVer(int value) {
|
||||
this.ver = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Name property.
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Name property.
|
||||
*/
|
||||
public void setName(String value) {
|
||||
this.name = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Properties property.
|
||||
*/
|
||||
public HashMap<String, String> getProperties() {
|
||||
if (this.properties == null) {
|
||||
this.properties = new HashMap<String, String>();
|
||||
}
|
||||
return this.properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Properties property.
|
||||
*/
|
||||
public void setProperties(HashMap<String, String> value) {
|
||||
this.properties = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Measurements property.
|
||||
*/
|
||||
public HashMap<String, Double> getMeasurements() {
|
||||
if (this.measurements == null) {
|
||||
this.measurements = new HashMap<String, Double>();
|
||||
}
|
||||
return this.measurements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Measurements property.
|
||||
*/
|
||||
public void setMeasurements(HashMap<String, Double> value) {
|
||||
this.measurements = value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
Preconditions.checkNotNull(writer, "writer must be a non-null value");
|
||||
|
||||
writer.write("ver", ver);
|
||||
writer.write("name", name);
|
||||
writer.write("properties", properties);
|
||||
writer.write("measurements", measurements);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEnvelopName() {
|
||||
return EVENT_ENVELOPE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBaseTypeName() {
|
||||
return EVENT_BASE_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optionally initializes fields for the current context.
|
||||
*/
|
||||
protected void InitializeFields() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonSerializable;
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Created by gupele on 12/24/2014.
|
||||
*/
|
||||
public class EventDataWrapper implements JsonSerializable {
|
||||
private final EventData item;
|
||||
|
||||
public EventDataWrapper() {
|
||||
item = new EventData();
|
||||
}
|
||||
|
||||
public EventData getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
Preconditions.checkNotNull(writer, "writer must be a non-null value");
|
||||
|
||||
writer.write("type", "Microsoft.ApplicationInsights.EventData");
|
||||
writer.write("item", item);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,192 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonSerializable;
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
/**
|
||||
* Data contract class ExceptionData.
|
||||
*/
|
||||
public class ExceptionData extends Domain implements JsonSerializable {
|
||||
/**
|
||||
* Envelope Name for this telemetry.
|
||||
*/
|
||||
public static final String EXCEPTION_ENVELOPE_NAME = "Microsoft.ApplicationInsights.Exception";
|
||||
|
||||
/**
|
||||
* Base Type for this telemetry.
|
||||
*/
|
||||
public static final String EXCEPTION_BASE_TYPE = "Microsoft.ApplicationInsights.ExceptionData";
|
||||
|
||||
/**
|
||||
* Backing field for property Ver.
|
||||
*/
|
||||
private int ver = 2;
|
||||
|
||||
/**
|
||||
* Backing field for property HandledAt.
|
||||
*/
|
||||
private String handledAt;
|
||||
|
||||
/**
|
||||
* Backing field for property Exceptions.
|
||||
*/
|
||||
private ArrayList<ExceptionDetails> exceptions;
|
||||
|
||||
/**
|
||||
* Backing field for property SeverityLevel.
|
||||
*/
|
||||
private int severityLevel;
|
||||
|
||||
/**
|
||||
* Backing field for property Properties.
|
||||
*/
|
||||
private HashMap<String, String> properties;
|
||||
|
||||
/**
|
||||
* Backing field for property Measurements.
|
||||
*/
|
||||
private HashMap<String, Double> measurements;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the <see cref="ExceptionData"/> class.
|
||||
*/
|
||||
public ExceptionData()
|
||||
{
|
||||
this.InitializeFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Ver property.
|
||||
*/
|
||||
public int getVer() {
|
||||
return this.ver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Ver property.
|
||||
*/
|
||||
public void setVer(int value) {
|
||||
this.ver = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the HandledAt property.
|
||||
*/
|
||||
public String getHandledAt() {
|
||||
return this.handledAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the HandledAt property.
|
||||
*/
|
||||
public void setHandledAt(String value) {
|
||||
this.handledAt = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Exceptions property.
|
||||
*/
|
||||
public ArrayList<ExceptionDetails> getExceptions() {
|
||||
if (this.exceptions == null) {
|
||||
this.exceptions = new ArrayList<ExceptionDetails>();
|
||||
}
|
||||
return this.exceptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Exceptions property.
|
||||
*/
|
||||
public void setExceptions(ArrayList<ExceptionDetails> value) {
|
||||
this.exceptions = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the SeverityLevel property.
|
||||
*/
|
||||
public int getSeverityLevel() {
|
||||
return this.severityLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the SeverityLevel property.
|
||||
*/
|
||||
public void setSeverityLevel(int value) {
|
||||
this.severityLevel = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Properties property.
|
||||
*/
|
||||
public HashMap<String, String> getProperties() {
|
||||
if (this.properties == null) {
|
||||
this.properties = new HashMap<String, String>();
|
||||
}
|
||||
return this.properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Properties property.
|
||||
*/
|
||||
public void setProperties(HashMap<String, String> value) {
|
||||
this.properties = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Measurements property.
|
||||
*/
|
||||
public HashMap<String, Double> getMeasurements() {
|
||||
if (this.measurements == null) {
|
||||
this.measurements = new HashMap<String, Double>();
|
||||
}
|
||||
return this.measurements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Measurements property.
|
||||
*/
|
||||
public void setMeasurements(HashMap<String, Double> value) {
|
||||
this.measurements = value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOException
|
||||
{
|
||||
Preconditions.checkNotNull(writer, "writer must be a non-null value");
|
||||
|
||||
super.serializeContent(writer);
|
||||
|
||||
writer.write("ver", ver);
|
||||
writer.write("handledAt", handledAt);
|
||||
writer.write("exceptions", exceptions);
|
||||
writer.write("measurements", measurements);
|
||||
writer.write("severityLevel", severityLevel);
|
||||
writer.write("properties", properties);
|
||||
writer.write("measurements", measurements);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEnvelopName() {
|
||||
return EXCEPTION_ENVELOPE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBaseTypeName() {
|
||||
return EXCEPTION_BASE_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optionally initializes fields for the current context.
|
||||
*/
|
||||
protected void InitializeFields() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,192 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonSerializable;
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
/**
|
||||
* Data contract class ExceptionDetails.
|
||||
*/
|
||||
public class ExceptionDetails implements JsonSerializable {
|
||||
/**
|
||||
* Backing field for property Id.
|
||||
*/
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* Backing field for property OuterId.
|
||||
*/
|
||||
private int outerId;
|
||||
|
||||
/**
|
||||
* Backing field for property TypeName.
|
||||
*/
|
||||
private String typeName;
|
||||
|
||||
/**
|
||||
* Backing field for property Message.
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* Backing field for property HasFullStack.
|
||||
*/
|
||||
private boolean hasFullStack = true;
|
||||
|
||||
/**
|
||||
* Backing field for property Stack.
|
||||
*/
|
||||
private String stack;
|
||||
|
||||
/**
|
||||
* Backing field for property ParsedStack.
|
||||
*/
|
||||
private ArrayList<StackFrame> parsedStack;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the <see cref="ExceptionDetails"/> class.
|
||||
*/
|
||||
public ExceptionDetails()
|
||||
{
|
||||
this.InitializeFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Id property.
|
||||
*/
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Id property.
|
||||
*/
|
||||
public void setId(int value) {
|
||||
this.id = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the OuterId property.
|
||||
*/
|
||||
public int getOuterId() {
|
||||
return this.outerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the OuterId property.
|
||||
*/
|
||||
public void setOuterId(int value) {
|
||||
this.outerId = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the TypeName property.
|
||||
*/
|
||||
public String getTypeName() {
|
||||
return this.typeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the TypeName property.
|
||||
*/
|
||||
public void setTypeName(String value) {
|
||||
this.typeName = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Message property.
|
||||
*/
|
||||
public String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Message property.
|
||||
*/
|
||||
public void setMessage(String value) {
|
||||
this.message = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the HasFullStack property.
|
||||
*/
|
||||
public boolean getHasFullStack() {
|
||||
return this.hasFullStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the HasFullStack property.
|
||||
*/
|
||||
public void setHasFullStack(boolean value) {
|
||||
this.hasFullStack = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Stack property.
|
||||
*/
|
||||
public String getStack() {
|
||||
return this.stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Stack property.
|
||||
*/
|
||||
public void setStack(String value) {
|
||||
this.stack = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ParsedStack property.
|
||||
*/
|
||||
public ArrayList<StackFrame> getParsedStack() {
|
||||
if (this.parsedStack == null) {
|
||||
this.parsedStack = new ArrayList<StackFrame>();
|
||||
}
|
||||
return this.parsedStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ParsedStack property.
|
||||
*/
|
||||
public void setParsedStack(ArrayList<StackFrame> value) {
|
||||
this.parsedStack = value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
@Override
|
||||
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
Preconditions.checkNotNull(writer, "writer must be a non-null value");
|
||||
|
||||
this.serializeContent(writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOException
|
||||
{
|
||||
writer.write("id", id);
|
||||
writer.write("outerId", outerId);
|
||||
writer.write("typeName", typeName);
|
||||
writer.write("message", message);
|
||||
writer.write("hasFullStack", hasFullStack);
|
||||
writer.write("stack", stack);
|
||||
writer.write("parsedStack", parsedStack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Optionally initializes fields for the current context.
|
||||
*/
|
||||
protected void InitializeFields() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonSerializable;
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
public class Internal implements JsonSerializable {
|
||||
/**
|
||||
* Backing field for property SdkVersion.
|
||||
*/
|
||||
private String sdkVersion;
|
||||
|
||||
/**
|
||||
* Backing field for property AgentVersion.
|
||||
*/
|
||||
private String agentVersion;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the <see cref="Internal"/> class.
|
||||
*/
|
||||
public Internal()
|
||||
{
|
||||
this.InitializeFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the SdkVersion property.
|
||||
*/
|
||||
public String getSdkVersion() {
|
||||
return this.sdkVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the SdkVersion property.
|
||||
*/
|
||||
public void setSdkVersion(String value) {
|
||||
this.sdkVersion = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the AgentVersion property.
|
||||
*/
|
||||
public String getAgentVersion() {
|
||||
return this.agentVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the AgentVersion property.
|
||||
*/
|
||||
public void setAgentVersion(String value) {
|
||||
this.agentVersion = value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds all members of this class to a hashmap
|
||||
* @param map to which the members of this class will be added.
|
||||
*/
|
||||
public void addToHashMap(HashMap<String, String> map)
|
||||
{
|
||||
if (this.sdkVersion != null) {
|
||||
map.put("sdkVersion", this.sdkVersion);
|
||||
}
|
||||
if (this.agentVersion != null) {
|
||||
map.put("agentVersion", this.agentVersion);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
@Override
|
||||
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
Preconditions.checkNotNull(writer, "writer must be a non-null value");
|
||||
|
||||
this.serializeContent(writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOException
|
||||
{
|
||||
writer.write("sdkVersion", sdkVersion);
|
||||
writer.write("agentVersion", agentVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* Optionally initializes fields for the current context.
|
||||
*/
|
||||
protected void InitializeFields() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonSerializable;
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
/**
|
||||
* Data contract class Location.
|
||||
*/
|
||||
public class Location implements JsonSerializable {
|
||||
/**
|
||||
* Backing field for property Ip.
|
||||
*/
|
||||
private String ip;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the <see cref="Location"/> class.
|
||||
*/
|
||||
public Location()
|
||||
{
|
||||
this.InitializeFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Ip property.
|
||||
*/
|
||||
public String getIp() {
|
||||
return this.ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Ip property.
|
||||
*/
|
||||
public void setIp(String value) {
|
||||
this.ip = value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds all members of this class to a hashmap
|
||||
* @param map to which the members of this class will be added.
|
||||
*/
|
||||
public void addToHashMap(HashMap<String, String> map)
|
||||
{
|
||||
if (!(this.ip == null)) {
|
||||
map.put("ip", this.ip);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
@Override
|
||||
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
Preconditions.checkNotNull(writer, "writer must be a non-null value");
|
||||
|
||||
serializeContent(writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOException
|
||||
{
|
||||
writer.write("ip", ip);
|
||||
}
|
||||
|
||||
/**
|
||||
* Optionally initializes fields for the current context.
|
||||
*/
|
||||
protected void InitializeFields() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonSerializable;
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
|
||||
/**
|
||||
* Data contract class MessageData.
|
||||
*/
|
||||
public class MessageData extends Domain implements JsonSerializable {
|
||||
/**
|
||||
* Envelope Name for this telemetry.
|
||||
*/
|
||||
public static final String MESSAGE_ENVELOPE_NAME = "Microsoft.ApplicationInsights.Message";
|
||||
|
||||
/**
|
||||
* Base Type for this telemetry.
|
||||
*/
|
||||
public static final String MESSAGE_BASE_TYPE = "Microsoft.ApplicationInsights.MessageData";
|
||||
|
||||
/**
|
||||
* Backing field for property Ver.
|
||||
*/
|
||||
private int ver = 2;
|
||||
|
||||
/**
|
||||
* Backing field for property Message.
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* Backing field for property SeverityLevel.
|
||||
*/
|
||||
private int severityLevel;
|
||||
|
||||
/**
|
||||
* Backing field for property Properties.
|
||||
*/
|
||||
private HashMap<String, String> properties;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the <see cref="MessageData"/> class.
|
||||
*/
|
||||
public MessageData()
|
||||
{
|
||||
this.InitializeFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Ver property.
|
||||
*/
|
||||
public int getVer() {
|
||||
return this.ver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Ver property.
|
||||
*/
|
||||
public void setVer(int value) {
|
||||
this.ver = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Message property.
|
||||
*/
|
||||
public String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Message property.
|
||||
*/
|
||||
public void setMessage(String value) {
|
||||
this.message = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the SeverityLevel property.
|
||||
*/
|
||||
public int getSeverityLevel() {
|
||||
return this.severityLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the SeverityLevel property.
|
||||
*/
|
||||
public void setSeverityLevel(int value) {
|
||||
this.severityLevel = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Properties property.
|
||||
*/
|
||||
public HashMap<String, String> getProperties() {
|
||||
if (this.properties == null) {
|
||||
this.properties = new HashMap<String, String>();
|
||||
}
|
||||
return this.properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Properties property.
|
||||
*/
|
||||
public void setProperties(HashMap<String, String> value) {
|
||||
this.properties = value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOException
|
||||
{
|
||||
super.serializeContent(writer);
|
||||
|
||||
writer.write("ver", ver);
|
||||
writer.write("message", message);
|
||||
writer.write("severityLevel", severityLevel);
|
||||
writer.write("properties", properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEnvelopName() {
|
||||
return MESSAGE_ENVELOPE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBaseTypeName() {
|
||||
return MESSAGE_BASE_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optionally initializes fields for the current context.
|
||||
*/
|
||||
protected void InitializeFields() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonSerializable;
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by gupele on 12/25/2014.
|
||||
*/
|
||||
public class MessageDataWrapper implements JsonSerializable {
|
||||
private final MessageData item;
|
||||
|
||||
public MessageDataWrapper() {
|
||||
item = new MessageData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
writer.write("type", "Microsoft.ApplicationInsights.MessageData");
|
||||
writer.write("item", item);
|
||||
}
|
||||
|
||||
public Map<String, String> getProperties() {
|
||||
return item.getProperties();
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
item.setMessage(message);
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return item.getMessage();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonSerializable;
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
|
||||
/**
|
||||
* Data contract class MetricData.
|
||||
*/
|
||||
public class MetricData extends Domain implements JsonSerializable {
|
||||
/**
|
||||
* Envelope Name for this telemetry.
|
||||
*/
|
||||
public static final String METRIC_ENVELOPE_NAME = "Microsoft.ApplicationInsights.Metric";
|
||||
|
||||
/**
|
||||
* Base Type for this telemetry.
|
||||
*/
|
||||
public static final String METRIC_BASE_TYPE = "Microsoft.ApplicationInsights.MetricData";
|
||||
|
||||
/**
|
||||
* Backing field for property Ver.
|
||||
*/
|
||||
private int ver = 2;
|
||||
|
||||
/**
|
||||
* Backing field for property Metrics.
|
||||
*/
|
||||
private List<DataPoint> metrics;
|
||||
|
||||
/**
|
||||
* Backing field for property Properties.
|
||||
*/
|
||||
private HashMap<String, String> properties;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the <see cref="MetricData"/> class.
|
||||
*/
|
||||
public MetricData()
|
||||
{
|
||||
this.InitializeFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Ver property.
|
||||
*/
|
||||
public int getVer() {
|
||||
return this.ver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Ver property.
|
||||
*/
|
||||
public void setVer(int value) {
|
||||
this.ver = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Metrics property.
|
||||
*/
|
||||
public List<DataPoint> getMetrics() {
|
||||
if (this.metrics == null) {
|
||||
this.metrics = new ArrayList<DataPoint>();
|
||||
}
|
||||
return this.metrics;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Metrics property.
|
||||
*/
|
||||
public void setMetrics(List<DataPoint> value) {
|
||||
this.metrics = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Properties property.
|
||||
*/
|
||||
public HashMap<String, String> getProperties() {
|
||||
if (this.properties == null) {
|
||||
this.properties = new HashMap<String, String>();
|
||||
}
|
||||
return this.properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Properties property.
|
||||
*/
|
||||
public void setProperties(HashMap<String, String> value) {
|
||||
this.properties = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
super.serializeContent(writer);
|
||||
|
||||
writer.write("ver", ver);
|
||||
writer.write("metrics", metrics);
|
||||
writer.write("properties", properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEnvelopName() {
|
||||
return METRIC_ENVELOPE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBaseTypeName() {
|
||||
return METRIC_BASE_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optionally initializes fields for the current context.
|
||||
*/
|
||||
protected void InitializeFields() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonSerializable;
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by gupele on 12/25/2014.
|
||||
*/
|
||||
public class MetricDataWrapper implements JsonSerializable {
|
||||
private final MetricData item;
|
||||
|
||||
public MetricDataWrapper() {
|
||||
item = new MetricData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Ver property.
|
||||
*/
|
||||
public int getVer() {
|
||||
return item.getVer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Ver property.
|
||||
*/
|
||||
public void setVer(int value) {
|
||||
item.setVer(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Metrics property.
|
||||
*/
|
||||
public List<DataPoint> getMetrics() {
|
||||
return item.getMetrics();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Metrics property.
|
||||
*/
|
||||
public void setMetrics(ArrayList<DataPoint> value) {
|
||||
item.setMetrics(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Properties property.
|
||||
*/
|
||||
public HashMap<String, String> getProperties() {
|
||||
return item.getProperties();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Properties property.
|
||||
*/
|
||||
public void setProperties(HashMap<String, String> value) {
|
||||
item.setProperties(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
writer.write("type", "Microsoft.ApplicationInsights.MetricData");
|
||||
writer.write("item", item);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,149 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonSerializable;
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
/**
|
||||
* Data contract class Operation.
|
||||
*/
|
||||
public class Operation implements JsonSerializable {
|
||||
/**
|
||||
* Backing field for property Id.
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* Backing field for property Name.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Backing field for property ParentId.
|
||||
*/
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* Backing field for property RootId.
|
||||
*/
|
||||
private String rootId;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the <see cref="Operation"/> class.
|
||||
*/
|
||||
public Operation()
|
||||
{
|
||||
this.InitializeFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Id property.
|
||||
*/
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Id property.
|
||||
*/
|
||||
public void setId(String value) {
|
||||
this.id = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Name property.
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Name property.
|
||||
*/
|
||||
public void setName(String value) {
|
||||
this.name = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ParentId property.
|
||||
*/
|
||||
public String getParentId() {
|
||||
return this.parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ParentId property.
|
||||
*/
|
||||
public void setParentId(String value) {
|
||||
this.parentId = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the RootId property.
|
||||
*/
|
||||
public String getRootId() {
|
||||
return this.rootId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the RootId property.
|
||||
*/
|
||||
public void setRootId(String value) {
|
||||
this.rootId = value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds all members of this class to a hashmap
|
||||
* @param map to which the members of this class will be added.
|
||||
*/
|
||||
public void addToHashMap(HashMap<String, String> map)
|
||||
{
|
||||
if (this.id == null) {
|
||||
map.put("id", this.id);
|
||||
}
|
||||
if (this.name == null) {
|
||||
map.put("name", this.name);
|
||||
}
|
||||
if (this.parentId == null) {
|
||||
map.put("parentId", this.parentId);
|
||||
}
|
||||
if (this.rootId == null) {
|
||||
map.put("rootId", this.rootId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
@Override
|
||||
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
Preconditions.checkNotNull(writer, "writer must be a non-null value");
|
||||
|
||||
serializeContent(writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
writer.write("id", id);
|
||||
writer.write("name", name);
|
||||
writer.write("parentId", parentId);
|
||||
writer.write("rootId", rootId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Optionally initializes fields for the current context.
|
||||
*/
|
||||
protected void InitializeFields() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
|
||||
/**
|
||||
* Data contract class PageViewData.
|
||||
*/
|
||||
public class PageViewData extends EventData {
|
||||
/**
|
||||
* Envelope Name for this telemetry.
|
||||
*/
|
||||
public static final String EnvelopeName = "Microsoft.ApplicationInsights.PageView";
|
||||
|
||||
/**
|
||||
* Base Type for this telemetry.
|
||||
*/
|
||||
public static final String BaseType = "Microsoft.ApplicationInsights.PageViewData";
|
||||
|
||||
/**
|
||||
* Backing field for property Url.
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* Backing field for property Duration.
|
||||
*/
|
||||
private String duration;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the <see cref="PageViewData"/> class.
|
||||
*/
|
||||
public PageViewData()
|
||||
{
|
||||
this.InitializeFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Url property.
|
||||
*/
|
||||
public String getUrl() {
|
||||
return this.url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Url property.
|
||||
*/
|
||||
public void setUrl(String value) {
|
||||
this.url = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Duration property.
|
||||
*/
|
||||
public String getDuration() {
|
||||
return this.duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Duration property.
|
||||
*/
|
||||
public void setDuration(String value) {
|
||||
this.duration = value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
super.serializeContent(writer);
|
||||
|
||||
writer.write("url", url);
|
||||
writer.write("duration", duration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Optionally initializes fields for the current context.
|
||||
*/
|
||||
protected void InitializeFields() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
|
||||
/**
|
||||
* Data contract class PageViewPerfData.
|
||||
*/
|
||||
public class PageViewPerfData extends PageViewData {
|
||||
/**
|
||||
* Envelope Name for this telemetry.
|
||||
*/
|
||||
public static final String EnvelopeName = "Microsoft.ApplicationInsights.PageViewPerf";
|
||||
|
||||
/**
|
||||
* Base Type for this telemetry.
|
||||
*/
|
||||
public static final String BaseType = "Microsoft.ApplicationInsights.PageViewPerfData";
|
||||
|
||||
/**
|
||||
* Backing field for property PerfTotal.
|
||||
*/
|
||||
private String perfTotal;
|
||||
|
||||
/**
|
||||
* Backing field for property NetworkConnect.
|
||||
*/
|
||||
private String networkConnect;
|
||||
|
||||
/**
|
||||
* Backing field for property SentRequest.
|
||||
*/
|
||||
private String sentRequest;
|
||||
|
||||
/**
|
||||
* Backing field for property ReceivedResponse.
|
||||
*/
|
||||
private String receivedResponse;
|
||||
|
||||
/**
|
||||
* Backing field for property DomProcessing.
|
||||
*/
|
||||
private String domProcessing;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the <see cref="PageViewPerfData"/> class.
|
||||
*/
|
||||
public PageViewPerfData()
|
||||
{
|
||||
this.InitializeFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the PerfTotal property.
|
||||
*/
|
||||
public String getPerfTotal() {
|
||||
return this.perfTotal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the PerfTotal property.
|
||||
*/
|
||||
public void setPerfTotal(String value) {
|
||||
this.perfTotal = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the NetworkConnect property.
|
||||
*/
|
||||
public String getNetworkConnect() {
|
||||
return this.networkConnect;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the NetworkConnect property.
|
||||
*/
|
||||
public void setNetworkConnect(String value) {
|
||||
this.networkConnect = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the SentRequest property.
|
||||
*/
|
||||
public String getSentRequest() {
|
||||
return this.sentRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the SentRequest property.
|
||||
*/
|
||||
public void setSentRequest(String value) {
|
||||
this.sentRequest = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ReceivedResponse property.
|
||||
*/
|
||||
public String getReceivedResponse() {
|
||||
return this.receivedResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ReceivedResponse property.
|
||||
*/
|
||||
public void setReceivedResponse(String value) {
|
||||
this.receivedResponse = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the DomProcessing property.
|
||||
*/
|
||||
public String getDomProcessing() {
|
||||
return this.domProcessing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the DomProcessing property.
|
||||
*/
|
||||
public void setDomProcessing(String value) {
|
||||
this.domProcessing = value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
super.serializeContent(writer);
|
||||
|
||||
writer.write("perfTotal", perfTotal);
|
||||
writer.write("networkConnect", networkConnect);
|
||||
writer.write("sentRequest", sentRequest);
|
||||
writer.write("receivedResponse", receivedResponse);
|
||||
writer.write("domProcessing", domProcessing);
|
||||
}
|
||||
|
||||
/**
|
||||
* Optionally initializes fields for the current context.
|
||||
*/
|
||||
protected void InitializeFields() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,326 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
import com.sun.org.apache.bcel.internal.generic.DSTORE;
|
||||
|
||||
/**
|
||||
* Data contract class RemoteDependencyData.
|
||||
*/
|
||||
public class RemoteDependencyData extends Domain {
|
||||
/**
|
||||
* Envelope Name for this telemetry.
|
||||
*/
|
||||
public static final String REMOTE_ENVELOPE_NAME = "Microsoft.ApplicationInsights.RemoteDependency";
|
||||
|
||||
/**
|
||||
* Base Type for this telemetry.
|
||||
*/
|
||||
public static final String REMOTE_BASE_TYPE = "Microsoft.ApplicationInsights.RemoteDependencyData";
|
||||
|
||||
/**
|
||||
* Backing field for property Ver.
|
||||
*/
|
||||
private int ver = 2;
|
||||
|
||||
/**
|
||||
* Backing field for property Name.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Backing field for property Kind.
|
||||
*/
|
||||
private DataPointType kind = DataPointType.Measurement;
|
||||
|
||||
/**
|
||||
* Backing field for property Value.
|
||||
*/
|
||||
private double value;
|
||||
|
||||
/**
|
||||
* Backing field for property Count.
|
||||
*/
|
||||
private Integer count;
|
||||
|
||||
/**
|
||||
* Backing field for property Min.
|
||||
*/
|
||||
private Double min;
|
||||
|
||||
/**
|
||||
* Backing field for property Max.
|
||||
*/
|
||||
private Double max;
|
||||
|
||||
/**
|
||||
* Backing field for property StdDev.
|
||||
*/
|
||||
private Double stdDev;
|
||||
|
||||
/**
|
||||
* Backing field for property DependencyKind.
|
||||
*/
|
||||
private DependencyKind dependencyKind = DependencyKind.Undefind;
|
||||
|
||||
/**
|
||||
* Backing field for property Success.
|
||||
*/
|
||||
private Boolean success = true;
|
||||
|
||||
/**
|
||||
* Backing field for property Async.
|
||||
*/
|
||||
private Boolean async;
|
||||
|
||||
/**
|
||||
* Backing field for property DependencySource.
|
||||
*/
|
||||
private DependencySourceType dependencySource = DependencySourceType.Undefined;
|
||||
|
||||
/**
|
||||
* Backing field for property Properties.
|
||||
*/
|
||||
private HashMap<String, String> properties;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the <see cref="RemoteDependencyData"/> class.
|
||||
*/
|
||||
public RemoteDependencyData()
|
||||
{
|
||||
this.InitializeFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Ver property.
|
||||
*/
|
||||
public int getVer() {
|
||||
return this.ver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Ver property.
|
||||
*/
|
||||
public void setVer(int value) {
|
||||
this.ver = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Name property.
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Name property.
|
||||
*/
|
||||
public void setName(String value) {
|
||||
this.name = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Kind property.
|
||||
*/
|
||||
public DataPointType getKind() {
|
||||
return this.kind;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Kind property.
|
||||
*/
|
||||
public void setKind(DataPointType value) {
|
||||
this.kind = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Value property.
|
||||
*/
|
||||
public double getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Value property.
|
||||
*/
|
||||
public void setValue(double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Count property.
|
||||
*/
|
||||
public Integer getCount() {
|
||||
return this.count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Count property.
|
||||
*/
|
||||
public void setCount(Integer value) {
|
||||
this.count = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Min property.
|
||||
*/
|
||||
public Double getMin() {
|
||||
return this.min;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Min property.
|
||||
*/
|
||||
public void setMin(Double value) {
|
||||
this.min = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Max property.
|
||||
*/
|
||||
public Double getMax() {
|
||||
return this.max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Max property.
|
||||
*/
|
||||
public void setMax(Double value) {
|
||||
this.max = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the StdDev property.
|
||||
*/
|
||||
public Double getStdDev() {
|
||||
return this.stdDev;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the StdDev property.
|
||||
*/
|
||||
public void setStdDev(Double value) {
|
||||
this.stdDev = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the DependencyKind property.
|
||||
*/
|
||||
public DependencyKind getDependencyKind() {
|
||||
return this.dependencyKind;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the DependencyKind property.
|
||||
*/
|
||||
public void setDependencyKind(DependencyKind value) {
|
||||
this.dependencyKind = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Success property.
|
||||
*/
|
||||
public Boolean getSuccess() {
|
||||
return this.success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Success property.
|
||||
*/
|
||||
public void setSuccess(Boolean value) {
|
||||
this.success = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Async property.
|
||||
*/
|
||||
public Boolean getAsync() {
|
||||
return this.async;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Async property.
|
||||
*/
|
||||
public void setAsync(Boolean value) {
|
||||
this.async = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the DependencySource property.
|
||||
*/
|
||||
public DependencySourceType getDependencySource() {
|
||||
return this.dependencySource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the DependencySource property.
|
||||
*/
|
||||
public void setDependencySource(DependencySourceType value) {
|
||||
this.dependencySource = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Properties property.
|
||||
*/
|
||||
public HashMap<String, String> getProperties() {
|
||||
if (this.properties == null) {
|
||||
this.properties = new HashMap<String, String>();
|
||||
}
|
||||
return this.properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Properties property.
|
||||
*/
|
||||
public void setProperties(HashMap<String, String> value) {
|
||||
this.properties = value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
super.serializeContent(writer);
|
||||
|
||||
writer.write("ver", ver);
|
||||
writer.write("name", name);
|
||||
|
||||
if (!DataPointType.Measurement.equals(kind)) {
|
||||
writer.write("kind", kind.getValue());
|
||||
}
|
||||
|
||||
writer.write("value", value);
|
||||
writer.write("count", count);
|
||||
writer.write("min", min);
|
||||
writer.write("max", max);
|
||||
writer.write("stdDev", stdDev);
|
||||
writer.write("dependencyKind", dependencyKind.getValue());
|
||||
writer.write("success", success);
|
||||
writer.write("async", async);
|
||||
|
||||
if (!DependencySourceType.Undefined.equals(dependencyKind)) {
|
||||
writer.write("dependencySource", dependencySource.getValue());
|
||||
}
|
||||
|
||||
writer.write("properties", properties);
|
||||
}
|
||||
|
||||
public String getEnvelopName() {
|
||||
return REMOTE_ENVELOPE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBaseTypeName() {
|
||||
return REMOTE_BASE_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optionally initializes fields for the current context.
|
||||
*/
|
||||
protected void InitializeFields() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonSerializable;
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by gupele on 12/25/2014.
|
||||
*/
|
||||
public class RemoteDependencyDataWrapper implements JsonSerializable {
|
||||
private final RemoteDependencyData item;
|
||||
|
||||
public RemoteDependencyDataWrapper() {
|
||||
item = new RemoteDependencyData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
writer.write("type", "Microsoft.ApplicationInsights.RemoteDependencyData");
|
||||
writer.write("item", item);
|
||||
}
|
||||
|
||||
public Map<String, String> getProperties() {
|
||||
return item.getProperties();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return item.getName();
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
item.setName(name);
|
||||
}
|
||||
|
||||
public DependencyKind getDependencyKind() {
|
||||
return item.getDependencyKind();
|
||||
}
|
||||
|
||||
public void setDependencyKind(DependencyKind dependencyKind) {
|
||||
item.setDependencyKind(dependencyKind);
|
||||
}
|
||||
|
||||
public double getValue() {
|
||||
return item.getValue();
|
||||
}
|
||||
|
||||
public void setValue(double value) {
|
||||
item.setValue(value);
|
||||
}
|
||||
|
||||
public Integer getCount() {
|
||||
return item.getCount();
|
||||
}
|
||||
|
||||
public void setCount(Integer count) {
|
||||
item.setCount(count);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,280 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
|
||||
/**
|
||||
* Data contract class RequestData.
|
||||
*/
|
||||
public class RequestData extends Domain {
|
||||
/**
|
||||
* Envelope Name for this telemetry.
|
||||
*/
|
||||
public static final String REQUEST_ENVELOPE_NAME = "Microsoft.ApplicationInsights.Request";
|
||||
|
||||
/**
|
||||
* Base Type for this telemetry.
|
||||
*/
|
||||
public static final String REQUEST_BASE_TYPE = "Microsoft.ApplicationInsights.RequestData";
|
||||
|
||||
/**
|
||||
* Backing field for property Ver.
|
||||
*/
|
||||
private int ver = 2;
|
||||
|
||||
/**
|
||||
* Backing field for property Id.
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* Backing field for property Name.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Backing field for property StartTime.
|
||||
*/
|
||||
private String startTime;
|
||||
|
||||
/**
|
||||
* Backing field for property Duration.
|
||||
*/
|
||||
private String duration;
|
||||
|
||||
/**
|
||||
* Backing field for property ResponseCode.
|
||||
*/
|
||||
private String responseCode;
|
||||
|
||||
/**
|
||||
* Backing field for property Success.
|
||||
*/
|
||||
private boolean success;
|
||||
|
||||
/**
|
||||
* Backing field for property HttpMethod.
|
||||
*/
|
||||
private String httpMethod;
|
||||
|
||||
/**
|
||||
* Backing field for property Url.
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* Backing field for property Properties.
|
||||
*/
|
||||
private HashMap<String, String> properties;
|
||||
|
||||
/**
|
||||
* Backing field for property Measurements.
|
||||
*/
|
||||
private HashMap<String, Double> measurements;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the <see cref="RequestData"/> class.
|
||||
*/
|
||||
public RequestData()
|
||||
{
|
||||
this.InitializeFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Ver property.
|
||||
*/
|
||||
public int getVer() {
|
||||
return this.ver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Ver property.
|
||||
*/
|
||||
public void setVer(int value) {
|
||||
this.ver = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Id property.
|
||||
*/
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Id property.
|
||||
*/
|
||||
public void setId(String value) {
|
||||
this.id = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Name property.
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Name property.
|
||||
*/
|
||||
public void setName(String value) {
|
||||
this.name = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the StartTime property.
|
||||
*/
|
||||
public String getStartTime() {
|
||||
return this.startTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the StartTime property.
|
||||
*/
|
||||
public void setStartTime(String value) {
|
||||
this.startTime = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Duration property.
|
||||
*/
|
||||
public String getDuration() {
|
||||
return this.duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Duration property.
|
||||
*/
|
||||
public void setDuration(String value) {
|
||||
this.duration = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ResponseCode property.
|
||||
*/
|
||||
public String getResponseCode() {
|
||||
return this.responseCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ResponseCode property.
|
||||
*/
|
||||
public void setResponseCode(String value) {
|
||||
this.responseCode = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Success property.
|
||||
*/
|
||||
public boolean getSuccess() {
|
||||
return this.success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Success property.
|
||||
*/
|
||||
public void setSuccess(boolean value) {
|
||||
this.success = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the HttpMethod property.
|
||||
*/
|
||||
public String getHttpMethod() {
|
||||
return this.httpMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the HttpMethod property.
|
||||
*/
|
||||
public void setHttpMethod(String value) {
|
||||
this.httpMethod = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Url property.
|
||||
*/
|
||||
public String getUrl() {
|
||||
return this.url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Url property.
|
||||
*/
|
||||
public void setUrl(String value) {
|
||||
this.url = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Properties property.
|
||||
*/
|
||||
public HashMap<String, String> getProperties() {
|
||||
if (this.properties == null) {
|
||||
this.properties = new HashMap<String, String>();
|
||||
}
|
||||
return this.properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Properties property.
|
||||
*/
|
||||
public void setProperties(HashMap<String, String> value) {
|
||||
this.properties = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Measurements property.
|
||||
*/
|
||||
public HashMap<String, Double> getMeasurements() {
|
||||
if (this.measurements == null) {
|
||||
this.measurements = new HashMap<String, Double>();
|
||||
}
|
||||
return this.measurements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Measurements property.
|
||||
*/
|
||||
public void setMeasurements(HashMap<String, Double> value) {
|
||||
this.measurements = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEnvelopName() {
|
||||
return REQUEST_ENVELOPE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBaseTypeName() {
|
||||
return REQUEST_BASE_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
super.serializeContent(writer);
|
||||
|
||||
writer.write("ver", ver);
|
||||
writer.write("id", id);
|
||||
writer.write("name", name);
|
||||
writer.write("startTime", startTime);
|
||||
writer.write("duration", duration);
|
||||
writer.write("responseCode", responseCode);
|
||||
writer.write("success", success);
|
||||
writer.write("httpMethod", httpMethod);
|
||||
writer.write("url", url);
|
||||
writer.write("properties", properties);
|
||||
writer.write("measurements", measurements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Optionally initializes fields for the current context.
|
||||
*/
|
||||
protected void InitializeFields() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonSerializable;
|
||||
|
||||
/**
|
||||
* Created by gupele on 12/25/2014.
|
||||
*/
|
||||
public interface SendableData extends JsonSerializable {
|
||||
String getEnvelopName();
|
||||
|
||||
String getBaseTypeName();
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonSerializable;
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
/**
|
||||
* Data contract class Session.
|
||||
*/
|
||||
public class Session implements JsonSerializable {
|
||||
/**
|
||||
* Backing field for property Id.
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* Backing field for property IsFirst.
|
||||
*/
|
||||
private String isFirst;
|
||||
|
||||
/**
|
||||
* Backing field for property IsNew.
|
||||
*/
|
||||
private String isNew;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the <see cref="Session"/> class.
|
||||
*/
|
||||
public Session()
|
||||
{
|
||||
this.InitializeFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Id property.
|
||||
*/
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Id property.
|
||||
*/
|
||||
public void setId(String value) {
|
||||
this.id = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the IsFirst property.
|
||||
*/
|
||||
public String getIsFirst() {
|
||||
return this.isFirst;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the IsFirst property.
|
||||
*/
|
||||
public void setIsFirst(String value) {
|
||||
this.isFirst = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the IsNew property.
|
||||
*/
|
||||
public String getIsNew() {
|
||||
return this.isNew;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the IsNew property.
|
||||
*/
|
||||
public void setIsNew(String value) {
|
||||
this.isNew = value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds all members of this class to a hashmap
|
||||
* @param map to which the members of this class will be added.
|
||||
*/
|
||||
public void addToHashMap(HashMap<String, String> map)
|
||||
{
|
||||
if (!(this.id == null)) {
|
||||
map.put("id", this.id);
|
||||
}
|
||||
if (!(this.isFirst == null)) {
|
||||
map.put("isFirst", this.isFirst);
|
||||
}
|
||||
if (!(this.isNew == null)) {
|
||||
map.put("isNew", this.isNew);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
@Override
|
||||
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
Preconditions.checkNotNull(writer, "writer must be a non-null value");
|
||||
|
||||
this.serializeContent(writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
writer.write("id", id);
|
||||
writer.write("isFirst", isFirst);
|
||||
writer.write("isNew", isNew);
|
||||
}
|
||||
|
||||
/**
|
||||
* Optionally initializes fields for the current context.
|
||||
*/
|
||||
protected void InitializeFields() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
/**
|
||||
* Enum SeverityLevel.
|
||||
*/
|
||||
public enum SeverityLevel {
|
||||
Verbose(0),
|
||||
Information(1),
|
||||
Warning(2),
|
||||
Error(3),
|
||||
Critical(4);
|
||||
|
||||
private final int id;
|
||||
|
||||
public int getValue() {
|
||||
return id;
|
||||
}
|
||||
|
||||
SeverityLevel(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,147 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonSerializable;
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
/**
|
||||
* Data contract class StackFrame.
|
||||
*/
|
||||
public class StackFrame implements JsonSerializable {
|
||||
/**
|
||||
* Backing field for property Level.
|
||||
*/
|
||||
private int level;
|
||||
|
||||
/**
|
||||
* Backing field for property Method.
|
||||
*/
|
||||
private String method;
|
||||
|
||||
/**
|
||||
* Backing field for property Assembly.
|
||||
*/
|
||||
private String assembly;
|
||||
|
||||
/**
|
||||
* Backing field for property FileName.
|
||||
*/
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* Backing field for property Line.
|
||||
*/
|
||||
private int line;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the <see cref="StackFrame"/> class.
|
||||
*/
|
||||
public StackFrame()
|
||||
{
|
||||
this.InitializeFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Level property.
|
||||
*/
|
||||
public int getLevel() {
|
||||
return this.level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Level property.
|
||||
*/
|
||||
public void setLevel(int value) {
|
||||
this.level = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Method property.
|
||||
*/
|
||||
public String getMethod() {
|
||||
return this.method;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Method property.
|
||||
*/
|
||||
public void setMethod(String value) {
|
||||
this.method = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Assembly property.
|
||||
*/
|
||||
public String getAssembly() {
|
||||
return this.assembly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Assembly property.
|
||||
*/
|
||||
public void setAssembly(String value) {
|
||||
this.assembly = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the FileName property.
|
||||
*/
|
||||
public String getFileName() {
|
||||
return this.fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the FileName property.
|
||||
*/
|
||||
public void setFileName(String value) {
|
||||
this.fileName = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Line property.
|
||||
*/
|
||||
public int getLine() {
|
||||
return this.line;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Line property.
|
||||
*/
|
||||
public void setLine(int value) {
|
||||
this.line = value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
@Override
|
||||
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
Preconditions.checkNotNull(writer, "writer must be a non-null value");
|
||||
|
||||
this.serializeContent(writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
writer.write("level", level);
|
||||
writer.write("method", method);
|
||||
writer.write("assembly", assembly);
|
||||
writer.write("fileName", fileName);
|
||||
writer.write("line", line);
|
||||
}
|
||||
|
||||
/**
|
||||
* Optionally initializes fields for the current context.
|
||||
*/
|
||||
protected void InitializeFields() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,148 @@
|
|||
package com.microsoft.applicationinsights.implementation.schemav2;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonSerializable;
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
/**
|
||||
* Data contract class User.
|
||||
*/
|
||||
public class User implements JsonSerializable {
|
||||
/**
|
||||
* Backing field for property AccountAcquisitionDate.
|
||||
*/
|
||||
private String accountAcquisitionDate;
|
||||
|
||||
/**
|
||||
* Backing field for property AccountId.
|
||||
*/
|
||||
private String accountId;
|
||||
|
||||
/**
|
||||
* Backing field for property UserAgent.
|
||||
*/
|
||||
private String userAgent;
|
||||
|
||||
/**
|
||||
* Backing field for property Id.
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the <see cref="User"/> class.
|
||||
*/
|
||||
public User()
|
||||
{
|
||||
this.InitializeFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the AccountAcquisitionDate property.
|
||||
*/
|
||||
public String getAccountAcquisitionDate() {
|
||||
return this.accountAcquisitionDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the AccountAcquisitionDate property.
|
||||
*/
|
||||
public void setAccountAcquisitionDate(String value) {
|
||||
this.accountAcquisitionDate = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the AccountId property.
|
||||
*/
|
||||
public String getAccountId() {
|
||||
return this.accountId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the AccountId property.
|
||||
*/
|
||||
public void setAccountId(String value) {
|
||||
this.accountId = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the UserAgent property.
|
||||
*/
|
||||
public String getUserAgent() {
|
||||
return this.userAgent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the UserAgent property.
|
||||
*/
|
||||
public void setUserAgent(String value) {
|
||||
this.userAgent = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Id property.
|
||||
*/
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Id property.
|
||||
*/
|
||||
public void setId(String value) {
|
||||
this.id = value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds all members of this class to a hashmap
|
||||
* @param map to which the members of this class will be added.
|
||||
*/
|
||||
public void addToHashMap(HashMap<String, String> map)
|
||||
{
|
||||
if (!(this.accountAcquisitionDate == null)) {
|
||||
map.put("accountAcquisitionDate", this.accountAcquisitionDate);
|
||||
}
|
||||
if (!(this.accountId == null)) {
|
||||
map.put("accountId", this.accountId);
|
||||
}
|
||||
if (!(this.userAgent == null)) {
|
||||
map.put("userAgent", this.userAgent);
|
||||
}
|
||||
if (!(this.id == null)) {
|
||||
map.put("id", this.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
@Override
|
||||
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
Preconditions.checkNotNull(writer, "writer must be a non-null value");
|
||||
|
||||
this.serializeContent(writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the beginning of this object to the passed in writer.
|
||||
* @param writer The writer to serialize this object to.
|
||||
*/
|
||||
protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
writer.write("accountAcquisitionDate", accountAcquisitionDate);
|
||||
writer.write("accountId", accountId);
|
||||
writer.write("userAgent", accountId);
|
||||
writer.write("id", id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Optionally initializes fields for the current context.
|
||||
*/
|
||||
protected void InitializeFields() {
|
||||
}
|
||||
}
|
|
@ -11,9 +11,9 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonTelemetryDataSerializer;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.microsoft.applicationinsights.datacontracts.JsonWriter;
|
||||
import com.microsoft.applicationinsights.datacontracts.TelemetryContext;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
@ -59,18 +59,6 @@ public class GzipTelemetrySerializerTest {
|
|||
public void sanitize() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(JsonWriter writer) throws IOException {
|
||||
writer.writeStartObject();
|
||||
|
||||
writer.writeProperty("ver", 1);
|
||||
writer.writeProperty("telemetryName", telemetryName);
|
||||
|
||||
writer.writeProperty("properties", this.getProperties());
|
||||
|
||||
writer.writeEndObject();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
|
@ -90,6 +78,13 @@ public class GzipTelemetrySerializerTest {
|
|||
public String getTelemetryName() {
|
||||
return telemetryName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {
|
||||
writer.write("ver", 1);
|
||||
writer.write("telemetryName", telemetryName);
|
||||
writer.write("properties", this.getProperties());
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = NullPointerException.class)
|
||||
|
|
|
@ -0,0 +1,203 @@
|
|||
package com.microsoft.applicationinsights.datacontracts;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class JsonTelemetryDataSerializerTest {
|
||||
private final static class TestClassWithStrings implements JsonSerializable, Serializable {
|
||||
private String s1;
|
||||
private String s2;
|
||||
|
||||
@Override
|
||||
public void serialize(JsonTelemetryDataSerializer serializer) throws IOException {
|
||||
serializer.write("s1", s1);
|
||||
serializer.write("s2", s2);
|
||||
}
|
||||
|
||||
public String getS1() {
|
||||
return s1;
|
||||
}
|
||||
|
||||
public void setS1(String s1) {
|
||||
this.s1 = s1;
|
||||
}
|
||||
|
||||
public String getS2() {
|
||||
return s2;
|
||||
}
|
||||
|
||||
public void setS2(String s2) {
|
||||
this.s2 = s2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(other instanceof TestClassWithStrings)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TestClassWithStrings that = (TestClassWithStrings)other;
|
||||
return this.s1.equals(that.getS1()) && this.s2.equals(that.getS2());
|
||||
}
|
||||
}
|
||||
|
||||
private final static class StubClass implements JsonSerializable, Serializable {
|
||||
private int i1;
|
||||
private int i2;
|
||||
private String s1;
|
||||
private Long l1;
|
||||
private long l2;
|
||||
private String s2;
|
||||
private Map<String, Integer> m1 = new HashMap<String, Integer>();
|
||||
private List<String> list1 = new ArrayList<String>();
|
||||
|
||||
public int getI1() {
|
||||
return i1;
|
||||
}
|
||||
|
||||
public void setI1(int i1) {
|
||||
this.i1 = i1;
|
||||
}
|
||||
|
||||
public int getI2() {
|
||||
return i2;
|
||||
}
|
||||
|
||||
public void setI2(int i2) {
|
||||
this.i2 = i2;
|
||||
}
|
||||
|
||||
public String getS1() {
|
||||
return s1;
|
||||
}
|
||||
|
||||
public void setS1(String s1) {
|
||||
this.s1 = s1;
|
||||
}
|
||||
|
||||
public Long getL1() {
|
||||
return l1;
|
||||
}
|
||||
|
||||
public void setL1(Long l1) {
|
||||
this.l1 = l1;
|
||||
}
|
||||
|
||||
public long getL2() {
|
||||
return l2;
|
||||
}
|
||||
|
||||
public void setL2(long l2) {
|
||||
this.l2 = l2;
|
||||
}
|
||||
|
||||
public String getS2() {
|
||||
return s2;
|
||||
}
|
||||
|
||||
public void setS2(String s2) {
|
||||
this.s2 = s2;
|
||||
}
|
||||
|
||||
public Map<String, Integer> getM1() {
|
||||
return m1;
|
||||
}
|
||||
|
||||
public void setM1(Map<String, Integer> m1) {
|
||||
this.m1 = m1;
|
||||
}
|
||||
|
||||
public List<String> getList1() {
|
||||
return list1;
|
||||
}
|
||||
|
||||
public void setList1(List<String> list1) {
|
||||
this.list1 = list1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(JsonTelemetryDataSerializer serializer) throws IOException {
|
||||
serializer.write("i1", i1);
|
||||
serializer.write("i2", i2);
|
||||
serializer.write("s1", s1);
|
||||
serializer.write("l1", l1);
|
||||
serializer.write("l2", l2);
|
||||
serializer.write("s2", s2);
|
||||
serializer.write("m1", m1);
|
||||
serializer.write("list1", list1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(other instanceof TestClassWithStrings)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
StubClass that = (StubClass)other;
|
||||
return
|
||||
this.s1.equals(that.getS1()) && this.s2.equals(that.getS2()) &&
|
||||
this.i1 == that.getI1() && this.i2 == that.getI2() &&
|
||||
(this.l1 == null ? that.getL1() == null : this.l1.equals(getL1())) && this.l2 == that.getL2() &&
|
||||
this.list1.equals(that.getList1()) && this.m1.equals(that.getM1());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStrings() throws IOException {
|
||||
TestClassWithStrings testClassWithStrings = new TestClassWithStrings();
|
||||
testClassWithStrings.setS1("s1");
|
||||
testClassWithStrings.setS2("s2");
|
||||
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
BufferedWriter bufferedWriter = new BufferedWriter(stringWriter);
|
||||
JsonTelemetryDataSerializer tested = new JsonTelemetryDataSerializer(stringWriter);
|
||||
testClassWithStrings.serialize(tested);
|
||||
tested.close();
|
||||
String str = stringWriter.toString();
|
||||
TestClassWithStrings bac = new Gson().fromJson(str, TestClassWithStrings.class);
|
||||
assertEquals(bac, testClassWithStrings);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() throws IOException {
|
||||
StubClass stubClass = new StubClass();
|
||||
stubClass.setI1(1);
|
||||
stubClass.setI2(2);
|
||||
stubClass.setL1(3L);
|
||||
stubClass.setL2(4L);
|
||||
stubClass.getList1().add("str1");
|
||||
stubClass.getList1().add("str2");
|
||||
stubClass.getM1().put("key1", 5);
|
||||
stubClass.getM1().put("key2", 6);
|
||||
stubClass.getM1().put("key3", 7);
|
||||
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
BufferedWriter bufferedWriter = new BufferedWriter(stringWriter);
|
||||
JsonTelemetryDataSerializer tested = new JsonTelemetryDataSerializer(stringWriter);
|
||||
stubClass.serialize(tested);
|
||||
tested.close();
|
||||
String str = stringWriter.toString();
|
||||
StubClass bac = new Gson().fromJson(str, StubClass.class);
|
||||
System.out.println(str);
|
||||
}
|
||||
|
||||
}
|
|
@ -20,6 +20,7 @@ class Program
|
|||
metrics.put("Answers", (double)15);
|
||||
|
||||
appInsights.trackEvent("A test event", null, metrics);
|
||||
|
||||
appInsights.trackTrace("Things seem to be going well");
|
||||
|
||||
MetricTelemetry mt = new MetricTelemetry("Test time", 17.0);
|
||||
|
|
Загрузка…
Ссылка в новой задаче