Skip to content

Commit 00e0af9

Browse files
authored
docs: add settings documentation to otel.py and generate documentation. Fixes #751 (#817)
* docs: add settings documentation to otel.py and dynamic env variables and generate documentation
1 parent 3fd9052 commit 00e0af9

4 files changed

Lines changed: 86 additions & 4 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,4 @@ repos:
9999
entry: pixi run -e default python scripts/generate_settings_docs.py
100100
language: system
101101
pass_filenames: false
102-
files: ^(diracx-.*/src/diracx/.*/settings\.py|docs/.*\.j2|docs/templates/.*\.jinja|scripts/generate_settings_docs\.py)$
102+
files: ^(diracx-.*/src/diracx/.*/settings\.py|diracx-routers/src/diracx/routers/otel\.py|docs/.*\.j2|docs/templates/.*\.jinja|scripts/generate_settings_docs\.py)$

diracx-routers/src/diracx/routers/otel.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,34 @@
3535
class OTELSettings(ServiceSettingsBase):
3636
"""Settings for the Open Telemetry Configuration."""
3737

38-
model_config = SettingsConfigDict(env_prefix="DIRACX_OTEL_")
38+
model_config = SettingsConfigDict(
39+
env_prefix="DIRACX_OTEL_", use_attribute_docstrings=True
40+
)
3941

4042
enabled: bool = False
43+
"""
44+
Determines whether OpenTelemetry is enabled.
45+
"""
46+
4147
application_name: str = "diracx"
48+
"""
49+
The name of the application for OpenTelemetry.
50+
"""
51+
4252
grpc_endpoint: str = ""
53+
"""
54+
The gRPC endpoint for the OpenTelemetry collector.
55+
"""
56+
4357
grpc_insecure: bool = True
44-
# headers to pass to the OTEL Collector
45-
# e.g. {"tenant_id": "lhcbdiracx-cert"}
58+
"""
59+
Whether to use an insecure gRPC connection for the OpenTelemetry collector.
60+
"""
61+
4662
headers: Optional[dict[str, str]] = None
63+
"""
64+
A JSON-encoded dictionary of headers to pass to the OpenTelemetry collector, e.g. {"tenant_id": "lhcbdiracx-cert"}.
65+
"""
4766

4867

4968
def instrument_otel(app: FastAPI) -> None:

docs/admin/reference/env-variables.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22

33
*This page is auto-generated from the settings classes in `diracx.core.settings`.*
44

5+
## Core
6+
7+
### `DIRACX_CONFIG_BACKEND_URL`
8+
9+
The URL of the configuration backend.
10+
11+
### `DIRACX_SERVICE_DOTENV`
12+
13+
The variable points to .env files where configuration may be placed. There could be more than one file, with suffixes
14+
\_X, where X is a number. The files will be loaded in order.
15+
16+
### `DIRACX_SERVICE_JOBS_ENABLED`
17+
18+
Determines whether the jobs service is enabled.
19+
520
## AuthSettings
621

722
Settings for the authentication service.
@@ -123,6 +138,10 @@ Set of security properties available in this DIRAC installation.
123138
These properties define various authorization capabilities and are used
124139
for access control decisions. Defaults to all available security properties.
125140

141+
### `DIRACX_LEGACY_EXCHANGE_HASHED_API_KEY`
142+
143+
The hashed API key for the legacy exchange endpoint.
144+
126145
## SandboxStoreSettings
127146

128147
Settings for the sandbox store.
@@ -199,6 +218,16 @@ Maximum number of concurrent DB delete chunks during cleaning.
199218

200219
Controls parallelism of database DELETE operations.
201220

221+
## Databases
222+
223+
### `DIRACX_DB_URL_<db_name>`
224+
225+
The URL for the SQL database `<db_name>`.
226+
227+
### `DIRACX_OS_DB_<db_name>`
228+
229+
A JSON-encoded dictionary of connection keyword arguments for the OpenSearch database `<db_name>`.
230+
202231
## OTELSettings
203232

204233
Settings for the Open Telemetry Configuration.
@@ -207,18 +236,28 @@ Settings for the Open Telemetry Configuration.
207236

208237
*Optional*, default value: `False`
209238

239+
Determines whether OpenTelemetry is enabled.
240+
210241
### `DIRACX_OTEL_APPLICATION_NAME`
211242

212243
*Optional*, default value: `diracx`
213244

245+
The name of the application for OpenTelemetry.
246+
214247
### `DIRACX_OTEL_GRPC_ENDPOINT`
215248

216249
*Optional*, default value: \`\`
217250

251+
The gRPC endpoint for the OpenTelemetry collector.
252+
218253
### `DIRACX_OTEL_GRPC_INSECURE`
219254

220255
*Optional*, default value: `True`
221256

257+
Whether to use an insecure gRPC connection for the OpenTelemetry collector.
258+
222259
### `DIRACX_OTEL_HEADERS`
223260

224261
*Optional*, default value: `None`
262+
263+
A JSON-encoded dictionary of headers to pass to the OpenTelemetry collector, e.g. {"tenant_id": "lhcbdiracx-cert"}.

docs/admin/reference/env-variables.md.j2

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,33 @@
33
# List of environment variables
44

55
*This page is auto-generated from the settings classes in `diracx.core.settings`.*
6+
## Core
7+
8+
### `DIRACX_CONFIG_BACKEND_URL`
9+
The URL of the configuration backend.
10+
11+
### `DIRACX_SERVICE_DOTENV`
12+
The variable points to .env files where configuration may be placed. There could be more than one file, with suffixes
13+
_X, where X is a number. The files will be loaded in order.
14+
15+
### `DIRACX_SERVICE_JOBS_ENABLED`
16+
Determines whether the jobs service is enabled.
617

718
{{ render_class('AuthSettings') }}
819

20+
### `DIRACX_LEGACY_EXCHANGE_HASHED_API_KEY`
21+
The hashed API key for the legacy exchange endpoint.
22+
923
{{ render_class('SandboxStoreSettings') }}
1024

25+
## Databases
26+
27+
### `DIRACX_DB_URL_<db_name>`
28+
29+
The URL for the SQL database `<db_name>`.
30+
31+
### `DIRACX_OS_DB_<db_name>`
32+
33+
A JSON-encoded dictionary of connection keyword arguments for the OpenSearch database `<db_name>`.
34+
1135
{{ render_class('OTELSettings') }}

0 commit comments

Comments
 (0)