Documentation
¶
Overview ¶
Package monitoring provides pluggable metrics collection for BubblyUI composables.
The monitoring system is entirely optional and has zero overhead when disabled. By default, a NoOp implementation is used which performs no operations.
This package is an alias for github.com/newbpydev/bubblyui/pkg/bubbly/monitoring, providing a cleaner import path for users.
Features ¶
- Composable creation count and duration tracking
- Provide/Inject tree depth monitoring
- Memory allocation tracking per composable
- Cache hit/miss rates for performance optimization
- Prometheus metrics integration
- pprof profiling endpoints
Example ¶
import "github.com/newbpydev/bubblyui/monitoring"
func main() {
// Enable Prometheus metrics
metrics := monitoring.NewPrometheusMetrics(prometheus.DefaultRegisterer)
monitoring.SetGlobalMetrics(metrics)
// Enable pprof profiling on port 6060
monitoring.EnableProfiling(":6060")
defer monitoring.StopProfiling()
}
Zero Overhead ¶
When monitoring is disabled (default), there is zero overhead:
- No allocations
- No mutex contention
- No function calls (inlined NoOp methods)
- No performance impact
Index ¶
Constants ¶
This section is empty.
Variables ¶
var EnableProfiling = monitoring.EnableProfiling
EnableProfiling starts a pprof HTTP server on the specified address. Returns an error if profiling is already enabled or the server fails to start.
var GetGlobalMetrics = monitoring.GetGlobalMetrics
GetGlobalMetrics returns the current global metrics implementation.
var GetProfilingAddress = monitoring.GetProfilingAddress
GetProfilingAddress returns the address of the pprof server if enabled.
var IsProfilingEnabled = monitoring.IsProfilingEnabled
IsProfilingEnabled returns whether pprof profiling is currently enabled.
var SetGlobalMetrics = monitoring.SetGlobalMetrics
SetGlobalMetrics sets the global metrics implementation.
var StopProfiling = monitoring.StopProfiling
StopProfiling stops the pprof HTTP server if running.
Functions ¶
This section is empty.
Types ¶
type CallStats ¶
type CallStats = monitoring.CallStats
CallStats contains statistics about composable calls.
type ComposableMetrics ¶
type ComposableMetrics = monitoring.ComposableMetrics
ComposableMetrics defines the interface for composable metrics collection.
type ComposableProfile ¶
type ComposableProfile = monitoring.ComposableProfile
ComposableProfile contains profiling results for composables.
func ProfileComposables ¶
func ProfileComposables(duration time.Duration) *ComposableProfile
ProfileComposables runs composable profiling for the specified duration.
type NoOpMetrics ¶
type NoOpMetrics = monitoring.NoOpMetrics
NoOpMetrics is a no-op implementation with zero overhead.
type PrometheusMetrics ¶
type PrometheusMetrics = monitoring.PrometheusMetrics
PrometheusMetrics implements ComposableMetrics using Prometheus.
func NewPrometheusMetrics ¶
func NewPrometheusMetrics(reg prometheus.Registerer) *PrometheusMetrics
NewPrometheusMetrics creates a new Prometheus metrics implementation.