<@U04UQ68083H> I am trying to configure tracing fo...
# ory-copilot
s
@chilly-king-10285 I am trying to configure tracing for kratos. the documentaion is a big confusing. I am using signoz as my collector backend, is it possible to use standard open telemetry for kratos or is only jaeger supported?
b
A message from kapa.ai
You can use OpenTelemetry with Kratos, though the documentation does mention some limitations. Let me clarify the tracing options for you. While the Kratos documentation specifically mentions Jaeger as a supported tracing backend, Ory as a whole supports OpenTelemetry. According to the self-hosted operations documentation, Ory supports several tracing backends including OpenTelemetry, which would work with SignOz as your collector. The documentation states: > Ory supports the following tracing backends: > - OpenTelemetry > - Jaeger > - Elastic APM > - Datadog > - Zipkin > - Instana [Self-hosted Operations: Distributed tracing](https://www.ory.sh/docs/self-hosted/operations/tracing#tracing-options) For configuring OpenTelemetry with Kratos, you would need to set the following environment variables:
Copy code
TRACING_SERVICE_NAME="kratos" TRACING_PROVIDER="otel" TRACING_PROVIDERS_OTLP_INSECURE=true TRACING_PROVIDERS_OTLP_SAMPLING_SAMPLING_RATIO=0.4 TRACING_PROVIDERS_OTLP_SERVER_URL="your.signoz.collector:4318" OTEL_RESOURCE_ATTRIBUTES="service.name=kratos,deployment.environment=your-env,service.version=your-version"
This is similar to the configuration shown in a GitHub issue for Hydra, but would apply to Kratos as well [GitHub Issue: Opentelemetry spans names have changed when changed tracing_provider](https://github.com/ory/hydra/issues/3622). Note that there is a known issue with Kratos where the
persistence.sql.NextMessages
job registers as an error in OpenTelemetry tracing, as mentioned in [GitHub Issue:
persistence.sql.NextMessages
registers as Error in otel-tracing](https://github.com/ory/kratos/issues/4013). For a local setup to test tracing, you can use the provided docker-compose file in the Kratos repository:
Copy code
docker-compose -f quickstart.yml \     -f quickstart-tracing.yml \     up --build
[Kratos Guides: Distributed tracing](https://www.ory.sh/docs/kratos/guides/tracing)
s
@chilly-king-10285 how would that configuration look like in yaml?
b
A message from kapa.ai
Based on the environment variables I shared earlier, here's how the tracing configuration would look in YAML format for Kratos:
Copy code
yaml tracing:   service_name: "kratos"   provider: "otel"   providers:     otlp:       insecure: true       sampling:         sampling_ratio: 0.4       server_url: "your.signoz.collector:4318"
You can add this to your Kratos configuration file. The
OTEL_RESOURCE_ATTRIBUTES
environment variable doesn't have a direct equivalent in the YAML configuration, so you might still need to set that separately as an environment variable. Remember that you can load this configuration file using the
-c
or
--config
flag when starting Kratos:
Copy code
kratos --config path/to/config.yaml
The configuration file can be in JSON, YAML, or TOML format as mentioned in the [Kratos Configuration documentation](https://www.ory.sh/docs/kratos/configuring). If you need to make changes to the configuration without restarting the server, some configuration values support reloading on the fly, though the documentation doesn't specifically mention if tracing configuration is among those.