|
1 | 1 | from functools import cached_property |
2 | 2 | from typing import Annotated |
3 | 3 |
|
| 4 | +from common_library.basic_types import DEFAULT_FACTORY |
4 | 5 | from models_library.basic_types import BootModeEnum, LogLevel |
5 | 6 | from pydantic import AliasChoices, Field, TypeAdapter, field_validator |
6 | 7 | from pydantic.networks import AnyUrl |
@@ -34,32 +35,39 @@ class ApplicationSettings(BaseApplicationSettings, MixinLoggingSettings): |
34 | 35 | ), |
35 | 36 | ] = LogLevel.INFO |
36 | 37 |
|
37 | | - PENNSIEVE: PennsieveSettings = Field( |
38 | | - json_schema_extra={"auto_default_from_env": True} |
39 | | - ) |
| 38 | + PENNSIEVE: Annotated[ |
| 39 | + PennsieveSettings, Field(json_schema_extra={"auto_default_from_env": True}) |
| 40 | + ] |
40 | 41 |
|
41 | | - DATCORE_ADAPTER_LOG_FORMAT_LOCAL_DEV_ENABLED: bool = Field( |
42 | | - default=False, |
43 | | - validation_alias=AliasChoices( |
44 | | - "DATCORE_ADAPTER_LOG_FORMAT_LOCAL_DEV_ENABLED", |
45 | | - "LOG_FORMAT_LOCAL_DEV_ENABLED", |
| 42 | + DATCORE_ADAPTER_LOG_FORMAT_LOCAL_DEV_ENABLED: Annotated[ |
| 43 | + bool, |
| 44 | + Field( |
| 45 | + validation_alias=AliasChoices( |
| 46 | + "DATCORE_ADAPTER_LOG_FORMAT_LOCAL_DEV_ENABLED", |
| 47 | + "LOG_FORMAT_LOCAL_DEV_ENABLED", |
| 48 | + ), |
| 49 | + description="Enables local development log format. WARNING: make sure it is disabled if you want to have structured logs!", |
46 | 50 | ), |
47 | | - description="Enables local development log format. WARNING: make sure it is disabled if you want to have structured logs!", |
48 | | - ) |
49 | | - DATCORE_ADAPTER_LOG_FILTER_MAPPING: dict[ |
50 | | - LoggerName, list[MessageSubstring] |
51 | | - ] = Field( |
52 | | - default_factory=dict, |
53 | | - validation_alias=AliasChoices( |
54 | | - "DATCORE_ADAPTER_LOG_FILTER_MAPPING", "LOG_FILTER_MAPPING" |
| 51 | + ] = False |
| 52 | + DATCORE_ADAPTER_LOG_FILTER_MAPPING: Annotated[ |
| 53 | + dict[LoggerName, list[MessageSubstring]], |
| 54 | + Field( |
| 55 | + default_factory=dict, |
| 56 | + validation_alias=AliasChoices( |
| 57 | + "DATCORE_ADAPTER_LOG_FILTER_MAPPING", "LOG_FILTER_MAPPING" |
| 58 | + ), |
| 59 | + description="is a dictionary that maps specific loggers (such as 'uvicorn.access' or 'gunicorn.access') to a list of log message patterns that should be filtered out.", |
55 | 60 | ), |
56 | | - description="is a dictionary that maps specific loggers (such as 'uvicorn.access' or 'gunicorn.access') to a list of log message patterns that should be filtered out.", |
57 | | - ) |
| 61 | + ] = DEFAULT_FACTORY |
| 62 | + |
58 | 63 | DATCORE_ADAPTER_PROMETHEUS_INSTRUMENTATION_ENABLED: bool = True |
59 | | - DATCORE_ADAPTER_TRACING: TracingSettings | None = Field( |
60 | | - description="settings for opentelemetry tracing", |
61 | | - json_schema_extra={"auto_default_from_env": True}, |
62 | | - ) |
| 64 | + DATCORE_ADAPTER_TRACING: Annotated[ |
| 65 | + TracingSettings | None, |
| 66 | + Field( |
| 67 | + description="settings for opentelemetry tracing", |
| 68 | + json_schema_extra={"auto_default_from_env": True}, |
| 69 | + ), |
| 70 | + ] |
63 | 71 |
|
64 | 72 | @cached_property |
65 | 73 | def debug(self) -> bool: |
|
0 commit comments