> ## Documentation Index
> Fetch the complete documentation index at: https://docs.responsibleailabs.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenTelemetry

> Exporter les scores RAIL en tant que spans OpenTelemetry pour une observabilité complète.

## Installation

```bash theme={null}
pip install "rail-score-sdk[telemetry]"
```

## Configuration

```python theme={null}
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
from rail_score_sdk import RailScoreClient
from rail_score_sdk.telemetry import RAILTelemetry

# Configurer l'exportateur OTEL
provider = TracerProvider()
exporter = OTLPSpanExporter(endpoint="http://localhost:4317")
provider.add_span_processor(BatchSpanProcessor(exporter))
trace.set_tracer_provider(provider)

# Activer la télémétrie RAIL
rail = RailScoreClient(api_key="YOUR_RAIL_API_KEY")
RAILTelemetry.instrument(rail)

# Tous les appels eval() émettent maintenant des spans automatiquement
result = rail.eval(content="Votre texte ici", mode="basic")
```

## Attributs de span

Chaque appel `rail.eval()` émet un span avec ces attributs :

| Attribut                     | Type     | Description                       |
| ---------------------------- | -------- | --------------------------------- |
| `rail.score`                 | `float`  | Score RAIL global                 |
| `rail.confidence`            | `float`  | Confiance dans le score           |
| `rail.mode`                  | `string` | `basic` ou `deep`                 |
| `rail.credits_consumed`      | `float`  | Crédits consommés                 |
| `rail.from_cache`            | `bool`   | Si le résultat était mis en cache |
| `rail.dim.{name}.score`      | `float`  | Score par dimension               |
| `rail.dim.{name}.confidence` | `float`  | Confiance par dimension           |

## Visualisation des traces

Les spans RAIL s'intègrent à tout backend compatible OTEL : Jaeger, Tempo, Honeycomb, Datadog, New Relic ou Langfuse.

```bash theme={null}
# Démarrer une instance Jaeger locale pour le développement
docker run -p 16686:16686 -p 4317:4317 jaegertracing/all-in-one
```

Ouvrez `http://localhost:16686` pour voir les traces.
