Skip to content
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

Merged
merged 6 commits into from
Jun 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions storage/applicationinsights/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@
<artifactId>applicationinsights-core</artifactId>
<version>[1.0,)</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-web</artifactId>
<version>[1.0,)</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,21 @@
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.internal.Util;
import zipkin.storage.StorageAdapters;
import zipkin.Constants;

import static zipkin.internal.ApplyTimestampAndDuration.guessTimestamp;

Expand All @@ -47,12 +53,22 @@ public void accept(List<Span> spans) {
for (int i = 0; i < spans.size(); i++) {
Span span = spans.get(i);
Map<String, String> spanProps = new HashMap<String, String>();

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;

//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));
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
Expand All @@ -69,6 +85,24 @@ public void accept(List<Span> spans) {
String res = gson.toJson(jsonElement);
String msg = "{ \"Span\":" + res + "}";
telemetry.trackTrace(msg, SeverityLevel.Critical, spanProps);

//data model changes
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;
Copy link
Collaborator

Choose a reason for hiding this comment

The 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 failure flag for many scenarios. So if we can deduct that span failed from annotations - it will improve those scenarios.

Copy link
Owner Author

@praveenbarli praveenbarli Jun 27, 2017

Choose a reason for hiding this comment

The 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/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/1000,
"Ok",true));
}
}
}

telemetry.flush();
Expand Down

This file was deleted.