-
Notifications
You must be signed in to change notification settings - Fork 166
Adds encoders. #8
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
Conversation
9024a0f to
9a48880
Compare
kevinlebrun
left a comment
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.
There are weird things going on around those micro-seconds time management. Are strings an option?
src/DDTrace/Encoders/Json.php
Outdated
| * @param Span $span | ||
| * @return array | ||
| */ | ||
| private static function spanToArray(Span $span) |
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.
Why is this method declared static? Is an instance method not good enough?
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.
Good question, don't remember the answer but will check it out later.
src/DDTrace/Encoders/Json.php
Outdated
| return $arraySpan; | ||
| } | ||
|
|
||
| private static function encodeSpan(Span $span) |
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.
Same as for spanToArray.
| } | ||
|
|
||
| if ($span->isFinished()) { | ||
| $arraySpan['duration_micro'] = 0; |
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.
It seems a little hacky. Why are you doing the replace inside encodeSpan? If it is a matter of int precision even with those rare 32-bit runtime you have more then 2000second to store the duration.
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.
It was a matter of consistency. Since both start and duration are being stored as micro and then converted into nano when encoding, doing so only for start and not for duration seemed weird to me. If this bugs you too much we can have a chat and get into an agreement. WDYT?
| 'name' => $span->getOperationName(), | ||
| 'resource' => $span->getResource(), | ||
| 'service' => $span->getService(), | ||
| 'start_micro' => 0, |
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.
It seems a little hacky.
| { | ||
| $expectedPayload = <<<JSON | ||
| [[{"trace_id":"160e7072ff7bd5f1","span_id":"160e7072ff7bd5f2","name":"test_name","resource":"test_resource", | ||
| JSON |
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.
Why is this concatenation necessary?
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.
This was because maximum line length per file (linters). The way to avoid this is to ident the json fields but that screw up the comparison in line 31. Remember, we can't convert the json into array/object in order to compare it because of the lack of support for int64 in PHP.
|
Not sure about the string @kevinlebrun. @palazzem is it possible to send the |
9a48880 to
1e88111
Compare
|
@jcchavezs actually the Trace Agent (written in Go) expects an This happens for the MsgPack Encoder, while for the JSON Encoder you'll get: |
|
I guess since this is the only way to pass the int64 we can merge this PR. What do you think @kevinlebrun ? |
|
Yes, totally. |
kevinlebrun
left a comment
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.
GTM.
|
@kevinlebrun @palazzem can you approve this PR? |
palazzem
left a comment
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.
All good to me!
This depends on #7
Ping @palazzem @vlad-mh @kevinlebrun