Skip to content

Commit 66e27f2

Browse files
martyniaaldbr
authored andcommitted
docs: add settings documentation to otel.py and dynamic env variables and generate documentation
1 parent b556dbc commit 66e27f2

5 files changed

Lines changed: 96 additions & 5 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: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
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+
516
## AuthSettings
617

718
Settings for the authentication service.
@@ -199,6 +210,29 @@ Maximum number of concurrent DB delete chunks during cleaning.
199210

200211
Controls parallelism of database DELETE operations.
201212

213+
### `DIRACX_LEGACY_EXCHANGE_HASHED_API_KEY`
214+
215+
The hashed API key for the legacy exchange endpoint.
216+
217+
### `DIRACX_SERVICE_DOTENV`
218+
219+
The variable points to .env files where configuration may be placed. There could be more than one file, with suffixes
220+
\_X, where X is a number. The files will be loaded in order.
221+
222+
### `DIRACX_SERVICE_JOBS_ENABLED`
223+
224+
Determines whether the jobs service is enabled.
225+
226+
## Databases
227+
228+
### `DIRACX_DB_URL_<db_name>`
229+
230+
The URL for the SQL database `<db_name>`.
231+
232+
### `DIRACX_OS_DB_<db_name>`
233+
234+
A JSON-encoded dictionary of connection keyword arguments for the OpenSearch database `<db_name>`.
235+
202236
## OTELSettings
203237

204238
Settings for the Open Telemetry Configuration.
@@ -207,18 +241,28 @@ Settings for the Open Telemetry Configuration.
207241

208242
*Optional*, default value: `False`
209243

244+
Determines whether OpenTelemetry is enabled.
245+
210246
### `DIRACX_OTEL_APPLICATION_NAME`
211247

212248
*Optional*, default value: `diracx`
213249

250+
The name of the application for OpenTelemetry.
251+
214252
### `DIRACX_OTEL_GRPC_ENDPOINT`
215253

216254
*Optional*, default value: \`\`
217255

256+
The gRPC endpoint for the OpenTelemetry collector.
257+
218258
### `DIRACX_OTEL_GRPC_INSECURE`
219259

220260
*Optional*, default value: `True`
221261

262+
Whether to use an insecure gRPC connection for the OpenTelemetry collector.
263+
222264
### `DIRACX_OTEL_HEADERS`
223265

224266
*Optional*, default value: `None`
267+
268+
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: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,37 @@
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.
614

715
{{ render_class('AuthSettings') }}
816

917
{{ render_class('SandboxStoreSettings') }}
1018

19+
### `DIRACX_LEGACY_EXCHANGE_HASHED_API_KEY`
20+
The hashed API key for the legacy exchange endpoint.
21+
22+
### `DIRACX_SERVICE_DOTENV`
23+
The variable points to .env files where configuration may be placed. There could be more than one file, with suffixes
24+
_X, where X is a number. The files will be loaded in order.
25+
26+
### `DIRACX_SERVICE_JOBS_ENABLED`
27+
Determines whether the jobs service is enabled.
28+
29+
## Databases
30+
31+
### `DIRACX_DB_URL_<db_name>`
32+
33+
The URL for the SQL database `<db_name>`.
34+
35+
### `DIRACX_OS_DB_<db_name>`
36+
37+
A JSON-encoded dictionary of connection keyword arguments for the OpenSearch database `<db_name>`.
38+
1139
{{ render_class('OTELSettings') }}

pixi.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[workspace]
22
channels = ["conda-forge"]
3-
platforms = ["linux-64", "osx-arm64"]
3+
platforms = ["linux-64", "osx-arm64", "osx-64"]
44

55
[dependencies]
66
python = ">=3.11.3,<3.12"

0 commit comments

Comments
 (0)