Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Prometheus Client Php Laravel Package

promphp/prometheus_client_php

Prometheus client library for PHP with counters, gauges, histograms, and summaries. Supports Redis, Predis, APCu/APCng, or in-memory storage for metric aggregation across workers, with simple APIs to register, update, and expose metrics for scraping.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Observability Roadmap: Enables standardized metrics collection for PHP applications, aligning with broader observability initiatives (e.g., Prometheus integration). Justifies investment in monitoring infrastructure by reducing tooling fragmentation.
  • Build vs. Buy: Buy—avoids reinventing Prometheus instrumentation for PHP, leveraging a battle-tested, community-maintained library. Reduces dev effort and risk compared to custom solutions.
  • Use Cases:
    • Microservices: Track request latency, error rates, and throughput across distributed PHP services (e.g., Laravel APIs).
    • Performance Optimization: Identify bottlenecks via histograms/summaries (e.g., database query durations, cache hit ratios).
    • SLA Compliance: Monitor custom business metrics (e.g., "orders processed per minute") for SLO/SLI tracking.
    • Cost Efficiency: Replace proprietary APM tools for lightweight metrics collection (e.g., in serverless or high-scale environments).
  • Data-Driven Decisions: Enables A/B testing metrics (e.g., feature adoption rates) by exposing granular labels (e.g., variant="control").
  • Compliance/Reporting: Supports auditable metric collection for regulatory requirements (e.g., "system uptime > 99.9%").

When to Consider This Package

  • Adopt When:

    • Your PHP stack (e.g., Laravel, Symfony) lacks native Prometheus support or requires custom metrics beyond APM tools (e.g., New Relic, Datadog).
    • You need multi-process aggregation (e.g., PHP-FPM workers, cron jobs) without PushGateway (use the companion prometheus_push_gateway_php if needed).
    • Cost is a constraint: Avoid vendor lock-in with open-source instrumentation.
    • Your team has PHP expertise to integrate metrics endpoints (e.g., /metrics) and configure storage adapters (Redis/APCu).
    • You’re using Prometheus/Grafana for visualization and alerting (or plan to migrate to it).
  • Look Elsewhere If:

    • You need PushGateway support (use the companion package or another library like stripe/prometheus-client-php).
    • Your app is serverless (consider AWS CloudWatch Embedded Metrics or similar).
    • You require distributed tracing (combine with OpenTelemetry PHP or Jaeger).
    • Your team lacks PHP/Prometheus familiarity (opt for managed APM tools with lower setup friction).
    • You’re using PHP 8.1 or below (package requires PHP 8.2+).
    • Your infrastructure cannot run Redis/APCu (e.g., shared hosting; use the in-memory adapter for short-lived scripts only).

How to Pitch It (Stakeholders)

For Executives:

*"This library lets us instrument our PHP applications with standardized, open-source metrics—enabling proactive performance monitoring, cost savings (vs. APM tools), and compliance reporting. By integrating Prometheus, we gain:

  • Visibility: Track custom KPIs (e.g., 'user signups/hour') alongside system metrics.
  • Scalability: Works across microservices, cron jobs, and high-traffic APIs.
  • Future-Proofing: Avoids vendor lock-in; aligns with cloud-native observability trends. Investment: Minimal (Composer install + Redis/APCu setup). ROI: Reduced MTTR, data-driven optimizations, and potential cost savings vs. proprietary tools."*

For Engineering:

*"This is the de facto Prometheus client for PHP, offering:

  • Flexible Storage: Choose Redis (for distributed setups), APCu (shared memory), or in-memory (short-lived scripts).
  • Rich Metrics: Counters, gauges, histograms, and summaries—with support for labels (e.g., service="auth", environment="prod").
  • Performance: Optimized for PHP 8.2+; avoids global state issues with multi-process apps.
  • Integration: Works with Laravel/Symfony via middleware or CLI scripts. Example:
    // Track API requests
    $counter = CollectorRegistry::getDefault()
        ->getOrRegisterCounter('api', 'requests_total', 'Total API calls')
        ->inc();
    

Trade-offs: Requires manual endpoint setup (/metrics) and Redis/APCu config. No PushGateway (but we can add the companion package if needed)."*

For DevOps/SRE:

*"This gives us self-service metrics for PHP apps without relying on external APM tools. Key benefits:

  • No Sampling: Collects all metrics (unlike APM tools that sample).
  • Prometheus Ecosystem: Integrates with Grafana, Alertmanager, and Thanos for long-term storage.
  • Lightweight: ~5MB footprint; runs alongside existing services. Setup: Add to composer.json, configure Redis/APCu, and expose /metrics (e.g., via Nginx route). Example Docker setup:
    services:
      redis:
        image: redis
      app:
        depends_on: [redis]
    

Alerting: Define rules in Prometheus (e.g., api_requests_total > 1000 triggers an alert)."*

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
datacore/hub-sdk
alengo/sulu-http-cache-bundle
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
imbo/imbo-coding-standard
visualbuilder/filament-lottie
servicioslineaonce/starter-kit
atomcoder/laravel-reorderable
irajul/filament-shadcn-theme
agtp/agtp-php
agtp/mod-php
centraldesktop/protobuf-php
trappistes/laravel-custom-fields
splash/sonata-admin
splash/metadata