logfire icon indicating copy to clipboard operation
logfire copied to clipboard

Callback metrics collection interval

Open gpkc opened this issue 1 year ago • 3 comments

Question

According to the docs:

Callback metrics, or observable metrics, are a way to create metrics that are automatically updated based on a time interval.

However, there doesn't seem to be any mentioning in the docs on how to configure this time interval. I presume it might be the export interval which can be set with otel_interval_milliseconds ?

gpkc avatar Dec 05 '24 15:12 gpkc

If you're getting otel_interval_milliseconds from https://logfire.pydantic.dev/docs/integrations/airflow/?h=otel_interval_milliseconds#airflow-configuration, yes.

More generally there's the environment variable OTEL_METRIC_EXPORT_INTERVAL.

alexmojaki avatar Dec 05 '24 15:12 alexmojaki

Makes sense. I presume under the hood, logfire uses a PeriodicExportingMetricReader maybe around here: https://github.com/pydantic/logfire/blob/main/logfire/_internal/config.py#L859 These take a export_interval_millis, so perhaps it could be interesting to be able to manually define separate readers with customized intervals. I don't know how these interact with OTEL_METRIC_EXPORT_INTERVAL if a custom interval is set.

gpkc avatar Dec 05 '24 16:12 gpkc

Example use cases for this would be: specifying lower intervals for metrics that require a higher resolution, or higher intervals for metrics that may consume resources (e.g. query a database)

gpkc avatar Dec 05 '24 16:12 gpkc