Skip to main content
Version: 2.10.x(Latest)

📄️ Basic

Demonstrates comprehensive basic metric types and their usage in GoFrame with OpenTelemetry and Prometheus integration. This example showcases counter metrics for tracking event occurrences, histogram metrics for measuring distributions, gauge metrics for current values, and UpDownCounter for bidirectional counting. Features include metric creation and registration, attribute configuration and labeling, metric value recording and observation, integration with Prometheus exporter, OpenTelemetry metric pipeline setup, and production-ready instrumentation patterns. Ideal for learning fundamental metric types, implementing application observability, monitoring service performance, building custom metrics dashboards, and establishing baseline monitoring for GoFrame applications.

📄️ Callback

Demonstrates callback-based metric collection in GoFrame using OpenTelemetry and Prometheus for asynchronous metric updates. This example showcases callback function registration for metrics, automatic metric value updates through callbacks, asynchronous metric observation, observable counter and gauge patterns, system resource metrics collection, and scheduled metric updates. Features include non-blocking metric collection, periodic callback execution, system metrics integration (CPU, memory, goroutines), lazy metric evaluation, automatic value refresh, and production-ready patterns. Ideal for collecting system metrics, monitoring resource usage, implementing asynchronous metric updates, reducing metric collection overhead, observing expensive-to-compute values, and building efficient monitoring systems with minimal performance impact.

📄️ Dynamic Attributes

Demonstrates dynamic metric attribute management in GoFrame using OpenTelemetry and Prometheus for runtime attribute updates. This example showcases runtime attribute modification, context-based attribute injection, request-scoped metric labeling, dynamic attribute value resolution, per-request metric customization, and flexible labeling patterns. Features include updating attributes during metric recording, extracting attributes from request context, injecting user/tenant/session IDs, dynamic label value computation, attribute value caching, and production-ready patterns. Ideal for implementing per-request metric labeling, tracking user-specific metrics, supporting multi-tenancy, enriching metrics with runtime context, analyzing behavior by dynamic dimensions, and building flexible monitoring systems that adapt to application state.

📄️ Global Attributes

Demonstrates global metric attributes management in GoFrame using OpenTelemetry and Prometheus for consistent metric labeling. This example showcases global attribute configuration and management, automatic attribute application across all metrics, service-level metadata (service.name, service.version), environment identification attributes, consistent metric labeling, and attribute inheritance patterns. Features include centralized attribute management, automatic attribute propagation, semantic convention support, multi-tenancy labeling, deployment environment tags, and production-ready patterns. Ideal for implementing consistent metric labeling, managing service metadata, enabling metric aggregation across services, supporting multi-environment deployments, facilitating metric filtering and grouping, and establishing enterprise monitoring standards.

📄️ HTTP Client

Demonstrates comprehensive HTTP client metrics collection in GoFrame using OpenTelemetry and Prometheus for monitoring outbound HTTP requests. This example showcases automatic HTTP client instrumentation, request duration histograms, request count metrics by status code and method, error rate tracking, connection pool metrics, and retry attempt monitoring. Features include automatic metric collection without code changes, detailed request/response attributes, integration with GoFrame's HTTP client, customizable metric labels, Prometheus exporter configuration, and production-ready observability patterns. Ideal for monitoring external API calls, tracking HTTP client performance, debugging connectivity issues, analyzing request patterns, and ensuring reliability of outbound HTTP communications in microservices architectures.

📄️ HTTP Server

Demonstrates comprehensive HTTP server metrics collection in GoFrame using OpenTelemetry and Prometheus for monitoring inbound HTTP requests. This example showcases automatic HTTP server instrumentation, request latency histograms, throughput metrics by endpoint and method, HTTP status code distribution, concurrent request tracking, and error rate monitoring. Features include automatic metric collection through middleware, detailed request attributes (path, method, status), integration with GoFrame's HTTP server, customizable metric buckets, Prometheus endpoint exposure, and production-ready monitoring patterns. Ideal for monitoring API performance, tracking service health, analyzing traffic patterns, identifying performance bottlenecks, implementing SLA monitoring, and ensuring high availability of HTTP services in production environments.

📄️ Meter Attributes

Demonstrates meter-level attribute management in GoFrame using OpenTelemetry and Prometheus for scoped metric labeling. This example showcases meter-specific attribute configuration, attribute scoping within meters, isolated metric labeling, meter-level metadata management, attribute inheritance from meters to metrics, and fine-grained attribute control. Features include creating meters with custom attributes, scoping attributes to specific metric groups, isolated attribute namespaces, automatic attribute application to meter metrics, meter-based multi-tenancy, and production-ready patterns. Ideal for organizing metrics by module or component, implementing scoped metric labeling, managing multiple metric namespaces, isolating attributes between metric groups, building modular monitoring systems, and establishing hierarchical metric organization for complex applications.

📄️ Prometheus Integration

Demonstrates direct Prometheus metrics integration in GoFrame without OpenTelemetry for lightweight monitoring solutions. This example showcases native Prometheus client library usage, direct metric registration with Prometheus registry, counter, gauge, histogram, and summary metric types, custom metric collectors, HTTP handler for /metrics endpoint exposure, and label management. Features include zero OpenTelemetry dependency, simple metric creation and registration, native Prometheus metric types, flexible metric labeling, built-in HTTP metrics endpoint, and production-ready patterns. Ideal for lightweight monitoring needs, legacy Prometheus setups, simplified metric collection, applications requiring only Prometheus integration, minimal dependency footprint, and environments where OpenTelemetry is not needed or desired.