Skip to content

feat: add metrique-battery-pack #247

@jlizen

Description

@jlizen

New crate: metrique-battery-pack

Ref: battery-pack repo, authoring guide

Motivation

metrique has 13 crates in its workspace. A basic "define a struct, set up a sink, emit on drop" workflow touches three crates and four or five trait imports from different modules. Good candidate for a battery pack.

Most of the workspace crates are already re-exported by metrique behind feature flags. The battery pack should enable those flags rather than adding the underlying crates as separate dependencies.

Default set

Just metrique itself.

Features

Feature What it enables Notes
emf metrique/emf CloudWatch Embedded Metric Format
json metrique/json Plain JSON output
aggregation metrique-aggregation #[aggregate], Histogram, Sum, KeyedAggregator, WorkerSink
util metrique-util State<T> for shared runtime state

Templates

Multiple templates, each with tests demonstrating test-util feature enablement. A shared METRIQUE.md (trait import cheat sheet, next steps, how to switch formats) is included in all templates via [[files]]. Templates can use MiniJinja placeholder variables (e.g., format = emf/json) to branch on sink setup, Cargo features, and imports.

cargo bp new metrique --name my-service
# prompts for template selection
Template What it scaffolds
default Async runtime, sink initialization (MiniJinja format placeholder for emf/json), global metrics setup (merge_globals), sample #[metrics] request handler with emit on drop
library #[metrics(subfield)] function using Instrumented, returning metrics to the caller
aggregation #[aggregate] with Histogram/Sum, embedded via Aggregate<T>, KeyedAggregator

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions