openzipkin / zipkin-js

Zipkin instrumentation for Node.js and browsers
Apache License 2.0
565 stars 171 forks source link

Feature request: use 'fast-json-stringify' to encode span into a json #487

Open lukiano opened 4 years ago

lukiano commented 4 years ago

Given that the span model is known, I was wondering if we could use a library like the one mentioned in the title. For those unfamiliar with it, if a javascript object follow a known schema, by passing that schema to the library it will stringify the object much faster than plain JSON.stringify.

jcchavezs commented 4 years ago

Interesting, would you give it a try in a PR? Maybe a simple benchmark would be also good.

On Thu, 20 Feb 2020, 06:55 Luciano Leggieri, notifications@github.com wrote:

Given that the span model is known, I was wondering if we could use a library like the one mentioned in the title. For those unfamiliar with it, if a javascript object follow a known schema, by passing that schema to the library it will stringify the object much faster than plain JSON.stringify.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/openzipkin/zipkin-js/issues/487?email_source=notifications&email_token=AAXOYARQRWXODZC6ZECAFFTRDYLLLA5CNFSM4KYHX3LKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IO4BMTQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXOYAR76FIJ3NWFDDE2DLLRDYLLLANCNFSM4KYHX3LA .

lukiano commented 4 years ago

I can try. I have to fetch the actual schema. I have some doubts on what's allowed on a tag.

jcchavezs commented 4 years ago

You can see the specs of the v2 model in https://zipkin.io/zipkin-api/#/default/post_spans.

tags is a map of string key and string value

lukiano commented 4 years ago

Currently blocked on https://github.com/fastify/fast-json-stringify/pull/209

lukiano commented 4 years ago

Processing the span on line https://github.com/openzipkin/zipkin-js/blob/7039cafbfffe521b0b2a024f50f33e3d47001e9f/packages/zipkin/test/jsonEncoder.JSON_V2.test.js#L50 in a loop 10 million times gives the following results: