Log Stores
zenml.log_stores
Implements the log stores for ZenML.
Attributes
__all__ = ['ArtifactLogStore', 'BaseLogStore', 'BaseLogStoreConfig', 'BaseLogStoreFlavor', 'DatadogLogStore', 'DatadogLogStoreConfig', 'DatadogLogStoreFlavor', 'OtelLogStore', 'OtelLogStoreConfig', 'OtelLogStoreFlavor']
module-attribute
Classes
ArtifactLogStore(artifact_store: BaseArtifactStore, *args: Any, **kwargs: Any)
Bases: OtelLogStore
Log store that saves logs to the artifact store.
This implementation extends OtelLogStore and uses the ArtifactLogExporter to write logs to the artifact store. Inherits all OTEL infrastructure including shared BatchLogRecordProcessor and routing.
Initialize the artifact log store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
artifact_store
|
BaseArtifactStore
|
The artifact store to use for logging. |
required |
*args
|
Any
|
Positional arguments for the base class. |
()
|
**kwargs
|
Any
|
Keyword arguments for the base class. |
{}
|
Source code in src/zenml/log_stores/artifact/artifact_log_store.py
247 248 249 250 251 252 253 254 255 256 257 258 | |
Attributes
config: ArtifactLogStoreConfig
property
Returns the configuration of the artifact log store.
Returns:
| Type | Description |
|---|---|
ArtifactLogStoreConfig
|
The configuration. |
origin_class: Type[ArtifactLogStoreOrigin]
property
Class of the origin.
Returns:
| Type | Description |
|---|---|
Type[ArtifactLogStoreOrigin]
|
The class of the origin. |
Functions
cleanup() -> None
Cleanup the artifact log store.
This method is called to ensure that the artifact log store is cleaned up.
Source code in src/zenml/log_stores/artifact/artifact_log_store.py
381 382 383 384 385 386 | |
fetch(logs_model: LogsResponse, start_time: Optional[datetime] = None, end_time: Optional[datetime] = None, limit: int = MAX_ENTRIES_PER_REQUEST) -> List[LogEntry]
Fetch logs from the artifact store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logs_model
|
LogsResponse
|
The logs model containing uri and artifact_store_id. |
required |
start_time
|
Optional[datetime]
|
Filter logs after this time. |
None
|
end_time
|
Optional[datetime]
|
Filter logs before this time. |
None
|
limit
|
int
|
Maximum number of log entries to return. |
MAX_ENTRIES_PER_REQUEST
|
Returns:
| Type | Description |
|---|---|
List[LogEntry]
|
List of log entries from the artifact store. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If logs_model.uri is not provided. |
Source code in src/zenml/log_stores/artifact/artifact_log_store.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | |
from_artifact_store(artifact_store: BaseArtifactStore) -> ArtifactLogStore
classmethod
Creates an artifact log store from an artifact store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
artifact_store
|
BaseArtifactStore
|
The artifact store to create the log store from. |
required |
Returns:
| Type | Description |
|---|---|
ArtifactLogStore
|
The created artifact log store. |
Source code in src/zenml/log_stores/artifact/artifact_log_store.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
get_exporter() -> LogExporter
Get the artifact log exporter for this log store.
Returns:
| Type | Description |
|---|---|
LogExporter
|
The ArtifactLogExporter instance. |
Source code in src/zenml/log_stores/artifact/artifact_log_store.py
302 303 304 305 306 307 308 309 310 311 312 | |
BaseLogStore(*args: Any, **kwargs: Any)
Bases: StackComponent, ABC
Base class for all ZenML log stores.
A log store is responsible for collecting, storing, and retrieving logs during pipeline and step execution. Different implementations may store logs in different backends (artifact store, OpenTelemetry, Datadog, etc.).
Initialize the log store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any
|
Positional arguments for the base class. |
()
|
**kwargs
|
Any
|
Keyword arguments for the base class. |
{}
|
Source code in src/zenml/log_stores/base_log_store.py
79 80 81 82 83 84 85 86 87 88 | |
Attributes
config: BaseLogStoreConfig
property
Returns the configuration of the log store.
Returns:
| Type | Description |
|---|---|
BaseLogStoreConfig
|
The configuration. |
origin_class: Type[BaseLogStoreOrigin]
property
Class of the origin.
Returns:
| Type | Description |
|---|---|
Type[BaseLogStoreOrigin]
|
The class of the origin used with this log store. |
Functions
deregister_origin(origin: BaseLogStoreOrigin, blocking: bool = True) -> None
Deregister an origin previously registered with the log store.
If no other origins are left, the log store will be flushed. The
blocking parameter determines whether to block until the flush is
complete.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
origin
|
BaseLogStoreOrigin
|
The origin to deregister. |
required |
blocking
|
bool
|
Whether to block until the deregistration is complete and all logs are flushed if this is the last origin registered. |
True
|
Source code in src/zenml/log_stores/base_log_store.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
emit(origin: BaseLogStoreOrigin, record: logging.LogRecord, metadata: Optional[Dict[str, Any]] = None) -> None
abstractmethod
Process a log record from the logging system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
origin
|
BaseLogStoreOrigin
|
The origin used to send the log record. |
required |
record
|
LogRecord
|
The Python logging.LogRecord to process. |
required |
metadata
|
Optional[Dict[str, Any]]
|
Additional metadata to attach to the log entry. |
None
|
Source code in src/zenml/log_stores/base_log_store.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
fetch(logs_model: LogsResponse, start_time: Optional[datetime] = None, end_time: Optional[datetime] = None, limit: int = MAX_ENTRIES_PER_REQUEST) -> List[LogEntry]
abstractmethod
Fetch logs from the log store.
This method is called from the server to retrieve logs for display on the dashboard or via API. The implementation should not require any integration-specific SDKs that aren't available on the server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logs_model
|
LogsResponse
|
The logs model containing metadata about the logs. |
required |
start_time
|
Optional[datetime]
|
Filter logs after this time. |
None
|
end_time
|
Optional[datetime]
|
Filter logs before this time. |
None
|
limit
|
int
|
Maximum number of log entries to return. |
MAX_ENTRIES_PER_REQUEST
|
Returns:
| Type | Description |
|---|---|
List[LogEntry]
|
List of log entries matching the query. |
Source code in src/zenml/log_stores/base_log_store.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
flush(blocking: bool = True) -> None
abstractmethod
Flush the log store.
This method is called to ensure that all logs are flushed to the backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
blocking
|
bool
|
Whether to block until the flush is complete. |
True
|
Source code in src/zenml/log_stores/base_log_store.py
183 184 185 186 187 188 189 190 191 | |
register_origin(name: str, log_model: LogsResponse, metadata: Dict[str, Any]) -> BaseLogStoreOrigin
Register an origin for the log store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the origin. |
required |
log_model
|
LogsResponse
|
The log model associated with the origin. |
required |
metadata
|
Dict[str, Any]
|
Additional metadata to attach to the log entry. |
required |
Returns:
| Type | Description |
|---|---|
BaseLogStoreOrigin
|
The origin. |
Source code in src/zenml/log_stores/base_log_store.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
BaseLogStoreConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: StackComponentConfig
Base configuration for all log stores.
Source code in src/zenml/stack/stack_component.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
BaseLogStoreFlavor
Bases: Flavor
Base class for all ZenML log store flavors.
Attributes
config_class: Type[BaseLogStoreConfig]
property
Config class for the base log store flavor.
Returns:
| Type | Description |
|---|---|
Type[BaseLogStoreConfig]
|
The config class. |
implementation_class: Type[BaseLogStore]
abstractmethod
property
Implementation class for the base log store flavor.
Returns:
| Type | Description |
|---|---|
Type[BaseLogStore]
|
The implementation class. |
type: StackComponentType
property
DatadogLogStore(*args: Any, **kwargs: Any)
Bases: OtelLogStore
Log store that exports logs to Datadog.
This implementation extends OtelLogStore and configures it to send logs to Datadog's HTTP intake API.
Source code in src/zenml/log_stores/otel/otel_log_store.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
Attributes
config: DatadogLogStoreConfig
property
Returns the configuration of the Datadog log store.
Returns:
| Type | Description |
|---|---|
DatadogLogStoreConfig
|
The configuration. |
Functions
cleanup() -> None
Cleanup the Datadog log store.
This method is called when the log store is no longer needed.
Source code in src/zenml/log_stores/datadog/datadog_log_store.py
242 243 244 245 246 247 248 249 | |
fetch(logs_model: LogsResponse, start_time: Optional[datetime] = None, end_time: Optional[datetime] = None, limit: int = MAX_ENTRIES_PER_REQUEST) -> List[LogEntry]
Fetch logs from Datadog's API.
This method queries Datadog's Logs API to retrieve logs for the specified pipeline run and step. It automatically paginates through results to fetch up to the requested limit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logs_model
|
LogsResponse
|
The logs model containing run and step metadata. |
required |
start_time
|
Optional[datetime]
|
Filter logs after this time. |
None
|
end_time
|
Optional[datetime]
|
Filter logs before this time. |
None
|
limit
|
int
|
Maximum number of log entries to return. |
MAX_ENTRIES_PER_REQUEST
|
Returns:
| Type | Description |
|---|---|
List[LogEntry]
|
List of log entries from Datadog. |
Source code in src/zenml/log_stores/datadog/datadog_log_store.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
get_exporter() -> DatadogLogExporter
Get the Datadog log exporter.
Returns:
| Type | Description |
|---|---|
DatadogLogExporter
|
DatadogExporter with the proper configuration. |
Source code in src/zenml/log_stores/datadog/datadog_log_store.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
DatadogLogStoreConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: OtelLogStoreConfig
Configuration for Datadog log store.
Attributes:
| Name | Type | Description |
|---|---|---|
api_key |
PlainSerializedSecretStr
|
Datadog API key for log ingestion. |
application_key |
PlainSerializedSecretStr
|
Datadog application key for log extraction. |
site |
str
|
Datadog site (e.g., "datadoghq.com", "datadoghq.eu"). |
max_export_batch_size |
int
|
Maximum batch size for exports (Datadog limit: 1000). |
Source code in src/zenml/stack/stack_component.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
Functions
set_default_endpoint(data: Dict[str, Any]) -> Dict[str, Any]
classmethod
Set the endpoint based on site if not provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dict[str, Any]
|
The input data dictionary. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
The data dictionary with the endpoint set if not provided. |
Source code in src/zenml/log_stores/datadog/datadog_flavor.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
validate_max_export_batch_size(v: int) -> int
classmethod
Validate that max_export_batch_size doesn't exceed Datadog's limit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
int
|
The value to validate. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The validated value. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the value exceeds Datadog's limit. |
Source code in src/zenml/log_stores/datadog/datadog_flavor.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
DatadogLogStoreFlavor
Bases: Flavor
Datadog log store flavor.
Attributes
config_class: Type[BaseLogStoreConfig]
property
Returns DatadogLogStoreConfig config class.
Returns:
| Type | Description |
|---|---|
Type[BaseLogStoreConfig]
|
The config class. |
docs_url: str
property
URL to the flavor documentation.
Returns:
| Type | Description |
|---|---|
str
|
The URL to the flavor documentation. |
implementation_class: Type[BaseLogStore]
property
Implementation class for this flavor.
Returns:
| Type | Description |
|---|---|
Type[BaseLogStore]
|
The implementation class. |
logo_url: str
property
URL to the flavor logo.
Returns:
| Type | Description |
|---|---|
str
|
The URL to the flavor logo. |
name: str
property
Name of the flavor.
Returns:
| Type | Description |
|---|---|
str
|
The name of the flavor. |
sdk_docs_url: str
property
URL to the SDK docs for this flavor.
Returns:
| Type | Description |
|---|---|
str
|
The URL to the SDK docs for this flavor. |
type: StackComponentType
property
OtelLogStore(*args: Any, **kwargs: Any)
Bases: BaseLogStore
Log store that exports logs using OpenTelemetry.
Subclasses should implement get_exporter() to provide the specific
log exporter for their backend.
Initialize the OpenTelemetry log store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any
|
Positional arguments for the base class. |
()
|
**kwargs
|
Any
|
Keyword arguments for the base class. |
{}
|
Source code in src/zenml/log_stores/otel/otel_log_store.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
Attributes
config: OtelLogStoreConfig
property
Returns the configuration of the OTel log store.
Returns:
| Type | Description |
|---|---|
OtelLogStoreConfig
|
The configuration. |
origin_class: Type[OtelLogStoreOrigin]
property
provider: LoggerProvider
property
Returns the OpenTelemetry logger provider.
Returns:
| Type | Description |
|---|---|
LoggerProvider
|
The logger provider. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the OpenTelemetry log store is not initialized. |
Functions
deactivate() -> None
Deactivate log collection and shut down the processor.
Flushes any pending logs and shuts down the processor's background thread.
Source code in src/zenml/log_stores/otel/otel_log_store.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | |
emit(origin: BaseLogStoreOrigin, record: logging.LogRecord, metadata: Optional[Dict[str, Any]] = None) -> None
Process a log record by sending to OpenTelemetry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
origin
|
BaseLogStoreOrigin
|
The origin used to send the log record. |
required |
record
|
LogRecord
|
The log record to process. |
required |
metadata
|
Optional[Dict[str, Any]]
|
Additional metadata to attach to the log entry. |
None
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the OpenTelemetry provider is not initialized. |
Source code in src/zenml/log_stores/otel/otel_log_store.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | |
fetch(logs_model: LogsResponse, start_time: Optional[datetime] = None, end_time: Optional[datetime] = None, limit: int = MAX_ENTRIES_PER_REQUEST) -> List[LogEntry]
Fetch logs from the OpenTelemetry backend.
This method should be overridden by subclasses to implement backend-specific log retrieval. The base implementation returns an empty list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logs_model
|
LogsResponse
|
The logs model containing run and step metadata. |
required |
start_time
|
Optional[datetime]
|
Filter logs after this time. |
None
|
end_time
|
Optional[datetime]
|
Filter logs before this time. |
None
|
limit
|
int
|
Maximum number of log entries to return. |
MAX_ENTRIES_PER_REQUEST
|
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Log fetching is not supported by the OTEL log store. |
Source code in src/zenml/log_stores/otel/otel_log_store.py
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | |
flush(blocking: bool = True) -> None
Flush the log store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
blocking
|
bool
|
Whether to block until the flush is complete. |
True
|
This method is called to ensure that all logs are flushed to the backend.
Source code in src/zenml/log_stores/otel/otel_log_store.py
271 272 273 274 275 276 277 278 279 280 281 | |
get_exporter() -> LogExporter
Get the Datadog log exporter.
Returns:
| Type | Description |
|---|---|
LogExporter
|
OTLPLogExporter configured with API key and site. |
Source code in src/zenml/log_stores/otel/otel_log_store.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
register_origin(name: str, log_model: LogsResponse, metadata: Dict[str, Any]) -> BaseLogStoreOrigin
Register an origin for the log store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the origin. |
required |
log_model
|
LogsResponse
|
The log model associated with the origin. |
required |
metadata
|
Dict[str, Any]
|
Additional metadata to attach to the log entry. |
required |
Returns:
| Type | Description |
|---|---|
BaseLogStoreOrigin
|
The origin. |
Source code in src/zenml/log_stores/otel/otel_log_store.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
OtelLogStoreConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseLogStoreConfig
Configuration for OpenTelemetry log store.
Attributes:
| Name | Type | Description |
|---|---|---|
service_name |
str
|
Name of the service (defaults to "zenml"). |
service_version |
str
|
Version of the service (defaults to the ZenML version). |
max_queue_size |
int
|
Maximum queue size for batch processor. |
schedule_delay_millis |
int
|
Delay between batch exports in milliseconds. |
max_export_batch_size |
int
|
Maximum batch size for exports. |
endpoint |
str
|
The endpoint to export logs to. |
headers |
Optional[Dict[str, str]]
|
The headers to use for the export. |
certificate_file |
Optional[str]
|
The certificate file to use for the export. |
client_key_file |
Optional[str]
|
The client key file to use for the export. |
client_certificate_file |
Optional[str]
|
The client certificate file to use for the export. |
compression |
Compression
|
The compression to use for the export. |
Source code in src/zenml/stack/stack_component.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
OtelLogStoreFlavor
Bases: Flavor
OpenTelemetry log store flavor.
Attributes
config_class: Type[BaseLogStoreConfig]
property
Returns DatadogLogStoreConfig config class.
Returns:
| Type | Description |
|---|---|
Type[BaseLogStoreConfig]
|
The config class. |
docs_url: str
property
URL to the flavor documentation.
Returns:
| Type | Description |
|---|---|
str
|
The URL to the flavor documentation. |
implementation_class: Type[BaseLogStore]
property
Implementation class for this flavor.
Returns:
| Type | Description |
|---|---|
Type[BaseLogStore]
|
The implementation class. |
logo_url: str
property
URL to the flavor logo.
Returns:
| Type | Description |
|---|---|
str
|
The URL to the flavor logo. |
name: str
property
Name of the flavor.
Returns:
| Type | Description |
|---|---|
str
|
The name of the flavor. |
sdk_docs_url: str
property
URL to the SDK docs for this flavor.
Returns:
| Type | Description |
|---|---|
str
|
The URL to the SDK docs for this flavor. |
type: StackComponentType
property
Modules
artifact
Artifact log store implementation.
Modules
artifact_log_exporter
OpenTelemetry exporter that writes logs to ZenML artifact store.
ArtifactLogExporter(artifact_store: BaseArtifactStore)
Bases: LogExporter
OpenTelemetry exporter that writes logs to ZenML artifact store.
Initialize the exporter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
artifact_store
|
BaseArtifactStore
|
The artifact store to write logs to. |
required |
Source code in src/zenml/log_stores/artifact/artifact_log_exporter.py
47 48 49 50 51 52 53 | |
export(batch: Sequence[LogData]) -> LogExportResult
Export a batch of logs to the artifact store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
Sequence[LogData]
|
Sequence of LogData to export (can be from multiple contexts). |
required |
Returns:
| Type | Description |
|---|---|
LogExportResult
|
LogExportResult indicating success or failure. |
Source code in src/zenml/log_stores/artifact/artifact_log_exporter.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
shutdown() -> None
Shutdown the exporter.
Source code in src/zenml/log_stores/artifact/artifact_log_exporter.py
350 351 352 | |
artifact_log_store
Artifact log store implementation.
ArtifactLogStore(artifact_store: BaseArtifactStore, *args: Any, **kwargs: Any)
Bases: OtelLogStore
Log store that saves logs to the artifact store.
This implementation extends OtelLogStore and uses the ArtifactLogExporter to write logs to the artifact store. Inherits all OTEL infrastructure including shared BatchLogRecordProcessor and routing.
Initialize the artifact log store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
artifact_store
|
BaseArtifactStore
|
The artifact store to use for logging. |
required |
*args
|
Any
|
Positional arguments for the base class. |
()
|
**kwargs
|
Any
|
Keyword arguments for the base class. |
{}
|
Source code in src/zenml/log_stores/artifact/artifact_log_store.py
247 248 249 250 251 252 253 254 255 256 257 258 | |
config: ArtifactLogStoreConfig
property
Returns the configuration of the artifact log store.
Returns:
| Type | Description |
|---|---|
ArtifactLogStoreConfig
|
The configuration. |
origin_class: Type[ArtifactLogStoreOrigin]
property
Class of the origin.
Returns:
| Type | Description |
|---|---|
Type[ArtifactLogStoreOrigin]
|
The class of the origin. |
cleanup() -> None
Cleanup the artifact log store.
This method is called to ensure that the artifact log store is cleaned up.
Source code in src/zenml/log_stores/artifact/artifact_log_store.py
381 382 383 384 385 386 | |
fetch(logs_model: LogsResponse, start_time: Optional[datetime] = None, end_time: Optional[datetime] = None, limit: int = MAX_ENTRIES_PER_REQUEST) -> List[LogEntry]
Fetch logs from the artifact store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logs_model
|
LogsResponse
|
The logs model containing uri and artifact_store_id. |
required |
start_time
|
Optional[datetime]
|
Filter logs after this time. |
None
|
end_time
|
Optional[datetime]
|
Filter logs before this time. |
None
|
limit
|
int
|
Maximum number of log entries to return. |
MAX_ENTRIES_PER_REQUEST
|
Returns:
| Type | Description |
|---|---|
List[LogEntry]
|
List of log entries from the artifact store. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If logs_model.uri is not provided. |
Source code in src/zenml/log_stores/artifact/artifact_log_store.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | |
from_artifact_store(artifact_store: BaseArtifactStore) -> ArtifactLogStore
classmethod
Creates an artifact log store from an artifact store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
artifact_store
|
BaseArtifactStore
|
The artifact store to create the log store from. |
required |
Returns:
| Type | Description |
|---|---|
ArtifactLogStore
|
The created artifact log store. |
Source code in src/zenml/log_stores/artifact/artifact_log_store.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
get_exporter() -> LogExporter
Get the artifact log exporter for this log store.
Returns:
| Type | Description |
|---|---|
LogExporter
|
The ArtifactLogExporter instance. |
Source code in src/zenml/log_stores/artifact/artifact_log_store.py
302 303 304 305 306 307 308 309 310 311 312 | |
ArtifactLogStoreConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: OtelLogStoreConfig
Configuration for the artifact log store.
Source code in src/zenml/stack/stack_component.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
ArtifactLogStoreOrigin(name: str, log_store: BaseLogStore, log_model: LogsResponse, metadata: Dict[str, Any])
Bases: OtelLogStoreOrigin
Artifact log store origin.
Initialize a log store origin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the origin. |
required |
log_store
|
BaseLogStore
|
The log store to emit logs to. |
required |
log_model
|
LogsResponse
|
The log model associated with the origin. |
required |
metadata
|
Dict[str, Any]
|
Additional metadata to attach to all log entries that will be emitted by this origin. |
required |
Source code in src/zenml/log_stores/artifact/artifact_log_store.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |
fetch_log_records(artifact_store: BaseArtifactStore, logs_uri: str, limit: int = MAX_ENTRIES_PER_REQUEST) -> List[LogEntry]
Fetches log entries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
artifact_store
|
BaseArtifactStore
|
The artifact store. |
required |
logs_uri
|
str
|
The URI of the artifact (file or directory). |
required |
limit
|
int
|
Maximum number of log entries to return. |
MAX_ENTRIES_PER_REQUEST
|
Returns:
| Type | Description |
|---|---|
List[LogEntry]
|
List of log entries. |
Source code in src/zenml/log_stores/artifact/artifact_log_store.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
parse_log_entry(log_line: str) -> Optional[LogEntry]
Parse a single log entry into a LogEntry object.
Handles two formats: 1. JSON format: {"timestamp": "...", "level": "...", "message": "...", "location": "..."} Uses Pydantic's model_validate_json for automatic parsing and validation. 2. Plain text: Any other text (defaults to INFO level)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_line
|
str
|
A single log line to parse |
required |
Returns:
| Type | Description |
|---|---|
Optional[LogEntry]
|
LogEntry object. For JSON logs, all fields are validated and parsed automatically. |
Optional[LogEntry]
|
For plain text logs, only message is populated with INFO level default. |
Optional[LogEntry]
|
Returns None only for empty lines. |
Source code in src/zenml/log_stores/artifact/artifact_log_store.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
prepare_logs_uri(artifact_store: BaseArtifactStore, log_id: UUID) -> str
Generates and prepares a URI for the log file or folder for a step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
artifact_store
|
BaseArtifactStore
|
The artifact store on which the artifact will be stored. |
required |
log_id
|
UUID
|
The ID of the logs entity |
required |
Returns:
| Type | Description |
|---|---|
str
|
The URI of the log storage (file or folder). |
Source code in src/zenml/log_stores/artifact/artifact_log_store.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
remove_ansi_escape_codes(text: str) -> str
Auxiliary function to remove ANSI escape codes from a given string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
the input string |
required |
Returns:
| Type | Description |
|---|---|
str
|
the version of the input string where the escape codes are removed. |
Source code in src/zenml/log_stores/artifact/artifact_log_store.py
82 83 84 85 86 87 88 89 90 91 | |
base_log_store
Base class for log stores.
Classes
BaseLogStore(*args: Any, **kwargs: Any)
Bases: StackComponent, ABC
Base class for all ZenML log stores.
A log store is responsible for collecting, storing, and retrieving logs during pipeline and step execution. Different implementations may store logs in different backends (artifact store, OpenTelemetry, Datadog, etc.).
Initialize the log store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any
|
Positional arguments for the base class. |
()
|
**kwargs
|
Any
|
Keyword arguments for the base class. |
{}
|
Source code in src/zenml/log_stores/base_log_store.py
79 80 81 82 83 84 85 86 87 88 | |
config: BaseLogStoreConfig
property
Returns the configuration of the log store.
Returns:
| Type | Description |
|---|---|
BaseLogStoreConfig
|
The configuration. |
origin_class: Type[BaseLogStoreOrigin]
property
Class of the origin.
Returns:
| Type | Description |
|---|---|
Type[BaseLogStoreOrigin]
|
The class of the origin used with this log store. |
deregister_origin(origin: BaseLogStoreOrigin, blocking: bool = True) -> None
Deregister an origin previously registered with the log store.
If no other origins are left, the log store will be flushed. The
blocking parameter determines whether to block until the flush is
complete.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
origin
|
BaseLogStoreOrigin
|
The origin to deregister. |
required |
blocking
|
bool
|
Whether to block until the deregistration is complete and all logs are flushed if this is the last origin registered. |
True
|
Source code in src/zenml/log_stores/base_log_store.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
emit(origin: BaseLogStoreOrigin, record: logging.LogRecord, metadata: Optional[Dict[str, Any]] = None) -> None
abstractmethod
Process a log record from the logging system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
origin
|
BaseLogStoreOrigin
|
The origin used to send the log record. |
required |
record
|
LogRecord
|
The Python logging.LogRecord to process. |
required |
metadata
|
Optional[Dict[str, Any]]
|
Additional metadata to attach to the log entry. |
None
|
Source code in src/zenml/log_stores/base_log_store.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
fetch(logs_model: LogsResponse, start_time: Optional[datetime] = None, end_time: Optional[datetime] = None, limit: int = MAX_ENTRIES_PER_REQUEST) -> List[LogEntry]
abstractmethod
Fetch logs from the log store.
This method is called from the server to retrieve logs for display on the dashboard or via API. The implementation should not require any integration-specific SDKs that aren't available on the server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logs_model
|
LogsResponse
|
The logs model containing metadata about the logs. |
required |
start_time
|
Optional[datetime]
|
Filter logs after this time. |
None
|
end_time
|
Optional[datetime]
|
Filter logs before this time. |
None
|
limit
|
int
|
Maximum number of log entries to return. |
MAX_ENTRIES_PER_REQUEST
|
Returns:
| Type | Description |
|---|---|
List[LogEntry]
|
List of log entries matching the query. |
Source code in src/zenml/log_stores/base_log_store.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
flush(blocking: bool = True) -> None
abstractmethod
Flush the log store.
This method is called to ensure that all logs are flushed to the backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
blocking
|
bool
|
Whether to block until the flush is complete. |
True
|
Source code in src/zenml/log_stores/base_log_store.py
183 184 185 186 187 188 189 190 191 | |
register_origin(name: str, log_model: LogsResponse, metadata: Dict[str, Any]) -> BaseLogStoreOrigin
Register an origin for the log store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the origin. |
required |
log_model
|
LogsResponse
|
The log model associated with the origin. |
required |
metadata
|
Dict[str, Any]
|
Additional metadata to attach to the log entry. |
required |
Returns:
| Type | Description |
|---|---|
BaseLogStoreOrigin
|
The origin. |
Source code in src/zenml/log_stores/base_log_store.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
BaseLogStoreConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: StackComponentConfig
Base configuration for all log stores.
Source code in src/zenml/stack/stack_component.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
BaseLogStoreFlavor
Bases: Flavor
Base class for all ZenML log store flavors.
config_class: Type[BaseLogStoreConfig]
property
Config class for the base log store flavor.
Returns:
| Type | Description |
|---|---|
Type[BaseLogStoreConfig]
|
The config class. |
implementation_class: Type[BaseLogStore]
abstractmethod
property
Implementation class for the base log store flavor.
Returns:
| Type | Description |
|---|---|
Type[BaseLogStore]
|
The implementation class. |
type: StackComponentType
property
BaseLogStoreOrigin(name: str, log_store: BaseLogStore, log_model: LogsResponse, metadata: Dict[str, Any])
Base class for all ZenML log store origins.
The origin is the entry point for all log records to be sent to the log store for processing. The process of sending a log record is as follows:
- instantiate the log store or use the active log store
- register an origin by calling log_store.register_origin() and passing the log model and optional metadata to be attached to each log record
- emit the log record by calling log_store.emit() and passing the origin and log record
- deregister the origin when all logs have been emitted by calling log_store.deregister(origin)
Initialize a log store origin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the origin. |
required |
log_store
|
BaseLogStore
|
The log store to emit logs to. |
required |
log_model
|
LogsResponse
|
The log model associated with the origin. |
required |
metadata
|
Dict[str, Any]
|
Additional metadata to attach to all log entries that will be emitted by this origin. |
required |
Source code in src/zenml/log_stores/base_log_store.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
datadog
Datadog log store implementation.
Modules
datadog_flavor
Datadog log store flavor.
DatadogLogStoreConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: OtelLogStoreConfig
Configuration for Datadog log store.
Attributes:
| Name | Type | Description |
|---|---|---|
api_key |
PlainSerializedSecretStr
|
Datadog API key for log ingestion. |
application_key |
PlainSerializedSecretStr
|
Datadog application key for log extraction. |
site |
str
|
Datadog site (e.g., "datadoghq.com", "datadoghq.eu"). |
max_export_batch_size |
int
|
Maximum batch size for exports (Datadog limit: 1000). |
Source code in src/zenml/stack/stack_component.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
set_default_endpoint(data: Dict[str, Any]) -> Dict[str, Any]
classmethod
Set the endpoint based on site if not provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dict[str, Any]
|
The input data dictionary. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
The data dictionary with the endpoint set if not provided. |
Source code in src/zenml/log_stores/datadog/datadog_flavor.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
validate_max_export_batch_size(v: int) -> int
classmethod
Validate that max_export_batch_size doesn't exceed Datadog's limit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
int
|
The value to validate. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The validated value. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the value exceeds Datadog's limit. |
Source code in src/zenml/log_stores/datadog/datadog_flavor.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
DatadogLogStoreFlavor
Bases: Flavor
Datadog log store flavor.
config_class: Type[BaseLogStoreConfig]
property
Returns DatadogLogStoreConfig config class.
Returns:
| Type | Description |
|---|---|
Type[BaseLogStoreConfig]
|
The config class. |
docs_url: str
property
URL to the flavor documentation.
Returns:
| Type | Description |
|---|---|
str
|
The URL to the flavor documentation. |
implementation_class: Type[BaseLogStore]
property
Implementation class for this flavor.
Returns:
| Type | Description |
|---|---|
Type[BaseLogStore]
|
The implementation class. |
logo_url: str
property
URL to the flavor logo.
Returns:
| Type | Description |
|---|---|
str
|
The URL to the flavor logo. |
name: str
property
Name of the flavor.
Returns:
| Type | Description |
|---|---|
str
|
The name of the flavor. |
sdk_docs_url: str
property
URL to the SDK docs for this flavor.
Returns:
| Type | Description |
|---|---|
str
|
The URL to the SDK docs for this flavor. |
type: StackComponentType
property
datadog_log_exporter
Log exporter that writes logs to Datadog.
DatadogLogExporter(endpoint: str, certificate_file: Optional[str] = None, client_key_file: Optional[str] = None, client_certificate_file: Optional[str] = None, headers: Optional[Dict[str, str]] = None, timeout: float = DEFAULT_TIMEOUT, compression: Compression = Compression.NoCompression)
Bases: OTLPLogExporter
Datadog log exporter.
This exporter writes OpenTelemetry logs to Datadog's HTTP intake API with slightly modified log records to adapt to Datadog's format.
Source code in src/zenml/log_stores/otel/otel_log_exporter.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
datadog_log_store
Datadog log store implementation.
DatadogLogStore(*args: Any, **kwargs: Any)
Bases: OtelLogStore
Log store that exports logs to Datadog.
This implementation extends OtelLogStore and configures it to send logs to Datadog's HTTP intake API.
Source code in src/zenml/log_stores/otel/otel_log_store.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
config: DatadogLogStoreConfig
property
Returns the configuration of the Datadog log store.
Returns:
| Type | Description |
|---|---|
DatadogLogStoreConfig
|
The configuration. |
cleanup() -> None
Cleanup the Datadog log store.
This method is called when the log store is no longer needed.
Source code in src/zenml/log_stores/datadog/datadog_log_store.py
242 243 244 245 246 247 248 249 | |
fetch(logs_model: LogsResponse, start_time: Optional[datetime] = None, end_time: Optional[datetime] = None, limit: int = MAX_ENTRIES_PER_REQUEST) -> List[LogEntry]
Fetch logs from Datadog's API.
This method queries Datadog's Logs API to retrieve logs for the specified pipeline run and step. It automatically paginates through results to fetch up to the requested limit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logs_model
|
LogsResponse
|
The logs model containing run and step metadata. |
required |
start_time
|
Optional[datetime]
|
Filter logs after this time. |
None
|
end_time
|
Optional[datetime]
|
Filter logs before this time. |
None
|
limit
|
int
|
Maximum number of log entries to return. |
MAX_ENTRIES_PER_REQUEST
|
Returns:
| Type | Description |
|---|---|
List[LogEntry]
|
List of log entries from Datadog. |
Source code in src/zenml/log_stores/datadog/datadog_log_store.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
get_exporter() -> DatadogLogExporter
Get the Datadog log exporter.
Returns:
| Type | Description |
|---|---|
DatadogLogExporter
|
DatadogExporter with the proper configuration. |
Source code in src/zenml/log_stores/datadog/datadog_log_store.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
otel
OpenTelemetry log store implementation.
Modules
otel_flavor
OpenTelemetry log store flavor.
Compression
OtelLogStoreConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseLogStoreConfig
Configuration for OpenTelemetry log store.
Attributes:
| Name | Type | Description |
|---|---|---|
service_name |
str
|
Name of the service (defaults to "zenml"). |
service_version |
str
|
Version of the service (defaults to the ZenML version). |
max_queue_size |
int
|
Maximum queue size for batch processor. |
schedule_delay_millis |
int
|
Delay between batch exports in milliseconds. |
max_export_batch_size |
int
|
Maximum batch size for exports. |
endpoint |
str
|
The endpoint to export logs to. |
headers |
Optional[Dict[str, str]]
|
The headers to use for the export. |
certificate_file |
Optional[str]
|
The certificate file to use for the export. |
client_key_file |
Optional[str]
|
The client key file to use for the export. |
client_certificate_file |
Optional[str]
|
The client certificate file to use for the export. |
compression |
Compression
|
The compression to use for the export. |
Source code in src/zenml/stack/stack_component.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
OtelLogStoreFlavor
Bases: Flavor
OpenTelemetry log store flavor.
config_class: Type[BaseLogStoreConfig]
property
Returns DatadogLogStoreConfig config class.
Returns:
| Type | Description |
|---|---|
Type[BaseLogStoreConfig]
|
The config class. |
docs_url: str
property
URL to the flavor documentation.
Returns:
| Type | Description |
|---|---|
str
|
The URL to the flavor documentation. |
implementation_class: Type[BaseLogStore]
property
Implementation class for this flavor.
Returns:
| Type | Description |
|---|---|
Type[BaseLogStore]
|
The implementation class. |
logo_url: str
property
URL to the flavor logo.
Returns:
| Type | Description |
|---|---|
str
|
The URL to the flavor logo. |
name: str
property
Name of the flavor.
Returns:
| Type | Description |
|---|---|
str
|
The name of the flavor. |
sdk_docs_url: str
property
URL to the SDK docs for this flavor.
Returns:
| Type | Description |
|---|---|
str
|
The URL to the SDK docs for this flavor. |
type: StackComponentType
property
otel_log_exporter
OpenTelemetry exporter that writes logs to any OpenTelemetry backend.
OTLPLogExporter(endpoint: str, certificate_file: Optional[str] = None, client_key_file: Optional[str] = None, client_certificate_file: Optional[str] = None, headers: Optional[Dict[str, str]] = None, timeout: float = DEFAULT_TIMEOUT, compression: Compression = Compression.NoCompression)
Bases: LogExporter
OpenTelemetry exporter using JSON protocol.
This exporter is a placeholder until the actual implementation of the OpenTelemetry exporter is available in the opentelemetry-exporter-otlp-proto-json package.
Initialize the exporter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
The endpoint to export logs to. |
required |
certificate_file
|
Optional[str]
|
The certificate file to use for the export. |
None
|
client_key_file
|
Optional[str]
|
The client key file to use for the export. |
None
|
client_certificate_file
|
Optional[str]
|
The client certificate file to use for the export. |
None
|
headers
|
Optional[Dict[str, str]]
|
The headers to use for the export. |
None
|
timeout
|
float
|
The timeout to use for the export. |
DEFAULT_TIMEOUT
|
compression
|
Compression
|
The compression to use for the export. |
NoCompression
|
Source code in src/zenml/log_stores/otel/otel_log_exporter.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
export(batch: Sequence[LogData]) -> LogExportResult
Export a batch of logs to the OpenTelemetry backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
Sequence[LogData]
|
The batch of logs to export. |
required |
Returns:
| Type | Description |
|---|---|
LogExportResult
|
LogExportResult indicating success or failure. |
Source code in src/zenml/log_stores/otel/otel_log_exporter.py
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | |
shutdown() -> None
Shutdown the exporter.
Source code in src/zenml/log_stores/otel/otel_log_exporter.py
375 376 377 378 379 380 381 382 | |
otel_log_store
OpenTelemetry log store implementation.
OtelBatchLogRecordProcessor
Bases: BatchLogRecordProcessor
OpenTelemetry batch log record processor.
This is a subclass of the BatchLogRecordProcessor that allows for a non-blocking flush.
flush(blocking: bool = True) -> bool
Force flush the batch log record processor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
blocking
|
bool
|
Whether to block until the flush is complete. |
True
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the flush is successful, False otherwise. |
Source code in src/zenml/log_stores/otel/otel_log_store.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
OtelLogStore(*args: Any, **kwargs: Any)
Bases: BaseLogStore
Log store that exports logs using OpenTelemetry.
Subclasses should implement get_exporter() to provide the specific
log exporter for their backend.
Initialize the OpenTelemetry log store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any
|
Positional arguments for the base class. |
()
|
**kwargs
|
Any
|
Keyword arguments for the base class. |
{}
|
Source code in src/zenml/log_stores/otel/otel_log_store.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
config: OtelLogStoreConfig
property
Returns the configuration of the OTel log store.
Returns:
| Type | Description |
|---|---|
OtelLogStoreConfig
|
The configuration. |
origin_class: Type[OtelLogStoreOrigin]
property
provider: LoggerProvider
property
Returns the OpenTelemetry logger provider.
Returns:
| Type | Description |
|---|---|
LoggerProvider
|
The logger provider. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the OpenTelemetry log store is not initialized. |
deactivate() -> None
Deactivate log collection and shut down the processor.
Flushes any pending logs and shuts down the processor's background thread.
Source code in src/zenml/log_stores/otel/otel_log_store.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | |
emit(origin: BaseLogStoreOrigin, record: logging.LogRecord, metadata: Optional[Dict[str, Any]] = None) -> None
Process a log record by sending to OpenTelemetry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
origin
|
BaseLogStoreOrigin
|
The origin used to send the log record. |
required |
record
|
LogRecord
|
The log record to process. |
required |
metadata
|
Optional[Dict[str, Any]]
|
Additional metadata to attach to the log entry. |
None
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the OpenTelemetry provider is not initialized. |
Source code in src/zenml/log_stores/otel/otel_log_store.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | |
fetch(logs_model: LogsResponse, start_time: Optional[datetime] = None, end_time: Optional[datetime] = None, limit: int = MAX_ENTRIES_PER_REQUEST) -> List[LogEntry]
Fetch logs from the OpenTelemetry backend.
This method should be overridden by subclasses to implement backend-specific log retrieval. The base implementation returns an empty list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logs_model
|
LogsResponse
|
The logs model containing run and step metadata. |
required |
start_time
|
Optional[datetime]
|
Filter logs after this time. |
None
|
end_time
|
Optional[datetime]
|
Filter logs before this time. |
None
|
limit
|
int
|
Maximum number of log entries to return. |
MAX_ENTRIES_PER_REQUEST
|
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Log fetching is not supported by the OTEL log store. |
Source code in src/zenml/log_stores/otel/otel_log_store.py
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | |
flush(blocking: bool = True) -> None
Flush the log store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
blocking
|
bool
|
Whether to block until the flush is complete. |
True
|
This method is called to ensure that all logs are flushed to the backend.
Source code in src/zenml/log_stores/otel/otel_log_store.py
271 272 273 274 275 276 277 278 279 280 281 | |
get_exporter() -> LogExporter
Get the Datadog log exporter.
Returns:
| Type | Description |
|---|---|
LogExporter
|
OTLPLogExporter configured with API key and site. |
Source code in src/zenml/log_stores/otel/otel_log_store.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
register_origin(name: str, log_model: LogsResponse, metadata: Dict[str, Any]) -> BaseLogStoreOrigin
Register an origin for the log store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the origin. |
required |
log_model
|
LogsResponse
|
The log model associated with the origin. |
required |
metadata
|
Dict[str, Any]
|
Additional metadata to attach to the log entry. |
required |
Returns:
| Type | Description |
|---|---|
BaseLogStoreOrigin
|
The origin. |
Source code in src/zenml/log_stores/otel/otel_log_store.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
OtelLogStoreOrigin(name: str, log_store: BaseLogStore, log_model: LogsResponse, metadata: Dict[str, Any])
Bases: BaseLogStoreOrigin
OpenTelemetry log store origin.
Initialize a log store origin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the origin. |
required |
log_store
|
BaseLogStore
|
The log store to emit logs to. |
required |
log_model
|
LogsResponse
|
The log model associated with the origin. |
required |
metadata
|
Dict[str, Any]
|
Additional metadata to attach to all log entries that will be emitted by this origin. |
required |
Source code in src/zenml/log_stores/otel/otel_log_store.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
logger: Logger
property
Returns the OpenTelemetry logger for this origin.
Returns:
| Type | Description |
|---|---|
Logger
|
The logger. |