From 78a8ebd7abe80096951bdf798ed9965d52b42afa Mon Sep 17 00:00:00 2001 From: Praveen Barli Date: Mon, 26 Jun 2017 16:25:31 -0700 Subject: [PATCH 1/5] data model changes to add name, id and dependency for sr annotaiton --- .../ApplicationInsightsSpanConsumer.java | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/storage/applicationinsights/src/main/java/zipkin/storage/applicationinsights/ApplicationInsightsSpanConsumer.java b/storage/applicationinsights/src/main/java/zipkin/storage/applicationinsights/ApplicationInsightsSpanConsumer.java index 38fd7fb..5e29bec 100644 --- a/storage/applicationinsights/src/main/java/zipkin/storage/applicationinsights/ApplicationInsightsSpanConsumer.java +++ b/storage/applicationinsights/src/main/java/zipkin/storage/applicationinsights/ApplicationInsightsSpanConsumer.java @@ -16,13 +16,16 @@ import com.microsoft.applicationinsights.TelemetryClient; import com.microsoft.applicationinsights.telemetry.SeverityLevel; import com.microsoft.applicationinsights.TelemetryConfiguration; +import com.microsoft.applicationinsights.telemetry.Duration; import com.google.gson.Gson; import com.google.gson.JsonElement; import java.util.List; import java.util.Map; import java.util.HashMap; +import zipkin.Annotation; import zipkin.Span; import zipkin.storage.StorageAdapters; +import zipkin.Constants; import static zipkin.internal.ApplyTimestampAndDuration.guessTimestamp; @@ -48,11 +51,17 @@ public void accept(List spans) { Span span = spans.get(i); Map spanProps = new HashMap(); //set indexing properties, avoid null values for props - spanProps.put("spanid", Long.toString(span.id)); - spanProps.put("traceId", Long.toString(span.traceId)); - spanProps.put("traceIdHigh", Long.toString(span.traceIdHigh)); + + String spanId = Long.toString(span.id); + String traceId = Long.toString(span.traceId); + String traceIdHigh = Long.toString(span.traceIdHigh); + String namespace = (this.namespace == null) ? "" : this.namespace; + + spanProps.put("spanid", spanId); + spanProps.put("traceId", traceId); + spanProps.put("traceIdHigh", traceIdHigh); //namespace to support duplicate data - spanProps.put("namespace", (this.namespace == null)?"":this.namespace); + spanProps.put("namespace", namespace); if (span.annotations != null && span.annotations.size() > 0 && span.annotations.get(0).endpoint != null @@ -68,6 +77,16 @@ public void accept(List spans) { } String res = gson.toJson(jsonElement); String msg = "{ \"Span\":" + res + "}"; + //data model changes + telemetry.getContext().getOperation().setId(traceId); + telemetry.getContext().getOperation().setName(span.name); + + for (Annotation annotation : span.annotations) { + if (annotation.value.equalsIgnoreCase(Constants.SERVER_RECV)) { + telemetry.trackDependency(Constants.SERVER_RECV, "request", new Duration(span.duration==null?0L:span.duration), + true); + } + } telemetry.trackTrace(msg, SeverityLevel.Critical, spanProps); } From 219c4f1c47c249f5eaec3491034591ba9b7ab3ee Mon Sep 17 00:00:00 2001 From: Praveen Barli Date: Mon, 26 Jun 2017 16:25:31 -0700 Subject: [PATCH 2/5] data model changes to add name, id and dependency for sr annotaiton --- .../ApplicationInsightsSpanConsumer.java | 43 +++++++++++++++++-- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/storage/applicationinsights/src/main/java/zipkin/storage/applicationinsights/ApplicationInsightsSpanConsumer.java b/storage/applicationinsights/src/main/java/zipkin/storage/applicationinsights/ApplicationInsightsSpanConsumer.java index 38fd7fb..13cb91f 100644 --- a/storage/applicationinsights/src/main/java/zipkin/storage/applicationinsights/ApplicationInsightsSpanConsumer.java +++ b/storage/applicationinsights/src/main/java/zipkin/storage/applicationinsights/ApplicationInsightsSpanConsumer.java @@ -14,15 +14,22 @@ package zipkin.storage.applicationinsights; import com.microsoft.applicationinsights.TelemetryClient; +import com.microsoft.applicationinsights.telemetry.RequestTelemetry; import com.microsoft.applicationinsights.telemetry.SeverityLevel; import com.microsoft.applicationinsights.TelemetryConfiguration; +import com.microsoft.applicationinsights.telemetry.Duration; +import com.microsoft.applicationinsights.telemetry.RequestTelemetry; import com.google.gson.Gson; import com.google.gson.JsonElement; +import java.util.Date; import java.util.List; import java.util.Map; import java.util.HashMap; +import org.apache.http.HttpStatus; +import zipkin.Annotation; import zipkin.Span; import zipkin.storage.StorageAdapters; +import zipkin.Constants; import static zipkin.internal.ApplyTimestampAndDuration.guessTimestamp; @@ -48,11 +55,21 @@ public void accept(List spans) { Span span = spans.get(i); Map spanProps = new HashMap(); //set indexing properties, avoid null values for props - spanProps.put("spanid", Long.toString(span.id)); - spanProps.put("traceId", Long.toString(span.traceId)); - spanProps.put("traceIdHigh", Long.toString(span.traceIdHigh)); + + String spanId = Long.toString(span.id); + String parentSpanId = span.parentId != null? Long.toString(span.parentId): null; + String traceId = Long.toString(span.traceId); + String traceIdHigh = Long.toString(span.traceIdHigh); + String namespace = (this.namespace == null) ? "" : this.namespace; + + spanProps.put("spanid", spanId); + spanProps.put("traceId", traceId); + spanProps.put("traceIdHigh", traceIdHigh); + if(parentSpanId!= null) + spanProps.put("OperationParentId", parentSpanId); + //namespace to support duplicate data - spanProps.put("namespace", (this.namespace == null)?"":this.namespace); + spanProps.put("namespace", namespace); if (span.annotations != null && span.annotations.size() > 0 && span.annotations.get(0).endpoint != null @@ -68,6 +85,24 @@ public void accept(List spans) { } String res = gson.toJson(jsonElement); String msg = "{ \"Span\":" + res + "}"; + //data model changes + telemetry.getContext().getOperation().setId(traceId); + telemetry.getContext().getOperation().setName(span.name); + + for (Annotation annotation : span.annotations) { + + if (annotation.value.equalsIgnoreCase(Constants.CLIENT_SEND)) { + String spanName = span.name !=null && !span.name.isEmpty()?span.name:Constants.CLIENT_SEND; + telemetry.trackDependency(spanName, "request", new Duration(span.duration==null?0L:span.duration), + true); + } + else if(annotation.value.equalsIgnoreCase(Constants.SERVER_SEND)){ + String spanName = span.name !=null && !span.name.isEmpty()?span.name:Constants.SERVER_RECV; + telemetry.trackRequest(new RequestTelemetry(spanName, new Date(timestamp), span.duration, + "Ok",true)); + } + } + telemetry.trackTrace(msg, SeverityLevel.Critical, spanProps); } From 735e0560797df1236c8d7de4017021fdb48da505 Mon Sep 17 00:00:00 2001 From: Praveen Barli Date: Tue, 27 Jun 2017 10:33:22 -0700 Subject: [PATCH 3/5] removed unused refs --- .../ApplicationInsightsSpanConsumer.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/storage/applicationinsights/src/main/java/zipkin/storage/applicationinsights/ApplicationInsightsSpanConsumer.java b/storage/applicationinsights/src/main/java/zipkin/storage/applicationinsights/ApplicationInsightsSpanConsumer.java index b5d6e02..e0cb8d9 100644 --- a/storage/applicationinsights/src/main/java/zipkin/storage/applicationinsights/ApplicationInsightsSpanConsumer.java +++ b/storage/applicationinsights/src/main/java/zipkin/storage/applicationinsights/ApplicationInsightsSpanConsumer.java @@ -18,20 +18,12 @@ import com.microsoft.applicationinsights.telemetry.SeverityLevel; import com.microsoft.applicationinsights.TelemetryConfiguration; import com.microsoft.applicationinsights.telemetry.Duration; -<<<<<<< HEAD -import com.microsoft.applicationinsights.telemetry.RequestTelemetry; -======= ->>>>>>> 78a8ebd7abe80096951bdf798ed9965d52b42afa import com.google.gson.Gson; import com.google.gson.JsonElement; import java.util.Date; import java.util.List; import java.util.Map; import java.util.HashMap; -<<<<<<< HEAD -import org.apache.http.HttpStatus; -======= ->>>>>>> 78a8ebd7abe80096951bdf798ed9965d52b42afa import zipkin.Annotation; import zipkin.Span; import zipkin.storage.StorageAdapters; From 249284bb4e39fbed3a238c31680c9d41ba0b132c Mon Sep 17 00:00:00 2001 From: Praveen Barli Date: Tue, 27 Jun 2017 11:44:54 -0700 Subject: [PATCH 4/5] removed appinsights config, appinsights-web pkg --- storage/applicationinsights/pom.xml | 5 -- .../main/resources/ApplicationInsights.xml | 48 ------------------- 2 files changed, 53 deletions(-) delete mode 100644 storage/applicationinsights/src/main/resources/ApplicationInsights.xml diff --git a/storage/applicationinsights/pom.xml b/storage/applicationinsights/pom.xml index 3948647..8e6de05 100644 --- a/storage/applicationinsights/pom.xml +++ b/storage/applicationinsights/pom.xml @@ -55,11 +55,6 @@ applicationinsights-core [1.0,) - - com.microsoft.azure - applicationinsights-web - [1.0,) - com.squareup.okhttp3 okhttp diff --git a/storage/applicationinsights/src/main/resources/ApplicationInsights.xml b/storage/applicationinsights/src/main/resources/ApplicationInsights.xml deleted file mode 100644 index a6ae28a..0000000 --- a/storage/applicationinsights/src/main/resources/ApplicationInsights.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 607f59cdf3f7bfdb8de37976def8904482904619 Mon Sep 17 00:00:00 2001 From: Praveen Barli Date: Wed, 28 Jun 2017 17:04:30 -0700 Subject: [PATCH 5/5] set operation id to hex val of traceid's, duration in millis --- .../ApplicationInsightsSpanConsumer.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/storage/applicationinsights/src/main/java/zipkin/storage/applicationinsights/ApplicationInsightsSpanConsumer.java b/storage/applicationinsights/src/main/java/zipkin/storage/applicationinsights/ApplicationInsightsSpanConsumer.java index e0cb8d9..d130630 100644 --- a/storage/applicationinsights/src/main/java/zipkin/storage/applicationinsights/ApplicationInsightsSpanConsumer.java +++ b/storage/applicationinsights/src/main/java/zipkin/storage/applicationinsights/ApplicationInsightsSpanConsumer.java @@ -26,6 +26,7 @@ import java.util.HashMap; import zipkin.Annotation; import zipkin.Span; +import zipkin.internal.Util; import zipkin.storage.StorageAdapters; import zipkin.Constants; @@ -52,7 +53,6 @@ public void accept(List spans) { for (int i = 0; i < spans.size(); i++) { Span span = spans.get(i); Map spanProps = new HashMap(); - //set indexing properties, avoid null values for props String spanId = Long.toString(span.id); String parentSpanId = span.parentId != null? Long.toString(span.parentId): null; @@ -61,13 +61,12 @@ public void accept(List spans) { String traceIdHigh = Long.toString(span.traceIdHigh); String namespace = (this.namespace == null) ? "" : this.namespace; + //set indexing properties, avoid null values for props spanProps.put("spanid", spanId); spanProps.put("traceId", traceId); spanProps.put("traceIdHigh", traceIdHigh); - if(parentSpanId!= null) spanProps.put("OperationParentId", parentSpanId); - //namespace to support duplicate data spanProps.put("namespace", namespace); if (span.annotations != null @@ -85,25 +84,25 @@ public void accept(List spans) { } String res = gson.toJson(jsonElement); String msg = "{ \"Span\":" + res + "}"; + telemetry.trackTrace(msg, SeverityLevel.Critical, spanProps); + //data model changes - telemetry.getContext().getOperation().setId(traceId); + telemetry.getContext().getOperation().setId(Util.toLowerHex(span.traceIdHigh, span.traceId)); telemetry.getContext().getOperation().setName(span.name); for (Annotation annotation : span.annotations) { if (annotation.value.equalsIgnoreCase(Constants.CLIENT_SEND)) { String spanName = span.name !=null && !span.name.isEmpty()?span.name:Constants.CLIENT_SEND; - telemetry.trackDependency(spanName, "request", new Duration(span.duration==null?0L:span.duration), + telemetry.trackDependency(spanName, "request", new Duration(span.duration==null?0L:span.duration/1000), true); } else if(annotation.value.equalsIgnoreCase(Constants.SERVER_SEND)){ String spanName = span.name !=null && !span.name.isEmpty()?span.name:Constants.SERVER_RECV; - telemetry.trackRequest(new RequestTelemetry(spanName, new Date(timestamp), span.duration, + telemetry.trackRequest(new RequestTelemetry(spanName, new Date(timestamp), span.duration/1000, "Ok",true)); } } - - telemetry.trackTrace(msg, SeverityLevel.Critical, spanProps); } telemetry.flush();