stechstudio/laravel-metrics
A Laravel package for recording and querying application metrics. Track counters, trends, and key performance or business data over time through a simple API, backed by database storage, so you can monitor and visualize what matters in your app.
Architecture fit. For a Laravel-centric estate, this package slots into the framework's event dispatcher and service container with minimal ceremony. It converts Laravel event/listener patterns—the same mechanism already used for domain events—into metric emission, which means teams can instrument business events (order placed, invite sent, webhook processed) without importing a vendor SDK at every call site. The façade-plus-config-driven-mapping pattern is idiomatic Laravel and low-cognitive-overhead for mid-level engineers. It is an application-level metrics shipper, not a full observability platform: no tracing, no log correlation, no dashboards. Treat it as the emission layer feeding an existing backend.
Integration feasibility. First-class drivers for InfluxDB, Prometheus, CloudWatch, and PostHog mean we can standardize on one interface while different environments or teams ship to their existing backend. That is a real de-risking property: we are not forcing a backend migration to adopt the package. The main integration work is mapping our event taxonomy to metric names and tags and deciding sync vs. queued shipping. If the package supports queued jobs (verify), wiring to Redis/SQS is straightforward.
Technical risk.
track API hides those differences, so tag design and driver choice must be governed centrally.Key questions.
PutMetricData batching)?Stack fit. Native fit for a Laravel 10/11 monolith or modular monolith on PHP 8.2+. It leverages the framework's event system, so it complements—rather than competes with—existing logging (Monolog) and tracing. In a multi-service estate, use it in Laravel services only; non-Laravel services should emit via OpenTelemetry/StatsD to the same backend so the metric namespace stays consistent. Decide up front whether this is the single emission standard or a transitional tool.
Migration path. Phase 1: install in one bounded service, publish config, wire a non-critical event (e.g., UserLoggedIn) to a backend already in use (CloudWatch or Influx likely). Phase 2: define a naming/tagging convention (domain.entity.action, tags limited to low-cardinality dimensions like plan, region, status). Phase 3: replace ad-hoc Log::info('metric', …) and StatsD calls with the package's API behind a thin internal wrapper (App\Metrics\Recorder) so the vendor API never leaks into domain code. Phase 4: expand event coverage and add dashboards/alerts in the backend. The wrapper is the key migration decision—it gives us a swap path if the package stalls.
Compatibility. Verify Laravel version constraints, PHP 8.x support, and whether the drivers pull in heavy SDKs (AWS SDK for CloudWatch is large; Influx/Prometheus clients vary). Check for conflicts with existing service providers and HTTP clients. For Prometheus specifically, confirm how the registry is exposed (a /metrics route or Pushgateway) and whether it plays nicely with Octane—long-lived workers and static registries are a known pitfall.
Sequencing. Instrumentation policy and tag governance must precede broad rollout; otherwise you get inconsistent metric names that are expensive to fix later. Recommend: (1) backend decision, (2) tagging standard, (3) wrapper + driver config, (4) one service in production, (5) expand by event tier (business-critical first), (6) dashboards/alerts. Avoid parallel instrumentation of many services before the convention is validated.
Maintenance. Low code footprint, MIT license, Composer-managed. The real maintenance is upstream: a 50-star package with a small maintainer base means we should budget for occasional abandoned-dependency scenarios (Laravel major upgrades, PHP releases). Pin versions, watch the repo, and keep the internal wrapper so fork-and-own is a day's work, not a quarter's. Budget roughly 0.1–0.2 FTE for stewardship across the portfolio.
Support. No commercial support; community-only. Internal ownership must be explicit—an observability or platform team should own the wrapper, tagging standard, and driver configuration. Application teams own their event definitions. Without a named owner, metric sprawl is guaranteed.
Scaling. Scales with request volume and event count, not with the package itself. Bottlenecks will be (a) backend ingestion limits—CloudWatch API throttling and per-metric cost, Influx write throughput and cardinality, Prometheus scrape intervals and memory; (b) queue throughput if async; (c) tag cardinality. Plan for sampling on high-volume events and aggregation at the source (counters incremented in-process and flushed, rather than one write per event). At high RPS, per-event synchronous writes are not viable; confirm batching.
Failure modes.
Ramp-up. Low for engineers already fluent in Laravel events and config—half a day to first metric, one to two sprints to a governed rollout. The learning curve is not the API; it is observability discipline (naming, tags, cardinality, alert design). Pair the rollout with a short internal guide and a reviewed metric catalog. Overall: a pragmatic, low-risk emission layer for Laravel services, contingent on treating tag governance and async shipping as first-class requirements rather than afterthoughts.
How can I help you explore Laravel packages today?