Codebase list golang-github-go-kit-kit / 40b062f
Merge pull request #373 from basvanbeek/master update to zipkin documentation Peter Bourgon authored 7 years ago GitHub committed 7 years ago
2 changed file(s) with 39 addition(s) and 105 deletion(s). Raw diff Collapse all Expand all
11
22 ## Development and Testing Set-up
33
4 Setting up [Zipkin] is not an easy thing to do. It will also demand quite some
5 resources. To help you get started with development and testing we've made a
6 docker-compose file available for running a full Zipkin stack.
4 Great efforts have been made to make [Zipkin] easier to test, develop and
5 experiment against. [Zipkin] can now be run from a single Docker container or by
6 running its self-contained executable jar without extensive configuration. In
7 its default configuration you will run Zipkin with a HTTP collector, In memory
8 Span storage backend and web UI on port 9411.
79
8 You will need [docker-compose] 1.6.0+ and [docker-engine] 1.10.0+.
9
10 If running on Linux `HOSTNAME` can be set to `localhost`. If running on Mac OS X
11 or Windows you probably need to set the hostname environment variable to the
12 hostname of the VM running the docker containers.
13
14 ```sh
15 cd tracing/zipkin
16 HOSTNAME=localhost docker-compose -f docker-compose-zipkin.yml up
10 Example:
11 ```
12 docker run -d -p 9411:9411 openzipkin/zipkin
1713 ```
1814
19 [Zipkin]: http://zipkin.io/
20 [docker-compose]: https://docs.docker.com/compose/
21 [docker-engine]: https://docs.docker.com/engine/
15 [zipkin]: http://zipkin.io
2216
23 As mentioned the [Zipkin] stack is quite heavy and may take a few minutes to
24 fully initialize.
25
26 The following services have been set-up to run:
27 - Apache Cassandra (port: 9160 (thrift), 9042 (native))
28 - Apache ZooKeeper (port: 2181)
29 - Apache Kafka (port: 9092)
30 - Zipkin Collector
31 - Zipkin Query
32 - Zipkin Web (port: 8080, 9990)
33
17 Instrumenting your services with Zipkin distributed tracing using the default
18 configuration is now possible with the latest release of [zipkin-go-opentracing]
19 as it includes an HTTP transport for sending spans to the [Zipkin] HTTP
20 Collector.
3421
3522 ## Middleware Usage
3623
3724 Follow the [addsvc] example to check out how to wire the Zipkin Middleware. The
3825 changes should be relatively minor.
3926
40 The [zipkin-go-opentracing] package has support for Kafka and Scribe collectors
41 as well as using Go Kit's [Log] package for logging.
27 The [zipkin-go-opentracing] package has support for HTTP, Kafka and Scribe
28 collectors as well as using Go Kit's [Log] package for logging.
29
30 ### Configuring for the Zipkin HTTP Collector
31
32 To select the transport for the HTTP Collector, you configure the `Recorder`
33 with the appropriate collector like this:
34
35 ```go
36 var (
37 debugMode = false
38 serviceName = "MyService"
39 serviceHostPort = "localhost:8000"
40 zipkinHTTPEndpoint = "localhost:9411"
41 )
42 collector, err = zipkin.NewHTTPCollector(zipkinHTTPEndpoint)
43 if err != nil {
44 // handle error
45 }
46 tracer, err = zipkin.NewTracer(
47 zipkin.NewRecorder(collector, debugMode, serviceHostPort, serviceName),
48 ...
49 )
50 ```
4251
4352 ### Span per Node vs. Span per RPC
4453 By default Zipkin V1 considers either side of an RPC to have the same identity
4554 and differs in that respect from many other tracing systems which consider the
46 caller to be the parent and the receiver the child. The OpenTracing
55 caller to be the parent and the receiver to be the child. The OpenTracing
4756 specification does not dictate one model over the other, but the Zipkin team is
4857 looking into these [single-host-spans] to potentially bring Zipkin more in-line
4958 with the other tracing systems.
134143 parentSpan := opentracing.SpanFromContext(ctx)
135144 if parentSpan == nil {
136145 parentSpan = opentracing.StartSpan(queryLabel)
146 defer parentSpan.Finish()
137147 }
138148
139149 // create a new span to record the resource interaction
+0
-76
tracing/zipkin/docker-compose-zipkin.yml less more
0 # This file uses the version 2 docker-compose file format, described here:
1 # https://docs.docker.com/compose/compose-file/#version-2
2 #
3 # It runs the zipkin-cassandra, zipkin-collector, zipkin-query, zipkin-web, and
4 # zookeeper-exhibitor containers.
5 #
6 # On linux you probably want to start this composition like this:
7 #
8 # HOSTNAME=localhost docker-compose -f docker-compose-zipkin.yml up
9 #
10 # On OS X you will probably start like this:
11 #
12 # HOSTNAME=default docker-compose -f docker-compose-zipkin.yml up
13
14 version: '2'
15 services:
16 cassandra:
17 image: openzipkin/zipkin-cassandra:1.39.4
18 network_mode: host
19
20 zookeeper:
21 image: mbabineau/zookeeper-exhibitor:latest
22 network_mode: host
23 environment:
24 HOSTNAME: ${HOSTNAME}
25
26 kafka:
27 image: wurstmeister/kafka
28 network_mode: host
29 environment:
30 KAFKA_CREATE_TOPICS: "zipkin:1:1"
31 KAFKA_ZOOKEEPER_CONNECTION_TIMEOUT_MS: 60000
32 KAFKA_ADVERTISED_PORT: 9092
33 KAFKA_ADVERTISED_HOST_NAME: ${HOSTNAME}
34 KAFKA_ZOOKEEPER_CONNECT: ${HOSTNAME}:2181
35 depends_on:
36 - zookeeper
37
38 collector:
39 image: openzipkin/zipkin-collector:1.39.4
40 network_mode: host
41 environment:
42 STORAGE_TYPE: cassandra
43 TRANSPORT_TYPE: kafka
44 CASSANDRA_CONTACT_POINTS: ${HOSTNAME}
45 KAFKA_ZOOKEEPER: ${HOSTNAME}:2181
46 METADATA_BROKER_LIST: ${HOSTNAME}:9092
47 depends_on:
48 - cassandra
49 - kafka
50
51 query:
52 image: openzipkin/zipkin-query:1.39.4
53 network_mode: host
54 environment:
55 STORAGE_TYPE: cassandra
56 TRANSPORT_TYPE: kafka
57 CASSANDRA_CONTACT_POINTS: ${HOSTNAME}
58 KAFKA_ZOOKEEPER: ${HOSTNAME}:2181
59 METADATA_BROKER_LIST: ${HOSTNAME}:9092
60 depends_on:
61 - cassandra
62 - kafka
63
64 web:
65 image: openzipkin/zipkin-web:1.39.4
66 network_mode: host
67 environment:
68 TRANSPORT_TYPE: kafka
69 KAFKA_ZOOKEEPER: ${HOSTNAME}:2181
70 METADATA_BROKER_LIST: ${HOSTNAME}:9092
71 QUERY_PORT_9411_TCP_ADDR: ${HOSTNAME}
72 ROOTURL: http://${HOSTNAME}:8080
73 depends_on:
74 - cassandra
75 - kafka