DepthsLogger()
class, ingest a small set of log rows (which automatically get persisted on disk),
and run a basic query with filters and projection.
What you will build
- A local instance directory for persisting telemetry signals on disk
- A
DepthsLogger()
object that automatically persists received telemetry signals on disk - A tiny dataset of log rows with a few varying fields
- A verification query that returns either dicts or a lazy frame
Prerequisites
- Python 3.12+
pip install depths
Imports and setup
We keep the instance id and directory explicit. Day boundaries are UTC. The logger will create directories and configs on first use.Create the logger
depths.core.logger.DepthsLogger
prepares today’s day folder, installs defaults, and starts aggregators by default.
Build a minimal dataset
Depths expects OTel-shaped rows for each table. For logs, the required fields are satisfied by providingproject_id
and a timestamp in nanoseconds; the rest is normalized by the producer. We vary severity and body to make filtering obvious.
Ingest synchronously
The logger validates and enqueues each row. Aggregators batch and persist to Delta in the background.Stop and flush
stop(flush="auto")
performs a bounded, quick flush of pending batches to the local disk.
Basic verification as dicts
depths.core.logger.DepthsLogger.read_logs
composes a lazy plan with pushdown filters. By default it materializes to a list of dicts. We select a few columns and limit to five latest rows.
The same query as a lazy frame
Setreturn_as="lazy"
to keep everything lazy for downstream operations. Collect only when you are ready.
What just happened
depths.core.logger.DepthsLogger
created our telemetry ingestor, with all the config and empty storage tables on the disk.- Each call to
ingest_log
validated the row againstdepths.core.schema.LOG_SCHEMA
viadepths.core.producer.LogProducer
, ensuring that only correct OpenTelemtry compatible rows get stored. - Behind the scenes,
depths.core.aggregator.LogAggregator
batched rows into typed Polars frames and appended to the logs Delta table under today’s UTC day, giving us the disk persistence. read_logs
built a lazy plan with equality, substring, and time-range predicates for efficient querying. We can then view these result as either a list of dictionaries, a polars dataframe or further perform ops on lazyframe (useful for operations like counts and other statistical options). We recommend reading about the Polars package and LazyFrame concept. Since we don’t expect every Depths user to be familiar with Polars, the default query function response is a list of dictionary objects.
Where to go next
- Tune behavior with
depths.core.config.DepthsLoggerOptions
and producer+aggregator configs in Customizing Depths - Explore more query patterns (projection, limits, groups) in Querying possibilities with Depths
- Add S3 shipping and read sealed days from object storage in S3 backups from scratch