diff --git a/README.md b/README.md index 09574cd5e..da4b97513 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Trickster is a fully-featured HTTP Reverse Proxy Cache for HTTP applications lik * [Negative Caching](./docs/negative-caching.md) to prevent domino effect outages * High-performance [Collapsed Forwarding](./docs/collapsed-forwarding.md) * Best-in-class [Byte Range Request caching and acceleration](./docs/range_request.md). -* [Distributed Tracing](./docs/tracing.md) via OpenTelemetry, supporting Jaeger and Zipkin +* [Distributed Tracing](./docs/tracing.md) via OpenTelemetry, supporting OTLP and Zipkin * Rules engine for custom request routing and rewriting ## Time Series Database Accelerator diff --git a/deploy/kube/configmap.yaml b/deploy/kube/configmap.yaml index 7ba3f6983..715368e65 100644 --- a/deploy/kube/configmap.yaml +++ b/deploy/kube/configmap.yaml @@ -505,24 +505,31 @@ data: # default: # # provider specifies the type of backend tracing system where traces are sent (in that format) - # # options are: jaeger, zipkin, stdout or none. none is the default + # # options are: otlp, zipkin, stdout or none. none is the default # provider: none # # service_name specifies the service name under which the traces are registered by this tracer # # default is trickster # service_name: trickster - # # collector_url is the URL of the tracing backend - # # required for zipkin and jaeger, unused for stdout - # collector_url: http://jaeger:14268/api/traces + # # endpoint is the URL, URI or Path to the tracing backend + # # required for Zipkin and OTLP, unused for stdout + # endpoint: http://jaeger:14268/api/traces - # # collector_user is the username credential for authenticating with the tracing backend - # # optional jaeger; unused for zipkin and stdout - # collector_user: '' + # # timeout_ms is the amount of time in milliseconds for the tracing post + # # to wait for a response before timing out + # # default is no timeout set + # timeout_ms: 5000 - # # collector_pass is the username credential for authenticating with the tracing backend - # # optional jaeger; unused for zipkin and stdout - # collector_pass: '' + # # headers is a list of http headers to include in the tracing post + # # default is none + # headers: + # "Header-Name-1": "header value 1" + # "Header-Name-2": "header value 2" + + # # disable_compression should be set to true if tracing posts should not be compressed + # # default is false + # disable_compression: false # # sample_rate sets the probability that a span will be recorded. # # A floating point value of 0.0 to 1.0 (inclusive) is permitted @@ -556,7 +563,7 @@ data: # # another example tracing config named example using jaeger agent backend and a 50% sample rate # example: # provider: jaeger - # collector_url: jaeger:6831 + # endpoint: jaeger:6831 # sample_rate: 0.5 # jaeger: # endpoint_type: agent @@ -564,7 +571,7 @@ data: # # another example tracing config named zipkin-example using zipkin backend and a 10% sample rate # zipkin-example: # provider: zipkin - # collector_url: https://zipkin.example.com:9411/api/v2/spans + # endpoint: https://zipkin.example.com:9411/api/v2/spans # sample_rate: 0.1 diff --git a/docs/chunked_caching.md b/docs/chunked_caching.md index 80475cb96..fa4f898d9 100644 --- a/docs/chunked_caching.md +++ b/docs/chunked_caching.md @@ -103,18 +103,16 @@ rules: tracing: jc1: - tracer_type: jaeger - collector_url: 'http://127.0.0.1:14268/api/traces' + tracer_type: otlp + endpoint: 'http://127.0.0.1:14268/api/traces' tags: testTag: testTagValue testTag2: testTag2Value ja1: - tracer_type: jaeger - collector_url: '127.0.0.1:6831' + tracer_type: otlp + endpoint: '127.0.0.1:6831' omit_tags: - http.url - jaeger: - endpoint_type: agent backends: prom1: diff --git a/docs/developer/tracing.md b/docs/developer/tracing.md deleted file mode 100644 index 253b43feb..000000000 --- a/docs/developer/tracing.md +++ /dev/null @@ -1,103 +0,0 @@ -# Tracing support - -Trickster has minimal support for OpenTelemetry. See - -## Config -TODO - -## Developer Testing - -### Manual with Jaeger - -1. Start jaeger - -``` -docker run -d --name jaeger \ () - -e COLLECTOR_ZIPKIN_HTTP_PORT=9411 \ - -p 5775:5775/udp \ - -p 6831:6831/udp \ - -p 6832:6832/udp \ - -p 5778:5778 \ - -p 16686:16686 \ - -p 14268:14268 \ - -p 9411:9411 \ - jaegertracing/all-in-one:1. -``` - -2. Star Promsim - -From the Trickster root run - -``` -go run cmd/promsim/main.go -``` - -3. Start Trickster with tracing test config - -From the Trickster root run -``` -make build -o trickster && ./bin/trickster -config testdata/test.tracing.conf --log-level debug -``` - -4. Query - -``` -curl -i 'localhost:8080/test/api/v1/query_range?query=my_test_query{random_label="57",series_count="1"}&start=2&end=4&step=1' -``` - -5. Visit Jaeger UI at http://localhost:16686/search - -### Testing Utilities - -`tracing.Recorder` is a trace exporter for capturing exported trace spans for inspection later. - -`tracing.TestHTTPClient` is an http client with a mock `http.RoundTripper` that calls a test handler for faking http calls. - -`SetupTestingTracer` uses the above type to setup a mock tracer whose spans can be validated. - -Usage together (from `recorder_test.go`: -```go -flush, ctx, recorder, tr := SetupTestingTracer(t, RecorderTracer, 1.0, TestContextValues) - -err := tr.WithSpan(ctx, "Testing trace with span", - func(ctx context.Context) error { - var ( - err error - ) - req, _ := http.NewRequest("GET", "https://example.com/test", nil) - - ctx, req = httptrace.W3C(ctx, req) - httptrace.Inject(ctx, req) - _, err = TestHTTPClient().Do(req) - if err != nil { - return err - } - - SpanFromContext(ctx).SetStatus(codes.OK) - - return nil - - }) - -assert.NoError(t, err, "failed to inject span") -flush() -m := make(map[string]string) -for _, kv := range TestEvents { - m[string(kv.Key)] = kv.Value.Emit() - -} - -for _, span := range recorder.spans { - for _, msg := range span.MessageEvents { - for _, attr := range msg.Attributes { - key := string(attr.Key) - wantV, ok := m[key] - assert.True(t, ok, "kv not in known good map") - v := attr.Value.Emit() - assert.Equal(t, wantV, v, "Span Message attribute value incorrect") - - } - } - -} -``` diff --git a/docs/tracing.md b/docs/tracing.md index a298ec710..f0765f898 100644 --- a/docs/tracing.md +++ b/docs/tracing.md @@ -1,13 +1,12 @@ # Distributed Tracing via OpenTelemetry -Trickster instruments Distributed Tracing with [OpenTelemetry](http://opentelemetry.io/), which is a currently emergent, comprehensive observability stack that is in Public Beta. We import the [OpenTelemetry golang packages](https://github.com/open-telemetry/opentelemetry-go) to instrument support for tracing. +Trickster instruments Distributed Tracing with [OpenTelemetry](http://opentelemetry.io/). We import the [OpenTelemetry golang packages](https://github.com/open-telemetry/opentelemetry-go) to instrument support for tracing. As OpenTelemetry evolves to support additional exporter formats, we will work to extend Trickster to support those as quickly as possible. We also make a best effort to update our otel package imports to the latest releases, whenever we publish a new Trickster release. You can check the [go.mod](../go.mod) file to see which release of opentelemetry-go we are is using. In this view, to see which version of otel a specific Trickster release imports, use the branch selector dropdown to switch to the tag corresponding to that version of Trickster. ## Supported Tracing Backends -- Jaeger -- Jaeger Agent +- Jaeger (via OTLP) - Zipkin - Console/Stdout (printed locally by the Trickster process) diff --git a/examples/conf/example.full.yaml b/examples/conf/example.full.yaml index b41411ef7..24c8beb2e 100644 --- a/examples/conf/example.full.yaml +++ b/examples/conf/example.full.yaml @@ -601,24 +601,31 @@ backends: # default: # # provider specifies the type of backend tracing system where traces are sent (in that format) -# # options are: jaeger, zipkin, stdout or none. none is the default +# # options are: otlp, zipkin, stdout or none. none is the default # provider: none # # service_name specifies the service name under which the traces are registered by this tracer # # default is trickster # service_name: trickster -# # collector_url is the URL of the tracing backend -# # required for zipkin and jaeger, unused for stdout -# collector_url: http://jaeger:14268/api/traces +# # endpoint is the URL, URI or Path to the tracing backend +# # required for Zipkin and OTLP, unused for stdout +# endpoint: http://jaeger:14268/api/traces -# # collector_user is the username credential for authenticating with the tracing backend -# # optional jaeger; unused for zipkin and stdout -# collector_user: '' +# # timeout_ms is the amount of time in milliseconds for the tracing post +# # to wait for a response before timing out +# # default is no timeout set +# timeout_ms: 5000 -# # collector_pass is the username credential for authenticating with the tracing backend -# # optional jaeger; unused for zipkin and stdout -# collector_pass: '' +# # headers is a list of http headers to include in the tracing post +# # default is none +# headers: +# "Header-Name-1": "header value 1" +# "Header-Name-2": "header value 2" + +# # disable_compression should be set to true if tracing posts should not be compressed +# # default is false +# disable_compression: false # # sample_rate sets the probability that a span will be recorded. # # A floating point value of 0.0 to 1.0 (inclusive) is permitted @@ -637,30 +644,22 @@ backends: # key1: "value1" # key2: "value2" -# # configurations for this tracer, specific to jaeger -# jaeger: -# # endpoint_type indicates whether the jaeger tracing backend is a collector or agent -# # default is collector -# endpoint_type: collector - # # configurations for this tracer, specific to stdout # stdout: # # pretty_print indicates whether the output to stdout is formatted better human readability # # default is false # pretty_print: false -# # another example tracing config named example using jaeger agent backend and a 50% sample rate +# # another example tracing config named example using otlp agent backend and a 50% sample rate # example: -# provider: jaeger -# collector_url: jaeger:6831 +# provider: otlp +# endpoint: jaeger:6831 # sample_rate: 0.5 -# jaeger: -# endpoint_type: agent # # another example tracing config named zipkin-example using zipkin backend and a 10% sample rate # zipkin-example: # provider: zipkin -# collector_url: https://zipkin.example.com:9411/api/v2/spans +# endpoint: https://zipkin.example.com:9411/api/v2/spans # sample_rate: 0.1 diff --git a/examples/docker-compose/docker-compose-data/trickster-config/trickster.yaml b/examples/docker-compose/docker-compose-data/trickster-config/trickster.yaml index 6081b4b7e..4416e55b9 100644 --- a/examples/docker-compose/docker-compose-data/trickster-config/trickster.yaml +++ b/examples/docker-compose/docker-compose-data/trickster-config/trickster.yaml @@ -32,15 +32,13 @@ tracing: pretty_print: true zip1: provider: zipkin - collector_url: 'http://zipkin:9411/api/v2/spans' + endpoint: 'http://zipkin:9411/api/v2/spans' jc1: - provider: jaeger # jaeger collector - collector_url: 'http://jaeger:14268/api/traces' + provider: otlp # jaeger collector + endpoint: 'http://jaeger:14268/api/traces' ja1: - provider: jaeger # jaeger agent - collector_url: 'jaeger:6831' - jaeger: - endpoint_type: agent + provider: otlp # jaeger agent + endpoint: 'jaeger:6831' backends: prom1: # prometheus cached with a memory cache, traces sent to stdout provider: prometheus diff --git a/testdata/test.tracing-recorder.conf b/testdata/test.tracing-recorder.conf deleted file mode 100644 index f5175c6d1..000000000 --- a/testdata/test.tracing-recorder.conf +++ /dev/null @@ -1,38 +0,0 @@ -# -# Copyright 2018 The Trickster Authors -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# ### this file is for unit tests only and will not work in a live setting - -frontend: - listen_port: 8080 - listen_address: localhost -caches: - test: - index: {} - redis: {} - filesystem: {} - bbolt: {} - badger: {} -backends: - test: - provider: prometheus - origin_url: 'http://localhost:9090' - timeseries_eviction_method: lru - tracing_name: test -metrics: {} -tracing: - test: - implementation: jaeger - exporter: recorder - sample_rate: 1 -logging: {} diff --git a/testdata/test.tracing.conf b/testdata/test.tracing.conf deleted file mode 100644 index f8b321276..000000000 --- a/testdata/test.tracing.conf +++ /dev/null @@ -1,44 +0,0 @@ -# -# Copyright 2018 The Trickster Authors -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# ### this file is for unit tests only and will not work in a live setting - -frontend: - listen_port: 8080 - listen_address: localhost -caches: - test: - index: {} - redis: {} - filesystem: {} - bbolt: {} - badger: {} -backends: - test: - tracing_name: test - provider: prometheus - origin_url: 'http://localhost:9090' - timeseries_eviction_method: lru -metrics: {} -tracing: - test: - implementation: opentelemetry -exporter: - - type: jaeger - collector: 'http://localhost:14268/api/traces' - sample_rate: 1 - - type: jaeger - agent: 'localhost:14268/api/traces' - sample_rate: 1 -logging: {} -