39 | 39 |
// of glog. So, we define a new flag set, to keep those domains distinct.
|
40 | 40 |
fs := flag.NewFlagSet("", flag.ExitOnError)
|
41 | 41 |
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")
|
51 | 57 |
)
|
52 | 58 |
flag.Usage = fs.Usage // only show our flags
|
53 | 59 |
fs.Parse(os.Args[1:])
|
|
83 | 89 |
|
84 | 90 |
// `package tracing` domain
|
85 | 91 |
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 |
}
|
87 | 105 |
zipkinMethodName := "add"
|
88 | 106 |
zipkinSpanFunc := zipkin.MakeNewSpanFunc(zipkinHostPort, *zipkinServiceName, zipkinMethodName)
|
|
107 |
zipkin.Log.Swap(logger) // log diagnostic/error details
|
89 | 108 |
|
90 | 109 |
// Our business and operational domain
|
91 | 110 |
var a Add = pureAdd
|
|
231 | 250 |
for i, a := range annotations {
|
232 | 251 |
values[i] = a.Value
|
233 | 252 |
}
|
234 | |
kitlog.With(c.Logger, "caller", kitlog.DefaultCaller).Log(
|
|
253 |
c.Logger.Log(
|
235 | 254 |
"trace_id", s.TraceID(),
|
236 | 255 |
"span_id", s.SpanID(),
|
237 | 256 |
"parent_span_id", s.ParentSpanID(),
|