-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
data model changes to add name, id and dependency for sr annotaiton #5
Changes from 5 commits
78a8ebd
219c4f1
71d4cec
735e056
249284b
607f59c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,15 +14,20 @@ | |
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.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 zipkin.Annotation; | ||
import zipkin.Span; | ||
import zipkin.storage.StorageAdapters; | ||
import zipkin.Constants; | ||
|
||
import static zipkin.internal.ApplyTimestampAndDuration.guessTimestamp; | ||
|
||
|
@@ -48,11 +53,23 @@ public void accept(List<Span> spans) { | |
Span span = spans.get(i); | ||
Map<String, String> spanProps = new HashMap<String, String>(); | ||
//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<Span> spans) { | |
} | ||
String res = gson.toJson(jsonElement); | ||
String msg = "{ \"Span\":" + res + "}"; | ||
//data model changes | ||
telemetry.getContext().getOperation().setId(traceId); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it should be a combination of two ids - There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, Shall I concatenate both strings while setting id? How are we going to retrieve back? |
||
telemetry.getContext().getOperation().setName(span.name); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does span in Zipkin has special annotation for an error? In Application Insights we rely on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, they suggest logging a binary annotation and have an open issue. We shall discuss further how we set AI flag. |
||
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); | ||
} | ||
|
||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there parent ID? Can you please place it into custom property for now.