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

Collect Zipkin v2 json #518

Merged
merged 8 commits into from
Nov 16, 2017
Merged

Conversation

pavolloffay
Copy link
Member

@pavolloffay pavolloffay commented Nov 8, 2017

Fixes #450

How does it work:

  • zipkin swagger from idl is compiled to go code (it uses https://github.com/go-swagger/go-swagger)
  • custom http handler which uses generated files to unmarshall and validate spans
  • convert swagger model classes to zipkin thrift

Zipkin related links:
messaging annos: openzipkin/zipkin-api#29
span v2: openzipkin/zipkin#1499

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.3%) to 98.656% when pulling 4b12db5 on pavolloffay:zipkin-v2 into 2b73fe9 on jaegertracing:master.

.gitmodules Outdated
@@ -4,3 +4,6 @@
[submodule "jaeger-ui"]
path = jaeger-ui
url = https://github.com/uber/jaeger-ui
[submodule "zipkin-api"]
path = zipkin-api
url = https://github.com/openzipkin/zipkin-api
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly are we getting from zipkin? I would rather do it without submodule dependency

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's just one file we should simply copy it, similar to how we copy the thrift IDL file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only one file https://github.com/openzipkin/zipkin-api/blob/master/zipkin2-api.yaml The repo only contains API definitions: thrift and swagger.

I wanted to propose to use that also for zipkin.thrift. Or we can just simply copy swagger to our idl. I don't have a strong preference. Zipkin submodule is easier to maintain. For example our zipkin thrift definition file slightly differs from upstream.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to copy

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coveralls
Copy link

Coverage Status

Coverage decreased (-2.3%) to 97.716% when pulling cd795b5 on pavolloffay:zipkin-v2 into a2ed9b8 on jaegertracing:master.

@pavolloffay
Copy link
Member Author

xdock tests with brave using JSON V2 are passing. It can be reviewed. In meanwhile I will improve coverage and wait for swagger a thrift IDL changes.

@coveralls
Copy link

Coverage Status

Coverage decreased (-2.2%) to 97.716% when pulling 102d6cf on pavolloffay:zipkin-v2 into 32e2cd3 on jaegertracing:master.

@pavolloffay pavolloffay changed the title WIP: Collect Zipkin v2 json Collect Zipkin v2 json Nov 13, 2017
@pavolloffay
Copy link
Member Author

it's ready for review

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 43b8461 on pavolloffay:zipkin-v2 into e0a74f2 on jaegertracing:master.

if err != nil {
return nil, err
}
defer gz.Close()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't this close gz at the end of this function? looking at the tests, it looks like it works fine? hmmm

}

// NewAPIHandler returns a new APIHandler
func NewAPIHandler(
zipkinSpansHandler app.ZipkinSpansHandler,
) *APIHandler {
) (*APIHandler, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function doesn't seem to return an error, is the API change necessary?

"github.com/jaegertracing/jaeger/thrift-gen/zipkincore"
)

func spansV2ToThrift(spans *models.ListOfSpans) ([]*zipkincore.Span, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the pointer to the slice required? It doesn't look like you're doing anything to the slice reference in this function. Without the pointer, this function should be more readable

return tSpans, nil
}

func spanV2ToThrift(s models.Span) (*zipkincore.Span, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when this function is invoked on L26, you already have a pointer to the span. Why not pass the pointer rather than making a copy of the span and passing that by value?

}

func annoV2ToThrift(a *models.Annotation, e *zipkincore.Endpoint) *zipkincore.Annotation {
ta := &zipkincore.Annotation{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like you can inline return

}

func tagsToThrift(tags models.Tags, localE *zipkincore.Endpoint) []*zipkincore.BinaryAnnotation {
var bAnnos []*zipkincore.BinaryAnnotation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preallocate bAnnos to len(tags)

@@ -53,6 +54,14 @@ services:
environment:
- ENCODING=JSON

zipkin-brave-json-v2:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 love how easy it is to integration test new endpoints

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling ca70179 on pavolloffay:zipkin-v2 into e0a74f2 on jaegertracing:master.

)

func spansV2ToThrift(spans models.ListOfSpans) ([]*zipkincore.Span, error) {
var tSpans []*zipkincore.Span
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be preallocated too

Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 78db314 on pavolloffay:zipkin-v2 into 5db9cde on jaegertracing:master.

@coveralls
Copy link

coveralls commented Nov 15, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 78db314 on pavolloffay:zipkin-v2 into 5db9cde on jaegertracing:master.

@pavolloffay
Copy link
Member Author

@yurishkuro I will merge on green, I can apply additional changes in a separate PR.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 3a703db on pavolloffay:zipkin-v2 into 6897ca2 on jaegertracing:master.

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

Successfully merging this pull request may close these issues.

4 participants