You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Logfire** uses the OpenTelemetry standard. This means that you can configure the SDK to export to any backend that supports OpenTelemetry.
4
+
5
+
The easiest way is to set the `OTEL_EXPORTER_OTLP_ENDPOINT` environment variable to a URL that points to your backend.
6
+
This will be used as a base, and the SDK will append `/v1/traces` and `/v1/metrics` to the URL to send traces and metrics, respectively.
7
+
8
+
Alternatively, you can use the `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` and `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT` environment variables to specify the URLs for traces and metrics separately. These URLs should include the full path, including `/v1/traces` and `/v1/metrics`.
9
+
10
+
!!! note
11
+
The data will be encoded using **Protobuf** (not JSON) and sent over **HTTP** (not gRPC).
12
+
13
+
Make sure that your backend supports this! :nerd_face:
14
+
15
+
## Example with Jaeger
16
+
17
+
Run this minimal command to start a [Jaeger](https://www.jaegertracing.io/) container:
18
+
19
+
```
20
+
docker run --rm \
21
+
-p 16686:16686 \
22
+
-p 4318:4318 \
23
+
jaegertracing/all-in-one:latest
24
+
```
25
+
26
+
Then run this code:
27
+
28
+
```python
29
+
import os
30
+
31
+
import logfire
32
+
33
+
# Jaeger only supports traces, not metrics, so only set the traces endpoint
34
+
# to avoid errors about failing to export metrics.
# Setting a service name is good practice in general, but especially
41
+
# important for Jaeger, otherwise spans will be labeled as 'unknown_service'
42
+
service_name='my_logfire_service',
43
+
44
+
# Sending to Logfire is on by default regardless of the OTEL env vars.
45
+
# Keep this line here if you don't want to send to both Jaeger and Logfire.
46
+
send_to_logfire=False,
47
+
)
48
+
49
+
with logfire.span('This is a span'):
50
+
logfire.info('Logfire logs are also actually just spans!')
51
+
```
52
+
53
+
Finally open [http://localhost:16686/search?service=my_logfire_service](http://localhost:16686/search?service=my_logfire_service) to see the traces in the Jaeger UI.
54
+
55
+
## Other environment variables
56
+
57
+
If `OTEL_TRACES_EXPORTER` and/or `OTEL_METRICS_EXPORTER` are set to any non-empty value other than `otlp`, then **Logfire** will ignore the corresponding `OTEL_EXPORTER_OTLP_*` variables. This is because **Logfire** doesn't support other exporters, so we assume that the environment variables are intended to be used by something else. Normally you don't need to worry about this, and you don't need to set these variables at all unless you want to prevent **Logfire** from setting up these exporters.
58
+
59
+
See the [OpenTelemetry documentation](https://opentelemetry-python.readthedocs.io/en/latest/exporter/otlp/otlp.html) for information about the other headers you can set, such as `OTEL_EXPORTER_OTLP_HEADERS`.
0 commit comments