Skip to content

Add initial experimental support for immediately pushing metrics in a FaaS context #98

Closed
@brettimus

Description

@brettimus

Motivation

When using autometrics with a push configuration inside, e.g., an edge function, we run into the issue that the library sets up an interval at which it pushes metrics to a push/aggregation gateway.

This makes the assumption that the parent script is a long-running process.

In an environment like that of Supabase's Edge Functions, we run into the issue that when autometrics is imported and configured in an edge function, it will keep the edge function alive (because of its interval) until the edge function either exceeds its allowed CPU time or times out entirely. In production, anyone using autometrics would effectively be faced with extra billing costs due to this.

Solution

As a first pass, we configure autometrics to immediately push new metrics whenever they are available, in the case where the pushInterval configuration parameter is set to 0.

For a future iteration, we can support a more robust push configuration, as there are likely other relevant options for the FaaS usecase (e.g., configuring a timeout of requests to the gateway).

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions