MeshTrace

This policy uses new policy matching algorithm. Do not combine with TrafficTrace.

This policy enables publishing traces to a third party tracing solution.

Tracing is supported over HTTP, HTTP2, and gRPC protocols. You must explicitly specify the protocol for each service and data plane proxy you want to enable tracing for.

Kuma currently supports the following trace exposition formats:

Services still need to be instrumented to preserve the trace chain across requests made across different services.

You can instrument with a language library of your choice (for Zipkin and for Datadog). For HTTP you can also manually forward the following headers:

  • x-request-id
  • x-b3-traceid
  • x-b3-parentspanid
  • x-b3-spanid
  • x-b3-sampled
  • x-b3-flags

TargetRef support matrix

targetRefAllowed kinds
targetRef.kindMesh, MeshSubset
targetRefAllowed kinds
targetRef.kindMesh, MeshGateway
targetRefAllowed kinds
targetRef.kindMesh, MeshSubset

To learn more about the information in this table, see the matching docs.

Configuration

Sampling

Most of the time setting only overall is sufficient. random and client are for advanced use cases.

You can configure sampling settings equivalent to Envoy’s:

The value is always a percentage and is between 0 and 100.

Example:

  1. sampling:
  2. overall: 80
  3. random: 60
  4. client: 40

Tags

You can add tags to trace metadata by directly supplying the value (literal) or by taking it from a header (header).

Example:

  1. tags:
  2. - name: team
  3. literal: core
  4. - name: env
  5. header:
  6. name: x-env
  7. default: prod
  8. - name: version
  9. header:
  10. name: x-version

If a value is missing for header, default is used. If default isn’t provided, then the tag won’t be added.

Backends

Datadog

You can configure a Datadog backend with a url and splitService.

Example:

  1. datadog:
  2. url: http://my-agent:8080 # Required. The url to reach a running datadog agent
  3. splitService: true # Default to false. If true, it will split inbound and outbound requests in different services in Datadog

The splitService property determines if Datadog service names should be split based on traffic direction and destination. For example, with splitService: true and a backend service that communicates with a couple of databases, you would get service names like backend_INBOUND, backend_OUTBOUND_db1, and backend_OUTBOUND_db2 in Datadog.

Zipkin

In most cases the only field you’ll want to set in url.

Example:

  1. zipkin:
  2. url: http://jaeger-collector:9411/api/v2/spans # Required. The url to a zipkin collector to send traces to
  3. traceId128bit: false # Default to false which will expose a 64bits traceId. If true, the id of the trace is 128bits
  4. apiVersion: httpJson # Default to httpJson. It can be httpJson, httpProto and is the version of the zipkin API
  5. sharedSpanContext: false # Default to true. If true, the inbound and outbound traffic will share the same span.

OpenTelemetry

The only field you can set is endpoint.

Example:

  1. openTelemetry:
  2. endpoint: otel-collector:4317 # Required. Address of OpenTelemetry collector

Examples

Zipkin

Simple example:

  1. apiVersion: kuma.io/v1alpha1
  2. kind: MeshTrace
  3. metadata:
  4. name: default
  5. namespace: kuma-system
  6. labels:
  7. kuma.io/mesh: default
  8. spec:
  9. default:
  10. backends:
  11. - type: Zipkin
  12. zipkin:
  13. url: http://jaeger-collector:9411/api/v2/spans
  1. type: MeshTrace
  2. name: default
  3. mesh: default
  4. spec:
  5. default:
  6. backends:
  7. - type: Zipkin
  8. zipkin:
  9. url: http://jaeger-collector:9411/api/v2/spans

Full example:

  1. apiVersion: kuma.io/v1alpha1
  2. kind: MeshTrace
  3. metadata:
  4. name: default
  5. namespace: kuma-system
  6. labels:
  7. kuma.io/mesh: default
  8. spec:
  9. default:
  10. tags:
  11. - name: team
  12. literal: core
  13. - name: env
  14. header:
  15. name: x-env
  16. default: prod
  17. - name: version
  18. header:
  19. name: x-version
  20. sampling:
  21. overall: 80
  22. random: 60
  23. client: 40
  24. backends:
  25. - type: Zipkin
  26. zipkin:
  27. url: http://jaeger-collector:9411/api/v2/spans
  28. apiVersion: httpJson
  1. type: MeshTrace
  2. name: default
  3. mesh: default
  4. spec:
  5. default:
  6. tags:
  7. - name: team
  8. literal: core
  9. - name: env
  10. header:
  11. name: x-env
  12. default: prod
  13. - name: version
  14. header:
  15. name: x-version
  16. sampling:
  17. overall: 80
  18. random: 60
  19. client: 40
  20. backends:
  21. - type: Zipkin
  22. zipkin:
  23. url: http://jaeger-collector:9411/api/v2/spans
  24. apiVersion: httpJson

Datadog

This assumes a Datadog agent is configured and running. If you haven’t already check the Datadog observability page.

Simple example:

  1. apiVersion: kuma.io/v1alpha1
  2. kind: MeshTrace
  3. metadata:
  4. name: default
  5. namespace: kuma-system
  6. labels:
  7. kuma.io/mesh: default
  8. spec:
  9. default:
  10. backends:
  11. - type: Datadog
  12. datadog:
  13. url: http://127.0.0.1:8126
  1. type: MeshTrace
  2. name: default
  3. mesh: default
  4. spec:
  5. default:
  6. backends:
  7. - type: Datadog
  8. datadog:
  9. url: http://127.0.0.1:8126

Full example:

  1. apiVersion: kuma.io/v1alpha1
  2. kind: MeshTrace
  3. metadata:
  4. name: default
  5. namespace: kuma-system
  6. labels:
  7. kuma.io/mesh: default
  8. spec:
  9. default:
  10. tags:
  11. - name: team
  12. literal: core
  13. - name: env
  14. header:
  15. name: x-env
  16. default: prod
  17. - name: version
  18. header:
  19. name: x-version
  20. sampling:
  21. overall: 80
  22. random: 60
  23. client: 40
  24. backends:
  25. - type: Datadog
  26. datadog:
  27. url: http://127.0.0.1:8126
  28. splitService: true
  1. type: MeshTrace
  2. name: default
  3. mesh: default
  4. spec:
  5. default:
  6. tags:
  7. - name: team
  8. literal: core
  9. - name: env
  10. header:
  11. name: x-env
  12. default: prod
  13. - name: version
  14. header:
  15. name: x-version
  16. sampling:
  17. overall: 80
  18. random: 60
  19. client: 40
  20. backends:
  21. - type: Datadog
  22. datadog:
  23. url: http://127.0.0.1:8126
  24. splitService: true

OpenTelemetry

This assumes a OpenTelemetry collector is configured and running. If you haven’t already check the OpenTelementry operator.

Simple example:

  1. apiVersion: kuma.io/v1alpha1
  2. kind: MeshTrace
  3. metadata:
  4. name: default
  5. namespace: kuma-system
  6. labels:
  7. kuma.io/mesh: default
  8. spec:
  9. default:
  10. backends:
  11. - type: OpenTelemetry
  12. openTelemetry:
  13. endpoint: otel-collector.com:4317
  1. type: MeshTrace
  2. name: default
  3. mesh: default
  4. spec:
  5. default:
  6. backends:
  7. - type: OpenTelemetry
  8. openTelemetry:
  9. endpoint: otel-collector.com:4317

Full example:

  1. apiVersion: kuma.io/v1alpha1
  2. kind: MeshTrace
  3. metadata:
  4. name: default
  5. namespace: kuma-system
  6. labels:
  7. kuma.io/mesh: default
  8. spec:
  9. default:
  10. tags:
  11. - name: team
  12. literal: core
  13. - name: env
  14. header:
  15. name: x-env
  16. default: prod
  17. - name: version
  18. header:
  19. name: x-version
  20. sampling:
  21. overall: 80
  22. random: 60
  23. client: 40
  24. backends:
  25. - type: OpenTelemetry
  26. openTelemetry:
  27. endpoint: otel-collector.com:4317
  1. type: MeshTrace
  2. name: default
  3. mesh: default
  4. spec:
  5. default:
  6. tags:
  7. - name: team
  8. literal: core
  9. - name: env
  10. header:
  11. name: x-env
  12. default: prod
  13. - name: version
  14. header:
  15. name: x-version
  16. sampling:
  17. overall: 80
  18. random: 60
  19. client: 40
  20. backends:
  21. - type: OpenTelemetry
  22. openTelemetry:
  23. endpoint: otel-collector.com:4317

Targeting parts of the infrastructure

While usually you want all the traces to be sent to the same tracing backend, you can target parts of a Mesh by using a finer-grained targetRef and a designated backend to trace different paths of our service traffic. This is especially useful when you want traces to never leave a world region, or a cloud, for example.

In this example, we have two zones east and west, each of these with their own Zipkin collector: east.zipkincollector:9411/api/v2/spans and west.zipkincollector:9411/api/v2/spans. We want data plane proxies in each zone to only send traces to their local collector.

To do this, we use a TargetRef kind value of MeshSubset to filter which data plane proxy a policy applies to.

West only policy:

  1. apiVersion: kuma.io/v1alpha1
  2. kind: MeshTrace
  3. metadata:
  4. name: trace-west
  5. namespace: kuma-system
  6. labels:
  7. kuma.io/mesh: default
  8. spec:
  9. targetRef:
  10. kind: MeshSubset
  11. tags:
  12. kuma.io/zone: west
  13. default:
  14. backends:
  15. - type: Zipkin
  16. zipkin:
  17. url: http://west.zipkincollector:9411/api/v2/spans
  1. type: MeshTrace
  2. name: trace-west
  3. mesh: default
  4. spec:
  5. targetRef:
  6. kind: MeshSubset
  7. tags:
  8. kuma.io/zone: west
  9. default:
  10. backends:
  11. - type: Zipkin
  12. zipkin:
  13. url: http://west.zipkincollector:9411/api/v2/spans

East only policy:

  1. apiVersion: kuma.io/v1alpha1
  2. kind: MeshTrace
  3. metadata:
  4. name: trace-east
  5. namespace: kuma-system
  6. labels:
  7. kuma.io/mesh: default
  8. spec:
  9. targetRef:
  10. kind: MeshSubset
  11. tags:
  12. kuma.io/zone: east
  13. default:
  14. backends:
  15. - zipkin:
  16. url: http://east.zipkincollector:9411/api/v2/spans
  1. type: MeshTrace
  2. name: trace-east
  3. mesh: default
  4. spec:
  5. targetRef:
  6. kind: MeshSubset
  7. tags:
  8. kuma.io/zone: east
  9. default:
  10. backends:
  11. - zipkin:
  12. url: http://east.zipkincollector:9411/api/v2/spans

All policy options