spacemonkeygo/monkit-zipkin

Name: monkit-zipkin

Owner: Space Monkey Go

Description: Zipkin plugin for Monkit

Created: 2016-06-23 22:31:44.0

Updated: 2018-04-04 03:31:43.0

Pushed: 2016-10-07 20:31:02.0

Homepage: https://godoc.org/gopkg.in/spacemonkeygo/monkit-zipkin.v2

Size: 32

Language: Go

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

monkit-zipkin

A plugin for http://github.com/spacemonkeygo/monkit that supports Zipkin.

See the docs at http://godoc.org/gopkg.in/spacemonkeygo/monkit-zipkin.v2

Example usage

Your main method gets set up something like this:

age main

rt (
"net/http"

"gopkg.in/spacemonkeygo/monkit-zipkin.v2"
"gopkg.in/spacemonkeygo/monkit.v2"
"gopkg.in/spacemonkeygo/monkit.v2/environment"
"gopkg.in/spacemonkeygo/monkit.v2/present"


 main() {
environment.Register(monkit.Default)
go http.ListenAndServe("localhost:9000", present.HTTP(monkit.Default))
collector, err := zipkin.NewScribeCollector("zipkin.whatever:9042")
if err != nil {
    panic(err)
}
zipkin.RegisterZipkin(monkit.Default, collector, zipkin.Options{
    Fraction: 1})

...

Once you've done that, you need to make sure your HTTP handlers pull Zipkin Context info from the Request. That's easy to do with zipkin.ContextWrapper.

 HandleRequest(ctx context.Context, w http.ResponseWriter,
*http.Request) {
fer mon.Task()(&ctx)(nil)

. whatever


 DoTheThing(ctx context.Context) (err error) {
fer mon.Task()(&ctx)(&err)
turn http.Serve(listener, zipkin.ContextWrapper(
zipkin.TraceHandler(zipkin.ContextHTTPHandlerFunc(HandleRequest))))

Last, your outbound HTTP requests need to pass through Context info:

 MakeRequest(ctx context.Context) (err error) {
fer mon.Task()(&ctx)(&err)
q, err := http.NewRequest(...)
 err != nil {
return err

sp, err := zipkin.TraceRequest(ctx, http.DefaultClient, req)
.

License

Copyright © 2016 Space Monkey, Inc.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.