Skip to content
This repository has been archived by the owner on Nov 27, 2017. It is now read-only.

How should we render annotations that are json? #11

Open
codefromthecrypt opened this issue Sep 20, 2016 · 17 comments
Open

How should we render annotations that are json? #11

codefromthecrypt opened this issue Sep 20, 2016 · 17 comments

Comments

@codefromthecrypt
Copy link

Right now, we render annotations that hold json as string literals.

Ex. if I do this in finagle

Trace.record("{\"event\": \"soft error\", \"type\": \"cache timeout\", \"waited.millis\": 1500}");

Or if I use opentracing's logKV api, this renders like so..

screen shot 2016-09-20 at 9 58 26 am

Presumably, we could do better, but I'm not sure how. Any ideas?

cc @basvanbeek @yurishkuro @bensigelman

@rogeralsing
Copy link
Contributor

Is there any way to detect that the annotation is Json? the normal annotations don't have any "type", right?
So we would have to do a client side check if the string can be parsed, right?

@codefromthecrypt
Copy link
Author

I was looking at the type like this..

https://github.com/openzipkin/zipkin/pull/1307/files

@eirslett
Copy link

@eirslett
Copy link

Something like an interactive JSON viewer where nodes can be expanded and collapsed?

@basvanbeek
Copy link

I would like that viewer to be inline (expandable/collapsible) inside the annotation detail pane.

This would also work well for OpenTracing Key/Value pairs

@rogeralsing
Copy link
Contributor

I have some early progress on this, at least the JSON is detected and rendered in its own way.

json

So how far should we push this?
Should we go for a full JSON formatter like this https://jsonformatter.curiousconcept.com/
Or, just apply pretty print and use e.g. Highlight JS on the results?

@rogeralsing
Copy link
Contributor

Meh, couldnt help it, I'm building my own JSON viewer in Angular.
json2

Going to throw some expander buttons at the arrays and objects.

@codefromthecrypt
Copy link
Author

codefromthecrypt commented Sep 21, 2016

At first glance, since the view is tabular, seems nice to have something
like.

// for some limit of column length, render as key/value (assume it isn't
nested as there's currently no use case for that)
key1=value1 key2=value2...

Then, you can click on the above to expand a json tree view.

Feels like it would be less distracting that way, particularly as rendering
json is currently a niche functionality (as some users who accept key/value
in tracers will expand it to a string as opposed to sending as raw json
anyway)

@codefromthecrypt
Copy link
Author

ps unless you're really interested I wouldn't sink too much time into this. It is a speculative feature, which hopefully is more a workaround. Ex quoted json doesn't work for search or anything else in zipkin.

If we ever supported anything like this properly, it would be far more coherent and far more searchable as a timestamp column on a binary annotation. Most of our backends have a timestamp on each searchable binary annotation row anyway.

I highly doubt our next models will include Map -> timestamp data structures as the span model is already complex. openzipkin/zipkin#939

@codefromthecrypt
Copy link
Author

codefromthecrypt commented Sep 22, 2016

If we choose to support quoted json client-side, let's keep scope down. opentracing has tags (which map to binary annotations) and the new thing is that annotations might be a single-level map rendered as quoted json. Single-level aren't allowed to be nested, so you wouldn't have "a":[1,2,3]

This in mind, they could just as well be rendered the same as our binary annotations, except possibly adding the timestamp of the annotation that encloses them.

I still shudder at the abuse of the string field

@codefromthecrypt
Copy link
Author

codefromthecrypt commented Sep 27, 2016

ps added more rationale here, hoping people resist the temptation to pollute zipkin with stringified json cc opentracing advocate @basvanbeek

openzipkin/openzipkin.github.io#52 (comment)

@eirslett
Copy link

When you do searches in Elasticsearch, the query is JSON, not SQL. And that could be handy to have as a binary annotation, right?

@codefromthecrypt
Copy link
Author

@eirslett elasticsearch queries specialize in natural json fields. they cannot navigate into quoted json naturally.

For example, the following two json:

    {
      "timestamp": 1474934400200000,
      "value": "{\n  \"type\": \"error\",\n  \"kind\": \"client\",\n  \"class\": \"SocketException\",\n  \"message\": \"socket closed\"\n}"
    }
    {
      "timestamp": 1474934400200000,
      "value": "Client Receive Error: SocketException: socket closed"
    }

The latter is easier to query with elasticsearch (sql, or cql) operators, as it is a plain string, vs quoted json.

Do you disagree?

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html

@codefromthecrypt
Copy link
Author

Ex. I know of no syntax to navigate into quoted json, like value.kind:"client" Maybe there's a "fuzzy json" mechanism I'm not aware of..

@codefromthecrypt
Copy link
Author

@eirslett I think I answered the wrong question :)

You aren't asking about how to query annotations in json using elasticsearch, you are asking about when you are tracing elasticsearch and the query was represented in json and a binary annotation. Sorry, I got confused.

Yes, of course if a binary annotation value itself is json, or any other kind of string, there's a use case for displaying it. I think we ran into that before. Binary annotations naturally have a key, so that's actually something we can handle even better as time goes on.

This issue is about annotations, not binary annotations. Ex. embedding quoted json as the annotation value. I think this practice is more questionable.

@rogeralsing
Copy link
Contributor

So where are we on this topic? should we have special rendering of json?

@codefromthecrypt
Copy link
Author

codefromthecrypt commented Oct 1, 2016 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants