-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Add Zipkin plugin #3080
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
ae65f10
Add concurrent zipkin http server to zipkin plugin for data fetching
83ff0e7
Add new skeleton for telegraf.ServiceInput to zipkin plugin
4d74b4d
Add simple test program for zipkin http server to zipkin plugin
bba8922
Add Godoc comments to zipkin_server.go in zipkin input plugin
89c471a
Update directory structure in zipkin plugin
72668e9
Rename zipkin_server.go to server.go
158e13c
Add TODO comments to server.go in zipkin plugin
f7acf33
Fix import path in main.go in zipkin plugin
8a858d9
Fix handler in server.go so that it returns correct http status in zi…
6ecefac
Add test for zipkin http server
898b3b6
Modify internal http server in zipkin plugin to use go 1.8 features f…
157b200
Update main.go to use new methods in zipkin server
b3dda37
Update server_test.go to call zipkin server constructor with the corr…
b6ebe5c
Add TODO comment to server.go in zipkin plugin
1147bcf
Update Godeps
53eaa02
Begin to add interfaces to zipkin plugin
76d4979
Update zipkin.go to include server and and interfaces/method implemen…
b8697b4
Add test for new unmarshalling features added to zipkin.go
bec51bf
Rename main struct in server.go to avoidpackage level naming conflict…
3882050
fix formatting directive in new_server_test.go in zipking plugin
1c799cc
Enable zipkin plugin in all.go
5a1d7ad
Delete outdated main.go file in zipkin plugin
9575625
Remove redeclared constant in server.go in zipkin plugin
4672463
Finish interface implementations in main zipkin plugin file
438e710
Rename test data directory
9239d64
Re-order method and type declaration in zipkin.go and add Godoc comments
e96bfba
Update data file path in new_server_test.go
f2adbe9
Add todo comments to zipkin.go in zipkin plugin
4ee9246
Disable server_test.go for current testing in zipkin plugin
4017863
Refactor zipkin server implementation into multiple files
7b60eef
Change http header status written on error condition in zipkin server…
9f4a837
Add initial telegraf conversion code to zipkin.go
a6ed636
Update zipkin plugin line protocol schema
c066ac1
Fix invalid struct fields in new_server_test.go for zipkin plugin
ca91421
Add zero check when working with traceid and remove excess comments i…
23b6798
Update new_server_test.go to account for changes to zipkin schema
e643d12
Add initial unit test for zipkin plugin
c876696
Add additional log statement to server_new.go
24ceba6
Change name of measurement for zipkin binary annotations
36198de
Add clarifying comments to zipkin server test, fix hardcoded path nam…
981b464
Add timestamp test for last metric in zipkin plugin unit test
7e828f6
Remove extraneous debug statement from new_server_test.go in zipkin p…
71d4b2f
Comment out debug statements in zipkin.go
bd08579
Add additional log statement to zipkin server test
e42c14b
Add unit test framework to zipkin plugin tests
7887367
Add separate file for unit test data to zipkin plugin
6003833
Remove new_server_test.go from zipkin plugin
581a8af
Add dependecy to server.go in zipkin plugin
38c85f6
Remove server_new.go
3e26625
Update server_test.go to contain new zipkin server unit test
64348cf
Add missing constant to zipkin.go
b6aa6fb
Add ability to wait for variable number of points to be written in zi…
1b417c4
Add additional unit test case to zipkin plugin, based on go openzipki…
92464a3
Remove debug file writing in zipkin server
5b2bfb7
Add scraped binary data file from openzipkin example cli app
75ee454
Add json representation of binary data from openzipkin cli app to vis…
7bab3df
Rename cli microservice data file
e51b1a0
Rename cli microservice json file
716b294
Add in loop to run all tests, add additional logs
2250eb7
Add additional debugging information to server logs in zipkin plugin
ec4d600
Add additional unit test data to zipkin plugin unit test from distrib…
ae105e8
Remove outdated comments from zipkin plugin
74db3ee
Change formatting in example data json file in zipkin plugin
e2d4463
Add additional binary unit test data with json representation to zipk…
e55bce3
Add go script to convert json to zipkin thrift protocol
970569c
Add json representation of testdata/threespans.dat to zipkin plugin
76fba59
Remove copy of first unit test for threespans.dat in zipkin plugin
ce09726
Add clarifying comments to unit test structs in zipkin plugin
4f3c91d
Remove unsued meta annotation struct
d82c8a3
Move thrift unmarshalling logic into separate function in zipkin plugin
150996d
Add go doc comments to zipkin.go
ee32c86
Remove unnecessary variable in zipkin.go, update sample config file
f4f5882
Update source code with go format
c6a8671
Rename zipkin server.go to handler.go
ac56b04
Refactor zipkin plugin
09a5628
WIP: Refactor tests in zipkin plugin
6ddf4d8
Add convert table test to zipkin plugin
070ec04
Fix timestamp units to microseconds for zipkin plugin
9d37894
Add more data for testing zipkin plugin
743a18d
Refactor formatting for zipkin plugin
e0d4c38
Fix bugs in test data for zipkin plugin
aa430af
Fix test logic bugs in zipkin plugin
c8e5494
Refactor zipkin plugin
6916c32
WIP: Create tests for zipkin plugin
72d0997
Temporarily comment out un-used test files in zipkin plugin
554df49
Update test to expect UTC times in zipkin plugin
017a682
add tests for minMax in zipkin plugin
ed792f9
Update zipkin tests to use UTC time
58d2352
Rename plugin test to zipkin test
d4e5e64
Combine unit_test.go to zipkin_test.go
f23b9bd
Add bitshift format to host in zipkin plugin
9265d80
Add full integration test for zipkin plugin
1754e13
Update test table in zipkin_test.go for new ipv4 string formatting
f30e787
Refactor ipv4 string conversion function in zipkin plugin to use stan…
64dfd37
Remove old comments from zipkin_test.go
0f48e48
Comment inaccurate test data in zipkin plugin
5780e5c
Add main file for stress writes to telegraf to zipkin plugin
a073a92
Add sample config for working with new tsi engine
b212910
Add draft of setup instructions for working with zipkin data in InfluxDB
57f1e2f
Update log message in stress writing script in zipkin plugin
2105698
Add currently broken write test benchmark
c5526f5
Update telegraf stress writing script in zipkin plugin
665e75f
Add debug log to zipkin http lander (temporary)
b1c1490
Make starting message more descriptive in zipkin.go
d31aef5
Add command line flags to cmd/stress_test_write.go in zipkin plugin
c6bbb7a
Move thrift_serialize to directory of Zipkin plugin
a65cf85
Move stress_test_write to directory of Zipkin plugin
8c40aa9
Update Godeps for Zipkin stress test
f6e6ee2
Fix vet errors for Zipkin plugin
3f29ecc
Add GZIP middleware to zipkin handler
f571b11
Add function for cors middleware to zipkin plugin
f21fd42
Change RP command in influx setup instructions in zipkin plugin
64fa992
Remove write_test.go in zipkin plugin
e25d498
Update thrift_serialize.go in zipkin plugin
5e9f1ab
Add informal notes about zipkin plugin performance
20e7290
Add README
e1056ed
Merge branch 'zipkin' of https://github.com/influxdata/telegraf into …
53e7a07
Add gzip and cors middleware to zipkin plugin
753fb6b
Remove annotation_timestamp from Zipkin plugin
f5c3a4a
Change duration to duration_ns
576685f
Change key to annotation_key
63caa1d
Change annotation_value to annotation
a708987
Remove type from binary annotations in zipkin plugin
df7c93b
Update README in zipkin plugin
60b4988
Add additional span with no annotation in zipkin plugin
6050cc1
Change trace ID high and low format to hexidecimal in zipkin plugin
52066d6
Update README definitions
7078fa4
Update README formatting for zipkin plugin
2314388
Update spans to have unique service names
6678586
Fix zipkins signed unsigned port number conflict
4b69301
Update zipkin description and sample configuration
6aa335c
Remove unnecessary files in zipkin plugin
db5d153
Change host so that port is not shown if zero
33654e0
Add a global span service name to zipkin span schema
9809815
Add a global span service name to zipkin span schema
ecf3712
Add a global span service name to zipkin span schema
c37a1b0
Update README in zipkin plugin
1050ff8
Merge branch 'zipkin' of https://github.com/influxdata/telegraf into …
0c33bbe
Update README in zipkin plugin
59634af
Update README in zipkin plugin
131e1c3
Add link to explain zipkin code
befbe7e
Add better description of trace example in README
01cfdbc
Refactor thrift_serialize.go into development tool
db8ac9a
Change testdata/json/distributed_trace_sample.json to array json format
08698d9
Move server initialization logic into start method of zipkin plugin; …
c33bb4d
Add test case for clean shutdown error to zipkin plugin
c03e54d
Change default hostname value when no endpoint is provided in zipkin …
7f991fd
Change default service name when no endpoint is provided
19ba03e
Add explanatory comment to cmd/stress_test_write/stress_test_write.go
17e2b6b
Remove unused struct from zipkin integration table test
b1ec4bd
Update LICENSE_OF_DEPENDENCIES.md for zipkin plugin
355c65e
Merge pull request #3085 from influxdata/zipkin-span-hostname-fix
goller 5ff0519
Merge pull request #3086 from influxdata/zipkin-default-hostname-fix
goller 4313cc2
Merge pull request #3084 from influxdata/zipkin-service-fixes
goller 4bdbc75
Merge pull request #3082 from influxdata/zipkin-thrift-cli-tool
goller eb0f8cc
Remove unused log statement and notes file
729fdbe
Merge branch 'zipkin' of https://github.com/influxdata/telegraf into …
079b8b7
Fix linter error in zipkin plugin
0c23e19
Update zipkin integration test so that a random port is chosen
d9e4057
Add experimental disclaimer to README.md
bbe13d8
Merge branch 'master' of github.com:influxdata/telegraf into zipkin
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
75
plugins/inputs/zipkin/cmd/stress_test_write/stress_test_write.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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...") | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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