<!--
title: Configure OpenTelemetry programmatically
domain: orchestration
topic: Observability
language: Yaml
source: temporalio/temporal
updated: 2025-06-24
url: https://awesomereviewers.com/reviewers/temporal-configure-opentelemetry-programmatically/
-->

{% raw %}
Configure OpenTelemetry programmatically rather than through environment variables or command-line flags. This creates a more maintainable and standardized approach to observability. Additionally, ensure all observability components like collectors are explicitly included in your deployment configurations.

Example:
```yaml
# Preferred - Adding collector to Docker Compose services
services: "${{ format('{0}\notel-collector', join(matrix.containers, '\n')) }}"

# Avoid passing as environment variables
# make OTEL=true functional-test-coverage  # Not recommended
```

This approach ensures consistent observability setup across environments and makes configuration changes more traceable through source control.
{% endraw %}
