monitoring

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2025 License: MIT Imports: 3 Imported by: 0

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

View Source
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.

View Source
var GetGlobalMetrics = monitoring.GetGlobalMetrics

GetGlobalMetrics returns the current global metrics implementation.

View Source
var GetProfilingAddress = monitoring.GetProfilingAddress

GetProfilingAddress returns the address of the pprof server if enabled.

View Source
var IsProfilingEnabled = monitoring.IsProfilingEnabled

IsProfilingEnabled returns whether pprof profiling is currently enabled.

View Source
var SetGlobalMetrics = monitoring.SetGlobalMetrics

SetGlobalMetrics sets the global metrics implementation.

View Source
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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL