From 5dce055108ca96929f3ff7e1d244869617adea0a Mon Sep 17 00:00:00 2001 From: k1LoW Date: Thu, 26 Oct 2023 19:07:45 +0900 Subject: [PATCH] Update about tracing --- README.md | 40 ++++++++++++++++++++++++++++++++++++++++ option.go | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 308d5da1..85bd6744 100644 --- a/README.md +++ b/README.md @@ -440,6 +440,16 @@ Force all steps to run. force: true ``` +### `trace:` + +Add tokens for tracing to headers and queries by default. + +Currently, HTTP runner, gRPC runner and DB runner are supported. + +``` yaml +trace: true +``` + ### `loop:` Loop setting for runbook. @@ -656,6 +666,7 @@ steps: application/json: # Content-Type specification. In this case, it is "Content-Type: application/json" username: alice password: passw0rd + trace: false # add `X-Runn-Trace` header to HTTP request for tracing test: | # test for current step current.res.status == 201 ``` @@ -752,6 +763,15 @@ runners: # skipVerify: false ``` +#### Add `X-Runn-Trace` header to HTTP request for tracing + +``` yaml +runners: + myapi: + endpoint: https://api.github.com + trace: true +``` + ### gRPC Runner: Do gRPC request Use `grpc://` scheme to specify gRPC Runner. @@ -772,6 +792,7 @@ steps: name: alice num: 3 request_time: 2022-06-25T05:24:43.861872Z + trace: false # add `x-runn-trace` header to gRPC request for tracing - desc: Request using Server streaming RPC greq: @@ -877,6 +898,15 @@ are recorded with the following structure. num: 32 # current.res.messages[0].num ``` +#### Add `x-runn-trace` header to gRPC request for tracing + +``` yaml +runners: + greq: + addr: grpc.example.com:8080 + trace: true +``` + ### DB Runner: Query a database Use dsn (Data Source Name) to specify DB Runner. @@ -891,6 +921,7 @@ steps: desc: Select users # description of step db: # key to identify the runner. In this case, it is DB Runner. query: SELECT * FROM users; # query to execute + trace: false # add comment with trace token to query for tracing ``` See [testdata/book/db.yml](testdata/book/db.yml). @@ -924,6 +955,15 @@ otherwise it records `last_insert_id` and `rows_affected` . rows_affected: 1 # current.rows_affected ``` +#### Add comment with trace token to query for tracing + +``` yaml +runners: + db: + dsn: mysql://dbuser:dbpass@hostname:3306/dbname + trace: true +`` + #### Support Databases **PostgreSQL:** diff --git a/option.go b/option.go index b0ac7335..ee47c305 100644 --- a/option.go +++ b/option.go @@ -655,7 +655,7 @@ func Force(enable bool) Option { } } -// Trace - Trace all steps by default. +// Trace - Add tokens for tracing to headers and queries by default. func Trace(enable bool) Option { return func(bk *book) error { if !bk.trace {