github.com/projectcontour/contour@v1.28.2/site/content/docs/1.27/config/tracing.md (about) 1 # Tracing Support 2 3 - [Overview](#overview) 4 - [Tracing-config](#tracing-config) 5 6 ## Overview 7 8 Envoy has rich support for [distributed tracing][1],and supports exporting data to third-party providers (Zipkin, Jaeger, Datadog, etc.) 9 10 [OpenTelemetry][2] is a CNCF project which is working to become a standard in the space. It was formed as a merger of the OpenTracing and OpenCensus projects. 11 12 Contour supports configuring envoy to export data to OpenTelemetry, and allows users to customize some configurations. 13 14 - Custom service name, the default is `contour`. 15 - Custom sampling rate, the default is `100`. 16 - Custom the maximum length of the request path, the default is `256`. 17 - Customize span tags from literal or request headers. 18 - Customize whether to include the pod's hostname and namespace. 19 20 ## Tracing-config 21 22 In order to use this feature, you must first select and deploy an opentelemetry-collector to receive the tracing data exported by envoy. 23 24 First we should deploy an opentelemetry-collector to receive the tracing data exported by envoy 25 ```bash 26 # install operator 27 kubectl apply -f https://github.com/open-telemetry/opentelemetry-operator/releases/latest/download/opentelemetry-operator.yaml 28 ``` 29 30 Install an otel collector instance, with verbose logging exporter enabled: 31 ```shell 32 kubectl apply -f - <<EOF 33 apiVersion: opentelemetry.io/v1alpha1 34 kind: OpenTelemetryCollector 35 metadata: 36 name: simplest 37 namespace: projectcontour 38 spec: 39 config: | 40 receivers: 41 otlp: 42 protocols: 43 grpc: 44 http: 45 exporters: 46 logging: 47 verbosity: detailed 48 49 service: 50 pipelines: 51 traces: 52 receivers: [otlp] 53 exporters: [logging] 54 EOF 55 ``` 56 57 Define extension service: 58 ```shell 59 kubectl apply -f - <<EOF 60 apiVersion: projectcontour.io/v1alpha1 61 kind: ExtensionService 62 metadata: 63 name: otel-collector 64 namespace: projectcontour 65 spec: 66 protocol: h2c 67 services: 68 - name: simplest-collector 69 port: 4317 70 EOF 71 ``` 72 73 Update Contour config (needs a Contour deployment restart afterwards): 74 ```shell 75 kubectl apply -f - <<EOF 76 apiVersion: v1 77 kind: ConfigMap 78 metadata: 79 name: contour 80 namespace: projectcontour 81 data: 82 contour.yaml: | 83 tracing: 84 # Whether to send the namespace and instance where envoy is located to open, the default is true. 85 includePodDetail: true 86 # The extensionService and namespace and name defined above in the format of namespace/name. 87 extensionService: projectcontour/otel-collector 88 # The service name that envoy sends to openTelemetry-collector, the default is contour. 89 serviceName: some-service-name 90 # A custom set of tags. 91 customTags: 92 # envoy will send the tagName to the collector. 93 - tagName: custom-tag 94 # fixed tag value. 95 literal: foo 96 - tagName: header-tag 97 # The tag value obtained from the request header, 98 # if the request header does not exist, this tag will not be sent. 99 requestHeaderName: X-Custom-Header 100 EOF 101 ``` 102 103 Install httpbin and test it: 104 ```bash 105 kubectl apply -f https://projectcontour.io/examples/httpbin.yaml 106 ``` 107 108 Access the api and view the logs of simplest: 109 ```bash 110 kubectl logs deploy/simplest-collector -n projectcontour 111 ``` 112 113 Now you should be able to see traces in the logs of the otel collector. 114 115 [1]: https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/observability/tracing 116 [2]: https://opentelemetry.io/ 117