Package list golang-github-go-kit-kit / 3ecf18f
Allow actual Zipkin (Scribe) Collectors Peter Bourgon 6 years ago
2 changed file(s) with 32 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
3939 // of glog. So, we define a new flag set, to keep those domains distinct.
4040 fs := flag.NewFlagSet("", flag.ExitOnError)
4141 var (
42 proxyHTTPAddr = fs.String("proxy.http.addr", "", "if set, proxy requests over HTTP to this addsvc")
43 debugAddr = fs.String("debug.addr", ":8000", "Address for HTTP debug/instrumentation server")
44 httpAddr = fs.String("http.addr", ":8001", "Address for HTTP (JSON) server")
45 grpcAddr = fs.String("grpc.addr", ":8002", "Address for gRPC server")
46 thriftAddr = fs.String("thrift.addr", ":8003", "Address for Thrift server")
47 thriftProtocol = fs.String("thrift.protocol", "binary", "binary, compact, json, simplejson")
48 thriftBufferSize = fs.Int("thrift.buffer.size", 0, "0 for unbuffered")
49 thriftFramed = fs.Bool("thrift.framed", false, "true to enable framing")
50 zipkinServiceName = fs.String("zipkin.service.name", "addsvc", "Zipkin service name")
42 debugAddr = fs.String("debug.addr", ":8000", "Address for HTTP debug/instrumentation server")
43 httpAddr = fs.String("http.addr", ":8001", "Address for HTTP (JSON) server")
44 grpcAddr = fs.String("grpc.addr", ":8002", "Address for gRPC server")
45 thriftAddr = fs.String("thrift.addr", ":8003", "Address for Thrift server")
46 thriftProtocol = fs.String("thrift.protocol", "binary", "binary, compact, json, simplejson")
47 thriftBufferSize = fs.Int("thrift.buffer.size", 0, "0 for unbuffered")
48 thriftFramed = fs.Bool("thrift.framed", false, "true to enable framing")
49
50 proxyHTTPAddr = fs.String("proxy.http.url", "", "if set, proxy requests over HTTP to this addsvc")
51
52 zipkinServiceName = fs.String("zipkin.service.name", "addsvc", "Zipkin service name")
53 zipkinCollectorAddr = fs.String("zipkin.collector.addr", "", "Zipkin Scribe collector address (empty will log spans)")
54 zipkinCollectorTimeout = fs.Duration("zipkin.collector.timeout", time.Second, "Zipkin collector timeout")
55 zipkinCollectorBatchSize = fs.Int("zipkin.collector.batch.size", 100, "Zipkin collector batch size")
56 zipkinCollectorBatchInterval = fs.Duration("zipkin.collector.batch.interval", time.Second, "Zipkin collector batch interval")
5157 )
5258 flag.Usage = fs.Usage // only show our flags
5359 fs.Parse(os.Args[1:])
8389
8490 // `package tracing` domain
8591 zipkinHostPort := "localhost:1234" // TODO Zipkin makes overly simple assumptions about services
86 zipkinCollector := loggingCollector{logger}
92 var zipkinCollector zipkin.Collector = loggingCollector{logger}
93 if *zipkinCollectorAddr != "" {
94 var err error
95 if zipkinCollector, err = zipkin.NewScribeCollector(
96 *zipkinCollectorAddr,
97 *zipkinCollectorTimeout,
98 *zipkinCollectorBatchSize,
99 *zipkinCollectorBatchInterval,
100 ); err != nil {
101 logger.Log("err", err)
102 os.Exit(1)
103 }
104 }
87105 zipkinMethodName := "add"
88106 zipkinSpanFunc := zipkin.MakeNewSpanFunc(zipkinHostPort, *zipkinServiceName, zipkinMethodName)
107 zipkin.Log.Swap(logger) // log diagnostic/error details
89108
90109 // Our business and operational domain
91110 var a Add = pureAdd
231250 for i, a := range annotations {
232251 values[i] = a.Value
233252 }
234 kitlog.With(c.Logger, "caller", kitlog.DefaultCaller).Log(
253 c.Logger.Log(
235254 "trace_id", s.TraceID(),
236255 "span_id", s.SpanID(),
237256 "parent_span_id", s.ParentSpanID(),
55 "golang.org/x/net/context"
66 )
77
8 // Endpoint is the fundamental building block of packages server and client.
8 // Endpoint is the fundamental building block of servers and clients.
99 // It represents a single RPC method.
1010 type Endpoint func(ctx context.Context, request interface{}) (response interface{}, err error)
1111
12 // Middleware is a chainable behavior modifier.
12 // Middleware is a chainable behavior modifier for endpoints.
1313 type Middleware func(Endpoint) Endpoint
1414
1515 // ErrBadCast indicates an unexpected concrete request or response struct was