Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Zipkin plugin #3080

Merged
merged 162 commits into from
Aug 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
162 commits
Select commit Hold shift + click to select a range
56c714b
Add inital skeleton for zipkin input plugin
Jun 27, 2017
ae65f10
Add concurrent zipkin http server to zipkin plugin for data fetching
Jun 27, 2017
83ff0e7
Add new skeleton for telegraf.ServiceInput to zipkin plugin
Jun 27, 2017
4d74b4d
Add simple test program for zipkin http server to zipkin plugin
Jun 27, 2017
bba8922
Add Godoc comments to zipkin_server.go in zipkin input plugin
Jun 28, 2017
89c471a
Update directory structure in zipkin plugin
Jun 28, 2017
72668e9
Rename zipkin_server.go to server.go
Jun 28, 2017
158e13c
Add TODO comments to server.go in zipkin plugin
Jun 28, 2017
f7acf33
Fix import path in main.go in zipkin plugin
Jun 28, 2017
8a858d9
Fix handler in server.go so that it returns correct http status in zi…
Jun 28, 2017
6ecefac
Add test for zipkin http server
Jun 28, 2017
898b3b6
Modify internal http server in zipkin plugin to use go 1.8 features f…
Jun 29, 2017
157b200
Update main.go to use new methods in zipkin server
Jun 29, 2017
b3dda37
Update server_test.go to call zipkin server constructor with the corr…
Jun 29, 2017
b6ebe5c
Add TODO comment to server.go in zipkin plugin
Jun 29, 2017
1147bcf
Update Godeps
Jun 29, 2017
53eaa02
Begin to add interfaces to zipkin plugin
Jun 29, 2017
76d4979
Update zipkin.go to include server and and interfaces/method implemen…
Jun 30, 2017
b8697b4
Add test for new unmarshalling features added to zipkin.go
Jun 30, 2017
bec51bf
Rename main struct in server.go to avoidpackage level naming conflict…
Jun 30, 2017
3882050
fix formatting directive in new_server_test.go in zipking plugin
Jun 30, 2017
1c799cc
Enable zipkin plugin in all.go
Jun 30, 2017
5a1d7ad
Delete outdated main.go file in zipkin plugin
Jun 30, 2017
9575625
Remove redeclared constant in server.go in zipkin plugin
Jun 30, 2017
4672463
Finish interface implementations in main zipkin plugin file
Jun 30, 2017
438e710
Rename test data directory
Jun 30, 2017
9239d64
Re-order method and type declaration in zipkin.go and add Godoc comments
Jun 30, 2017
e96bfba
Update data file path in new_server_test.go
Jun 30, 2017
f2adbe9
Add todo comments to zipkin.go in zipkin plugin
Jun 30, 2017
4ee9246
Disable server_test.go for current testing in zipkin plugin
Jun 30, 2017
4017863
Refactor zipkin server implementation into multiple files
Jul 5, 2017
7b60eef
Change http header status written on error condition in zipkin server…
Jul 5, 2017
9f4a837
Add initial telegraf conversion code to zipkin.go
Jul 6, 2017
a6ed636
Update zipkin plugin line protocol schema
Jul 7, 2017
c066ac1
Fix invalid struct fields in new_server_test.go for zipkin plugin
Jul 7, 2017
ca91421
Add zero check when working with traceid and remove excess comments i…
Jul 10, 2017
23b6798
Update new_server_test.go to account for changes to zipkin schema
Jul 10, 2017
e643d12
Add initial unit test for zipkin plugin
Jul 10, 2017
c876696
Add additional log statement to server_new.go
Jul 10, 2017
24ceba6
Change name of measurement for zipkin binary annotations
Jul 10, 2017
36198de
Add clarifying comments to zipkin server test, fix hardcoded path nam…
Jul 10, 2017
981b464
Add timestamp test for last metric in zipkin plugin unit test
Jul 10, 2017
7e828f6
Remove extraneous debug statement from new_server_test.go in zipkin p…
Jul 10, 2017
71d4b2f
Comment out debug statements in zipkin.go
Jul 10, 2017
bd08579
Add additional log statement to zipkin server test
Jul 11, 2017
e42c14b
Add unit test framework to zipkin plugin tests
Jul 11, 2017
7887367
Add separate file for unit test data to zipkin plugin
Jul 11, 2017
6003833
Remove new_server_test.go from zipkin plugin
Jul 11, 2017
581a8af
Add dependecy to server.go in zipkin plugin
Jul 11, 2017
38c85f6
Remove server_new.go
Jul 11, 2017
3e26625
Update server_test.go to contain new zipkin server unit test
Jul 11, 2017
64348cf
Add missing constant to zipkin.go
Jul 11, 2017
b6aa6fb
Add ability to wait for variable number of points to be written in zi…
Jul 12, 2017
1b417c4
Add additional unit test case to zipkin plugin, based on go openzipki…
Jul 12, 2017
92464a3
Remove debug file writing in zipkin server
Jul 12, 2017
5b2bfb7
Add scraped binary data file from openzipkin example cli app
Jul 12, 2017
75ee454
Add json representation of binary data from openzipkin cli app to vis…
Jul 12, 2017
7bab3df
Rename cli microservice data file
Jul 12, 2017
e51b1a0
Rename cli microservice json file
Jul 12, 2017
716b294
Add in loop to run all tests, add additional logs
Jul 12, 2017
2250eb7
Add additional debugging information to server logs in zipkin plugin
Jul 12, 2017
ec4d600
Add additional unit test data to zipkin plugin unit test from distrib…
Jul 12, 2017
ae105e8
Remove outdated comments from zipkin plugin
Jul 12, 2017
74db3ee
Change formatting in example data json file in zipkin plugin
Jul 12, 2017
e2d4463
Add additional binary unit test data with json representation to zipk…
Jul 12, 2017
e55bce3
Add go script to convert json to zipkin thrift protocol
Jul 12, 2017
970569c
Add json representation of testdata/threespans.dat to zipkin plugin
Jul 12, 2017
76fba59
Remove copy of first unit test for threespans.dat in zipkin plugin
Jul 12, 2017
ce09726
Add clarifying comments to unit test structs in zipkin plugin
Jul 12, 2017
4f3c91d
Remove unsued meta annotation struct
Jul 12, 2017
d82c8a3
Move thrift unmarshalling logic into separate function in zipkin plugin
Jul 13, 2017
150996d
Add go doc comments to zipkin.go
Jul 13, 2017
ee32c86
Remove unnecessary variable in zipkin.go, update sample config file
Jul 13, 2017
f4f5882
Update source code with go format
Jul 13, 2017
c6a8671
Rename zipkin server.go to handler.go
Jul 13, 2017
ac56b04
Refactor zipkin plugin
Jul 13, 2017
09a5628
WIP: Refactor tests in zipkin plugin
Jul 13, 2017
6ddf4d8
Add convert table test to zipkin plugin
Jul 14, 2017
070ec04
Fix timestamp units to microseconds for zipkin plugin
Jul 17, 2017
9d37894
Add more data for testing zipkin plugin
Jul 17, 2017
743a18d
Refactor formatting for zipkin plugin
Jul 18, 2017
e0d4c38
Fix bugs in test data for zipkin plugin
Jul 18, 2017
aa430af
Fix test logic bugs in zipkin plugin
Jul 19, 2017
c8e5494
Refactor zipkin plugin
Jul 19, 2017
6916c32
WIP: Create tests for zipkin plugin
Jul 20, 2017
72d0997
Temporarily comment out un-used test files in zipkin plugin
Jul 20, 2017
554df49
Update test to expect UTC times in zipkin plugin
Jul 20, 2017
017a682
add tests for minMax in zipkin plugin
Jul 20, 2017
ed792f9
Update zipkin tests to use UTC time
Jul 20, 2017
58d2352
Rename plugin test to zipkin test
Jul 20, 2017
d4e5e64
Combine unit_test.go to zipkin_test.go
Jul 20, 2017
f23b9bd
Add bitshift format to host in zipkin plugin
Jul 23, 2017
9265d80
Add full integration test for zipkin plugin
Jul 24, 2017
1754e13
Update test table in zipkin_test.go for new ipv4 string formatting
Jul 24, 2017
f30e787
Refactor ipv4 string conversion function in zipkin plugin to use stan…
Jul 24, 2017
64dfd37
Remove old comments from zipkin_test.go
Jul 24, 2017
0f48e48
Comment inaccurate test data in zipkin plugin
Jul 24, 2017
5780e5c
Add main file for stress writes to telegraf to zipkin plugin
Jul 25, 2017
a073a92
Add sample config for working with new tsi engine
Jul 25, 2017
b212910
Add draft of setup instructions for working with zipkin data in InfluxDB
Jul 25, 2017
57f1e2f
Update log message in stress writing script in zipkin plugin
Jul 25, 2017
2105698
Add currently broken write test benchmark
Jul 25, 2017
c5526f5
Update telegraf stress writing script in zipkin plugin
Jul 26, 2017
665e75f
Add debug log to zipkin http lander (temporary)
Jul 26, 2017
b1c1490
Make starting message more descriptive in zipkin.go
Jul 26, 2017
d31aef5
Add command line flags to cmd/stress_test_write.go in zipkin plugin
Jul 26, 2017
c6bbb7a
Move thrift_serialize to directory of Zipkin plugin
Jul 26, 2017
a65cf85
Move stress_test_write to directory of Zipkin plugin
Jul 26, 2017
8c40aa9
Update Godeps for Zipkin stress test
Jul 26, 2017
f6e6ee2
Fix vet errors for Zipkin plugin
Jul 26, 2017
3f29ecc
Add GZIP middleware to zipkin handler
Jul 27, 2017
f571b11
Add function for cors middleware to zipkin plugin
Jul 27, 2017
f21fd42
Change RP command in influx setup instructions in zipkin plugin
Jul 27, 2017
64fa992
Remove write_test.go in zipkin plugin
Jul 27, 2017
e25d498
Update thrift_serialize.go in zipkin plugin
Jul 27, 2017
5e9f1ab
Add informal notes about zipkin plugin performance
Jul 27, 2017
20e7290
Add README
Jul 28, 2017
e1056ed
Merge branch 'zipkin' of https://github.com/influxdata/telegraf into …
Jul 28, 2017
53e7a07
Add gzip and cors middleware to zipkin plugin
Jul 28, 2017
753fb6b
Remove annotation_timestamp from Zipkin plugin
Jul 28, 2017
f5c3a4a
Change duration to duration_ns
Jul 28, 2017
576685f
Change key to annotation_key
Jul 28, 2017
63caa1d
Change annotation_value to annotation
Jul 28, 2017
a708987
Remove type from binary annotations in zipkin plugin
Jul 28, 2017
df7c93b
Update README in zipkin plugin
Jul 28, 2017
60b4988
Add additional span with no annotation in zipkin plugin
Jul 28, 2017
6050cc1
Change trace ID high and low format to hexidecimal in zipkin plugin
Jul 28, 2017
52066d6
Update README definitions
Jul 28, 2017
7078fa4
Update README formatting for zipkin plugin
Jul 28, 2017
2314388
Update spans to have unique service names
Jul 31, 2017
6678586
Fix zipkins signed unsigned port number conflict
Jul 31, 2017
4b69301
Update zipkin description and sample configuration
Jul 31, 2017
6aa335c
Remove unnecessary files in zipkin plugin
Jul 31, 2017
db5d153
Change host so that port is not shown if zero
Jul 31, 2017
33654e0
Add a global span service name to zipkin span schema
Jul 31, 2017
9809815
Add a global span service name to zipkin span schema
Jul 31, 2017
ecf3712
Add a global span service name to zipkin span schema
Jul 31, 2017
c37a1b0
Update README in zipkin plugin
Aug 1, 2017
1050ff8
Merge branch 'zipkin' of https://github.com/influxdata/telegraf into …
Aug 1, 2017
0c33bbe
Update README in zipkin plugin
Aug 1, 2017
59634af
Update README in zipkin plugin
Aug 1, 2017
131e1c3
Add link to explain zipkin code
Aug 1, 2017
befbe7e
Add better description of trace example in README
Aug 1, 2017
01cfdbc
Refactor thrift_serialize.go into development tool
Aug 1, 2017
db8ac9a
Change testdata/json/distributed_trace_sample.json to array json format
Aug 1, 2017
08698d9
Move server initialization logic into start method of zipkin plugin; …
Aug 2, 2017
c33bb4d
Add test case for clean shutdown error to zipkin plugin
Aug 2, 2017
c03e54d
Change default hostname value when no endpoint is provided in zipkin …
Aug 2, 2017
7f991fd
Change default service name when no endpoint is provided
Aug 2, 2017
19ba03e
Add explanatory comment to cmd/stress_test_write/stress_test_write.go
Aug 2, 2017
17e2b6b
Remove unused struct from zipkin integration table test
Aug 2, 2017
b1ec4bd
Update LICENSE_OF_DEPENDENCIES.md for zipkin plugin
Aug 2, 2017
355c65e
Merge pull request #3085 from influxdata/zipkin-span-hostname-fix
goller Aug 2, 2017
5ff0519
Merge pull request #3086 from influxdata/zipkin-default-hostname-fix
goller Aug 2, 2017
4313cc2
Merge pull request #3084 from influxdata/zipkin-service-fixes
goller Aug 2, 2017
4bdbc75
Merge pull request #3082 from influxdata/zipkin-thrift-cli-tool
goller Aug 2, 2017
eb0f8cc
Remove unused log statement and notes file
Aug 2, 2017
729fdbe
Merge branch 'zipkin' of https://github.com/influxdata/telegraf into …
Aug 2, 2017
079b8b7
Fix linter error in zipkin plugin
Aug 2, 2017
0c23e19
Update zipkin integration test so that a random port is chosen
Aug 2, 2017
d9e4057
Add experimental disclaimer to README.md
Aug 2, 2017
bbe13d8
Merge branch 'master' of github.com:influxdata/telegraf into zipkin
Aug 3, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Godeps
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ github.com/Shopify/sarama c01858abb625b73a3af51d0798e4ad42c8147093
github.com/Sirupsen/logrus 61e43dc76f7ee59a82bdf3d71033dc12bea4c77d
github.com/aerospike/aerospike-client-go 95e1ad7791bdbca44707fedbb29be42024900d9c
github.com/amir/raidman c74861fe6a7bb8ede0a010ce4485bdbb4fc4c985
github.com/apache/thrift 4aaa92ece8503a6da9bc6701604f69acf2b99d07
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update licenses of dependencies file

github.com/aws/aws-sdk-go c861d27d0304a79f727e9a8a4e2ac1e74602fdc0
github.com/beorn7/perks 4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9
github.com/bsm/sarama-cluster ccdc0803695fbce22f1706d04ded46cd518fd832
Expand All @@ -17,10 +18,13 @@ github.com/eapache/go-resiliency b86b1ec0dd4209a588dc1285cdd471e73525c0b3
github.com/eapache/go-xerial-snappy bb955e01b9346ac19dc29eb16586c90ded99a98c
github.com/eapache/queue 44cc805cf13205b55f69e14bcb69867d1ae92f98
github.com/eclipse/paho.mqtt.golang d4f545eb108a2d19f9b1a735689dbfb719bc21fb
github.com/go-logfmt/logfmt 390ab7935ee28ec6b286364bba9b4dd6410cb3d5
github.com/go-sql-driver/mysql 2e00b5cd70399450106cec6431c2e2ce3cae5034
github.com/gobwas/glob bea32b9cd2d6f55753d94a28e959b13f0244797a
github.com/gogo/protobuf 7b6c6391c4ff245962047fc1e2c6e08b1cdfa0e8
github.com/golang/protobuf 8ee79997227bf9b34611aee7946ae64735e6fd93
github.com/golang/snappy 7db9049039a047d955fe8c19b83c8ff5abd765c7
github.com/google/go-cmp f94e52cad91c65a63acc1e75d4be223ea22e99bc
github.com/gorilla/mux 392c28fe23e1c45ddba891b0320b3b5df220beea
github.com/hailocab/go-hostpool e80d13ce29ede4452c43dea11e79b9bc8a15b478
github.com/hashicorp/consul 63d2fc68239b996096a1c55a0d4b400ea4c2583f
Expand All @@ -39,6 +43,9 @@ github.com/nats-io/nats ea9585611a4ab58a205b9b125ebd74c389a6b898
github.com/nats-io/nuid 289cccf02c178dc782430d534e3c1f5b72af807f
github.com/nsqio/go-nsq a53d495e81424aaf7a7665a9d32a97715c40e953
github.com/opencontainers/runc 89ab7f2ccc1e45ddf6485eaa802c35dcf321dfc8
github.com/opentracing-contrib/go-observer a52f2342449246d5bcc273e65cbdcfa5f7d6c63c
github.com/opentracing/opentracing-go 06f47b42c792fef2796e9681353e1d908c417827
github.com/openzipkin/zipkin-go-opentracing 1cafbdfde94fbf2b373534764e0863aa3bd0bf7b
github.com/pierrec/lz4 5c9560bfa9ace2bf86080bf40d46b34ae44604df
github.com/pierrec/xxHash 5a004441f897722c627870a981d02b29924215fa
github.com/pkg/errors 645ef00459ed84a119197bfb8d8205042c6df63d
Expand Down
5 changes: 5 additions & 0 deletions docs/LICENSE_OF_DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ works:
- github.com/eclipse/paho.mqtt.golang [ECLIPSE](https://github.com/eclipse/paho.mqtt.golang/blob/master/LICENSE)
- github.com/fsouza/go-dockerclient [BSD](https://github.com/fsouza/go-dockerclient/blob/master/LICENSE)
- github.com/gobwas/glob [MIT](https://github.com/gobwas/glob/blob/master/LICENSE)
- github.com/google/go-cmp [BSD](https://github.com/google/go-cmp/blob/master/LICENSE)
- github.com/gogo/protobuf [BSD](https://github.com/gogo/protobuf/blob/master/LICENSE)
- github.com/golang/protobuf [BSD](https://github.com/golang/protobuf/blob/master/LICENSE)
- github.com/golang/snappy [BSD](https://github.com/golang/snappy/blob/master/LICENSE)
- github.com/go-logfmt/logfmt [MIT](https://github.com/go-logfmt/logfmt/blob/master/LICENSE)
- github.com/gorilla/mux [BSD](https://github.com/gorilla/mux/blob/master/LICENSE)
- github.com/go-sql-driver/mysql [MPL](https://github.com/go-sql-driver/mysql/blob/master/LICENSE)
- github.com/hailocab/go-hostpool [MIT](https://github.com/hailocab/go-hostpool/blob/master/LICENSE)
Expand All @@ -52,6 +54,9 @@ works:
- github.com/nats-io/nats [MIT](https://github.com/nats-io/nats/blob/master/LICENSE)
- github.com/nats-io/nuid [MIT](https://github.com/nats-io/nuid/blob/master/LICENSE)
- github.com/nsqio/go-nsq [MIT](https://github.com/nsqio/go-nsq/blob/master/LICENSE)
- github.com/opentracing-contrib/go-observer [APACHE](https://github.com/opentracing-contrib/go-observer/blob/master/LICENSE)
- github.com/opentracing/opentracing-go [MIT](https://github.com/opentracing/opentracing-go/blob/master/LICENSE)
- github.com/openzipkin/zipkin-go-opentracing [MIT](https://github.com/openzipkin/zipkin-go-opentracing/blob/master/LICENSE)
- github.com/pierrec/lz4 [BSD](https://github.com/pierrec/lz4/blob/master/LICENSE)
- github.com/pierrec/xxHash [BSD](https://github.com/pierrec/xxHash/blob/master/LICENSE)
- github.com/pkg/errors [BSD](https://github.com/pkg/errors/blob/master/LICENSE)
Expand Down
1 change: 1 addition & 0 deletions plugins/inputs/all/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,6 @@ import (
_ "github.com/influxdata/telegraf/plugins/inputs/webhooks"
_ "github.com/influxdata/telegraf/plugins/inputs/win_perf_counters"
_ "github.com/influxdata/telegraf/plugins/inputs/zfs"
_ "github.com/influxdata/telegraf/plugins/inputs/zipkin"
_ "github.com/influxdata/telegraf/plugins/inputs/zookeeper"
)
164 changes: 164 additions & 0 deletions plugins/inputs/zipkin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
# Zipkin Plugin

This plugin implements the Zipkin http server to gather trace and timing data needed to troubleshoot latency problems in microservice architectures.

*Please Note: This plugin is experimental; Its data schema may be subject to change
based on its main usage cases and the evolution of the OpenTracing standard.*

## Configuration:
```toml
[[inputs.zipkin]]
path = "/api/v1/spans" # URL path for span data
port = 9411 # Port on which Telegraf listens
```

## Tracing:

This plugin uses Annotations tags and fields to track data from spans

- __TRACE:__ is a set of spans that share a single root span.
Traces are built by collecting all Spans that share a traceId.

- __SPAN:__ is a set of Annotations and BinaryAnnotations that correspond to a particular RPC.

- __Annotations:__ for each annotation & binary annotation of a span a metric is output. *Records an occurrence in time at the beginning and end of a request.*

Annotations may have the following values:

- __CS (client start):__ beginning of span, request is made.
- __SR (server receive):__ server receives request and will start processing it
network latency & clock jitters differ it from cs
- __SS (server send):__ server is done processing and sends request back to client
amount of time it took to process request will differ it from sr
- __CR (client receive):__ end of span, client receives response from server
RPC is considered complete with this annotation

### Tags
* __"id":__ The 64 bit ID of the span.
* __"parent_id":__ An ID associated with a particular child span. If there is no child span, the parent ID is set to ID.
* __"trace_id":__ The 64 or 128-bit ID of a particular trace. Every span in a trace shares this ID. Concatenation of high and low and converted to hexadecimal.
* __"name":__ Defines a span

##### Annotations have these additional tags:

* __"service_name":__ Defines a service
* __"annotation":__ The value of an annotation
* __"endpoint_host":__ Listening port concat with IPV4, if port is not present it will not be concatenated

##### Binary Annotations have these additional tag:

* __"service_name":__ Defines a service
* __"annotation":__ The value of an annotation
* __"endpoint_host":__ Listening port concat with IPV4, if port is not present it will not be concatenated
* __"annotation_key":__ label describing the annotation


### Fields:
* __"duration_ns":__ The time in nanoseconds between the end and beginning of a span.



### Sample Queries:

__Get All Span Names for Service__ `my_web_server`
```sql
SHOW TAG VALUES FROM "zipkin" with key="name" WHERE "service_name" = 'my_web_server'
```
- __Description:__ returns a list containing the names of the spans which have annotations with the given `service_name` of `my_web_server`.

__Get All Service Names__
```sql
SHOW TAG VALUES FROM "zipkin" WITH KEY = "service_name"
```
- __Description:__ returns a list of all `distinct` endpoint service names.

__Find spans with longest duration__
```sql
SELECT max("duration_ns") FROM "zipkin" WHERE "service_name" = 'my_service' AND "name" = 'my_span_name' AND time > now() - 20m GROUP BY "trace_id",time(30s) LIMIT 5
```
- __Description:__ In the last 20 minutes find the top 5 longest span durations for service `my_server` and span name `my_span_name`


### Recommended InfluxDB setup

This test will create high cardinality data so we reccomend using the [tsi influxDB engine](https://www.influxdata.com/path-1-billion-time-series-influxdb-high-cardinality-indexing-ready-testing/).
#### How To Set Up InfluxDB For Work With Zipkin

##### Steps
1. ___Update___ InfluxDB to >= 1.3, in order to use the new tsi engine.

2. ___Generate___ a config file with the following command:
```sh
influxd config > /path/for/config/file
```
3. ___Add___ the following to your config file, under the `[data]` tab:
```toml
[data]
index-version = "tsi1"
```

4. ___Start___ `influxd` with your new config file:
```sh
influxd -config=/path/to/your/config/file
```

5. ___Update___ your retention policy:
```sql
ALTER RETENTION POLICY "autogen" ON "telegraf" DURATION 1d SHARD DURATION 30m
```

### Example Input Trace:

- [Cli microservice with two services Test](https://github.com/openzipkin/zipkin-go-opentracing/tree/master/examples/cli_with_2_services)
- [Test data from distributed trace repo sample json](https://github.com/mattkanwisher/distributedtrace/blob/master/testclient/sample.json)
#### [Trace Example from Zipkin model](http://zipkin.io/pages/data_model.html)
```json
{
"traceId": "bd7a977555f6b982",
"name": "query",
"id": "be2d01e33cc78d97",
"parentId": "ebf33e1a81dc6f71",
"timestamp": 1458702548786000,
"duration": 13000,
"annotations": [
{
"endpoint": {
"serviceName": "zipkin-query",
"ipv4": "192.168.1.2",
"port": 9411
},
"timestamp": 1458702548786000,
"value": "cs"
},
{
"endpoint": {
"serviceName": "zipkin-query",
"ipv4": "192.168.1.2",
"port": 9411
},
"timestamp": 1458702548799000,
"value": "cr"
}
],
"binaryAnnotations": [
{
"key": "jdbc.query",
"value": "select distinct `zipkin_spans`.`trace_id` from `zipkin_spans` join `zipkin_annotations` on (`zipkin_spans`.`trace_id` = `zipkin_annotations`.`trace_id` and `zipkin_spans`.`id` = `zipkin_annotations`.`span_id`) where (`zipkin_annotations`.`endpoint_service_name` = ? and `zipkin_spans`.`start_ts` between ? and ?) order by `zipkin_spans`.`start_ts` desc limit ?",
"endpoint": {
"serviceName": "zipkin-query",
"ipv4": "192.168.1.2",
"port": 9411
}
},
{
"key": "sa",
"value": true,
"endpoint": {
"serviceName": "spanstore-jdbc",
"ipv4": "127.0.0.1",
"port": 3306
}
}
]
}
```
75 changes: 75 additions & 0 deletions plugins/inputs/zipkin/cmd/stress_test_write/stress_test_write.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
This is a development testing cli tool meant to stress the zipkin telegraf plugin.
It writes a specified number of zipkin spans to the plugin endpoint, with other
parameters which dictate batch size and flush timeout.

Usage as follows:

`./stress_test_write -batch_size=<batch_size> -max_backlog=<max_span_buffer_backlog> -batch_interval=<batch_interval_in_seconds> -span_count<number_of_spans_to_write> -zipkin_host=<zipkin_service_hostname>`

Or with a timer:

`time ./stress_test_write -batch_size=<batch_size> -max_backlog=<max_span_buffer_backlog> -batch_interval=<batch_interval_in_seconds> -span_count<number_of_spans_to_write> -zipkin_host=<zipkin_service_hostname>`

However, the flag defaults work just fine for a good write stress test (and are what
this tool has mainly been tested with), so there shouldn't be much need to
manually tweak the parameters.
*/

package main
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment what this does and how to use it


import (
"flag"
"fmt"
"log"
"time"

zipkin "github.com/openzipkin/zipkin-go-opentracing"
)

var (
BatchSize int
MaxBackLog int
BatchTimeInterval int
SpanCount int
ZipkinServerHost string
)

const usage = `./stress_test_write -batch_size=<batch_size> -max_backlog=<max_span_buffer_backlog> -batch_interval=<batch_interval_in_seconds> -span_count<number_of_spans_to_write> -zipkin_host=<zipkin_service_hostname>`

func init() {
flag.IntVar(&BatchSize, "batch_size", 10000, usage)
flag.IntVar(&MaxBackLog, "max_backlog", 100000, usage)
flag.IntVar(&BatchTimeInterval, "batch_interval", 1, usage)
flag.IntVar(&SpanCount, "span_count", 100000, usage)
flag.StringVar(&ZipkinServerHost, "zipkin_host", "localhost", usage)
}

func main() {
flag.Parse()
var hostname = fmt.Sprintf("http://%s:9411/api/v1/spans", ZipkinServerHost)
collector, err := zipkin.NewHTTPCollector(
hostname,
zipkin.HTTPBatchSize(BatchSize),
zipkin.HTTPMaxBacklog(MaxBackLog),
zipkin.HTTPBatchInterval(time.Duration(BatchTimeInterval)*time.Second))
defer collector.Close()
if err != nil {
log.Fatalf("Error intializing zipkin http collector: %v\n", err)
}

tracer, err := zipkin.NewTracer(
zipkin.NewRecorder(collector, false, "127.0.0.1:0", "trivial"))

if err != nil {
log.Fatalf("Error: %v\n", err)
}

log.Printf("Writing %d spans to zipkin server at %s\n", SpanCount, hostname)
for i := 0; i < SpanCount; i++ {
parent := tracer.StartSpan("Parent")
parent.LogEvent(fmt.Sprintf("Trace%d", i))
parent.Finish()
}
log.Println("Done. Flushing remaining spans...")
}
Loading