How marcobreveglieri/prometheus-client-delphi works
Project Type and Purpose
• This is a client‐library project (“Prometheus Client for Delphi”), not a standalone service.
• Its purpose is to provide Delphi applications with the ability to define, register, update, and expose Prometheus metrics (counters, gauges, histograms, etc.) in the Prometheus text exposition format.
• It also ships sample integrations (DMVC, Horse, WebBroker, WiRL) and automated tests.
File Structure Analysis
• Top‐level:
• Source/ – the core Delphi packages and units (Collectors, Registry, Exposers, Labels, Metrics).
• Samples/ – starter apps showing how to integrate the library with different web frameworks.
• Tests/ – unit and fixture code verifying collectors and registry behavior.
• Prometheus.Client.groupproj – Delphi group project file aggregating packages.
• boss.json / boss-lock.json – BOSS package manager descriptors.
• Core design pattern: a central CollectorRegistry holds Collector instances; Collectors are grouped by metric type and labeled; Exposers format registry contents to text.
Reading the README
• Confirms core components: TCollectorRegistry, concrete collector types (TCounter, TGauge, THistogram), text based exposer.
• Mentions middleware for popular Delphi web frameworks to automatically expose “/metrics” endpoints.
• Highlights customization via custom collectors.
• Prometheus.Client.Core (Registry, Collector base types)
• Collectors Module (Counter, Gauge, Histogram, Summary)
• Exposition Module (TextExposer, middleware adapters)
• Sample Web Apps (DMVC, Horse, WebBroker, WiRL)
• External System: Prometheus Server (scrapes /metrics)
• Tests (validating collector behaviors)
• Sample App → instantiates collectors → registers them in → CollectorRegistry
• Application code → updates metrics via → Collector instances
• HTTP Middleware or manual call → invokes → TextExposer → reads Registry → produces HTTP response
• Prometheus Server → scrapes → /metrics endpoint → ingests time series data
• Tests → import → Collectors & Registry → assert metric values
c. Architectural Patterns & Principles:
• Singleton or default instance for CollectorRegistry
• Factory or builder pattern via “.Create(…)” and “.Register()” fluent API
• Separation of concerns: collecting vs. formatting vs. HTTP serving
d. Technologies & Frameworks:
• Delphi (Object Pascal) packages and units
• BOSS package manager configuration files
• Web frameworks: Delphi MVC Framework, Horse, WebBroker, WiRL
• Indy TIdHTTP for manual exposition examples
• Prometheus text format as the output protocol