Customize Function traces

This tutorial shows how to use the build-in OpenTelemetry tracer object to send custom trace data to the trace backend.

Kyma Functions are instrumented to handle trace headers. This means that every time you call your Function, the executed logic is traceable using a dedicated span visible in the trace backend (i.e. start time and duration). Additionally, you can extend the default trace context and create your own custom spans whenever you feel it is helpful (i.e. when calling a remote service in your distributed application) or add additional information to the tracing context by introducing events and tags. This tutorial shows you how to do it using tracer client that is available as part of the event object.


Before you start, make sure you have these tools installed:

  • Kyma installed on a cluster
  • Trace backend configured to collect traces from the cluster. You can bring your own trace backend or deploy Jaeger.


The following code samples illustrate how to enrich the default trace with custom spans, events, and tags:

  1. Create an inline Function with the following body:

    • Node.js
    • Python
  2. Expose your Function.

  3. Find the traces for the Function in the trace backend.