Package list golang-github-go-kit-kit / 67928b5
updated addsvc to include Zipkin HTTP Collector for testing without Kafka Bas van Beek 4 years ago
2 changed file(s) with 49 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
3939 thriftProtocol = flag.String("thrift.protocol", "binary", "binary, compact, json, simplejson")
4040 thriftBufferSize = flag.Int("thrift.buffer.size", 0, "0 for unbuffered")
4141 thriftFramed = flag.Bool("thrift.framed", false, "true to enable framing")
42 zipkinAddr = flag.String("zipkin.addr", "", "Enable Zipkin tracing via a Kafka Collector host:port")
42 zipkinAddr = flag.String("zipkin.addr", "", "Enable Zipkin tracing via a Zipkin HTTP Collector endpoint")
43 zipkinKafkaAddr = flag.String("zipkin.kafka.addr", "", "Enable Zipkin tracing via a Kafka server host:port")
4344 appdashAddr = flag.String("appdash.addr", "", "Enable Appdash tracing via an Appdash server host:port")
4445 lightstepToken = flag.String("lightstep.token", "", "Enable LightStep tracing via a LightStep access token")
4546 method = flag.String("method", "sum", "sum, concat")
5657 var tracer stdopentracing.Tracer
5758 {
5859 if *zipkinAddr != "" {
60 // endpoint typically looks like: http://zipkinhost:9411/api/v1/spans
61 collector, err := zipkin.NewHTTPCollector(*zipkinAddr)
62 if err != nil {
63 fmt.Fprintf(os.Stderr, "%v\n", err)
64 os.Exit(1)
65 }
66 defer collector.Close()
67
68 tracer, err = zipkin.NewTracer(
69 zipkin.NewRecorder(collector, false, "0.0.0.0:0", "addcli"),
70 )
71 if err != nil {
72 fmt.Fprintf(os.Stderr, "%v\n", err)
73 os.Exit(1)
74 }
75 } else if *zipkinKafkaAddr != "" {
5976 collector, err := zipkin.NewKafkaCollector(
60 strings.Split(*zipkinAddr, ","),
77 strings.Split(*zipkinKafkaAddr, ","),
6178 zipkin.KafkaLogger(log.NewNopLogger()),
6279 )
6380 if err != nil {
6481 fmt.Fprintf(os.Stderr, "%v\n", err)
6582 os.Exit(1)
6683 }
84 defer collector.Close()
85
6786 tracer, err = zipkin.NewTracer(
68 zipkin.NewRecorder(collector, false, "localhost:8000", "addcli"),
87 zipkin.NewRecorder(collector, false, "0.0.0.0:0", "addcli"),
6988 )
7089 if err != nil {
7190 fmt.Fprintf(os.Stderr, "%v\n", err)
3939 thriftProtocol = flag.String("thrift.protocol", "binary", "binary, compact, json, simplejson")
4040 thriftBufferSize = flag.Int("thrift.buffer.size", 0, "0 for unbuffered")
4141 thriftFramed = flag.Bool("thrift.framed", false, "true to enable framing")
42 zipkinAddr = flag.String("zipkin.addr", "", "Enable Zipkin tracing via a Kafka server host:port")
42 zipkinAddr = flag.String("zipkin.addr", "", "Enable Zipkin tracing via a Zipkin HTTP Collector endpoint")
43 zipkinKafkaAddr = flag.String("zipkin.kafka.addr", "", "Enable Zipkin tracing via a Kafka server host:port")
4344 appdashAddr = flag.String("appdash.addr", "", "Enable Appdash tracing via an Appdash server host:port")
4445 lightstepToken = flag.String("lightstep.token", "", "Enable LightStep tracing via a LightStep access token")
4546 )
8485 var tracer stdopentracing.Tracer
8586 {
8687 if *zipkinAddr != "" {
87 logger := log.NewContext(logger).With("tracer", "Zipkin")
88 logger := log.NewContext(logger).With("tracer", "ZipkinHTTP")
8889 logger.Log("addr", *zipkinAddr)
90
91 // endpoint typically looks like: http://zipkinhost:9411/api/v1/spans
92 collector, err := zipkin.NewHTTPCollector(*zipkinAddr)
93 if err != nil {
94 logger.Log("err", err)
95 os.Exit(1)
96 }
97 defer collector.Close()
98
99 tracer, err = zipkin.NewTracer(
100 zipkin.NewRecorder(collector, false, "localhost:80", "addsvc"),
101 )
102 if err != nil {
103 logger.Log("err", err)
104 os.Exit(1)
105 }
106 } else if *zipkinKafkaAddr != "" {
107 logger := log.NewContext(logger).With("tracer", "ZipkinKafka")
108 logger.Log("addr", *zipkinKafkaAddr)
109
89110 collector, err := zipkin.NewKafkaCollector(
90 strings.Split(*zipkinAddr, ","),
91 zipkin.KafkaLogger(logger),
111 strings.Split(*zipkinKafkaAddr, ","),
112 zipkin.KafkaLogger(log.NewNopLogger()),
92113 )
93114 if err != nil {
94115 logger.Log("err", err)
95116 os.Exit(1)
96117 }
118 defer collector.Close()
119
97120 tracer, err = zipkin.NewTracer(
98121 zipkin.NewRecorder(collector, false, "localhost:80", "addsvc"),
99122 )