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
{{ message }}
Repository navigation
Commit 6cb8322
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/introduction/configuration.md
+26-2Lines changed: 26 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -99,9 +99,10 @@ Additional parameters for FastAPI integration:
99
99
100
100
## Opentelemetry
101
101
102
-
To bootstrap Opentelemetry, you must provide at least:
102
+
To bootstrap Opentelemetry, you must provide at least one of:
103
103
104
-
-`opentelemetry_endpoint`.
104
+
-`opentelemetry_endpoint`, for traces.
105
+
-`opentelemetry_metrics_endpoint`, for metrics.
105
106
106
107
Additional parameters:
107
108
@@ -116,6 +117,29 @@ Additional parameters:
116
117
-`opentelemetry_sampler` - an `opentelemetry.sdk.trace.sampling.Sampler` deciding which traces are recorded. Unset, the SDK's own default applies: `parentbased_always_on`, which records every trace that is not the child of a non-recording remote parent, unless `OTEL_TRACES_SAMPLER` / `OTEL_TRACES_SAMPLER_ARG` say otherwise.
117
118
-`opentelemetry_generate_health_check_spans` - generate spans for health check handlers if `True`.
118
119
-`opentelemetry_excluded_urls` - extra URLs excluded from tracing; the metrics path and (unless health-check spans are enabled) the health-check path are excluded automatically.
120
+
-`opentelemetry_metrics_endpoint` - will be passed to `OTLPMetricExporter` as endpoint, and turns on the metrics signal. Its own field rather than a flag on `opentelemetry_endpoint`, so upgrading never starts exporting metrics you did not ask for. Under `opentelemetry_exporter_protocol="http"` this is a full URL (e.g. `http://collector:4318/v1/metrics`); `opentelemetry_exporter_protocol` and `opentelemetry_insecure` are shared with traces.
121
+
122
+
### Metrics
123
+
124
+
Left unset, no `MeterProvider` is installed and the metrics signal stays off. Set it, and the
125
+
FastAPI, Litestar and FastStream instrumentations start recording their duration histograms
126
+
against it; until then they build those instruments against a no-op provider and the data goes
127
+
nowhere.
128
+
129
+
The export interval is the SDK's, 60 seconds, overridable with `OTEL_METRIC_EXPORT_INTERVAL`.
130
+
131
+
If the Prometheus instrument is also configured, request metrics are recorded twice: once for the
132
+
scrape endpoint and once for the OTLP pipeline, under different names. That is supported, and it
133
+
is what you want when the two feed different backends, but pointing both at one backend
134
+
double-counts.
135
+
136
+
```python
137
+
config = FastAPIConfig(
138
+
service_name="my-service",
139
+
opentelemetry_endpoint="localhost:4317",
140
+
opentelemetry_metrics_endpoint="localhost:4317",
141
+
)
142
+
```
119
143
120
144
Sampling is the cheapest way to cut what tracing costs: on a benchmark endpoint returning a constant,
121
145
`ParentBased(TraceIdRatioBased(0.01))` saved ~55 µs per request against the always-on default.
0 commit comments