Liking cljdoc? Tell your friends :D

wagoe.observability.metrics.ports

Port definitions for metrics infrastructure.

This namespace defines the protocols that metrics adapters must implement, providing a clean abstraction over different metrics backends (Prometheus, Datadog, in-memory registries, etc.).

Core protocols:

  • IMetricsRegistry: Metric registration and management
  • IMetricsEmitter: Metric value emission and updates
  • IMetricsExporter: Metric export and serialization

Metric Types:

  • Counter: Monotonically increasing values (requests, errors)
  • Gauge: Point-in-time values that can go up/down (active users, memory)
  • Histogram: Distribution of values with configurable buckets (latency)
  • Summary: Distribution statistics (quantiles, avg, etc.)
Port definitions for metrics infrastructure.

This namespace defines the protocols that metrics adapters must implement,
providing a clean abstraction over different metrics backends (Prometheus,
Datadog, in-memory registries, etc.).

Core protocols:
- IMetricsRegistry: Metric registration and management
- IMetricsEmitter: Metric value emission and updates
- IMetricsExporter: Metric export and serialization

Metric Types:
- Counter: Monotonically increasing values (requests, errors)
- Gauge: Point-in-time values that can go up/down (active users, memory)
- Histogram: Distribution of values with configurable buckets (latency)
- Summary: Distribution statistics (quantiles, avg, etc.)
raw docstring

IMetricsConfigcljprotocol

Protocol for runtime metrics configuration changes.

This allows for dynamic adjustment of metrics behavior without requiring application restart.

Protocol for runtime metrics configuration changes.

This allows for dynamic adjustment of metrics behavior without
requiring application restart.

disable-metric!clj

(disable-metric! this metric-name)

Disable collection for a specific metric.

Disabled metrics will be no-ops for performance.

Parameters: metric-name - Keyword metric name

Returns: Boolean indicating if metric was found and disabled

Disable collection for a specific metric.

Disabled metrics will be no-ops for performance.

Parameters:
  metric-name - Keyword metric name

Returns:
  Boolean indicating if metric was found and disabled

enable-metric!clj

(enable-metric! this metric-name)

Enable collection for a specific metric.

Parameters: metric-name - Keyword metric name

Returns: Boolean indicating if metric was found and enabled

Enable collection for a specific metric.

Parameters:
  metric-name - Keyword metric name

Returns:
  Boolean indicating if metric was found and enabled

get-default-tagsclj

(get-default-tags this)

Get current default tags.

Returns: Map of default tag keys/values

Get current default tags.

Returns:
  Map of default tag keys/values

get-export-intervalclj

(get-export-interval this)

Get current export interval.

Returns: Current interval in milliseconds

Get current export interval.

Returns:
  Current interval in milliseconds

metric-enabled?clj

(metric-enabled? this metric-name)

Check if a metric is currently enabled.

Parameters: metric-name - Keyword metric name

Returns: Boolean indicating if metric is enabled

Check if a metric is currently enabled.

Parameters:
  metric-name - Keyword metric name

Returns:
  Boolean indicating if metric is enabled

set-default-tags!clj

(set-default-tags! this tags)

Set default tags applied to all metrics.

Parameters: tags - Map of tag keys/values

Returns: Previous default tags map

Set default tags applied to all metrics.

Parameters:
  tags - Map of tag keys/values

Returns:
  Previous default tags map

set-export-interval!clj

(set-export-interval! this interval-ms)

Set the metrics export interval for push-based systems.

Parameters: interval-ms - Export interval in milliseconds

Returns: Previous interval in milliseconds

Set the metrics export interval for push-based systems.

Parameters:
  interval-ms - Export interval in milliseconds

Returns:
  Previous interval in milliseconds
sourceraw docstring

IMetricsEmittercljprotocol

Protocol for emitting metric values.

This is the interface used by application code to record metric values. Implementation handles proper tagging, batching, and backend communication.

Protocol for emitting metric values.

This is the interface used by application code to record metric values.
Implementation handles proper tagging, batching, and backend communication.

inc-counter!clj

(inc-counter! this metric-handle)
(inc-counter! this metric-handle value)
(inc-counter! this metric-handle value tags)

Increment a counter metric.

Parameters: metric-handle - Handle returned from register-counter! value - Optional increment amount (default: 1) tags - Optional additional tags for this measurement

Returns: nil (side effect only)

Increment a counter metric.

Parameters:
  metric-handle - Handle returned from register-counter!
  value        - Optional increment amount (default: 1)
  tags         - Optional additional tags for this measurement

Returns:
  nil (side effect only)

observe-histogram!clj

(observe-histogram! this metric-handle value)
(observe-histogram! this metric-handle value tags)

Record a value in a histogram metric.

Parameters: metric-handle - Handle returned from register-histogram! value - Numeric value to observe tags - Optional additional tags for this measurement

Returns: nil (side effect only)

Record a value in a histogram metric.

Parameters:
  metric-handle - Handle returned from register-histogram!
  value         - Numeric value to observe
  tags          - Optional additional tags for this measurement

Returns:
  nil (side effect only)

observe-summary!clj

(observe-summary! this metric-handle value)
(observe-summary! this metric-handle value tags)

Record a value in a summary metric.

Parameters: metric-handle - Handle returned from register-summary! value - Numeric value to observe tags - Optional additional tags for this measurement

Returns: nil (side effect only)

Record a value in a summary metric.

Parameters:
  metric-handle - Handle returned from register-summary!
  value         - Numeric value to observe
  tags          - Optional additional tags for this measurement

Returns:
  nil (side effect only)

set-gauge!clj

(set-gauge! this metric-handle value)
(set-gauge! this metric-handle value tags)

Set a gauge metric to a specific value.

Parameters: metric-handle - Handle returned from register-gauge! value - Numeric value to set tags - Optional additional tags for this measurement

Returns: nil (side effect only)

Set a gauge metric to a specific value.

Parameters:
  metric-handle - Handle returned from register-gauge!
  value         - Numeric value to set
  tags          - Optional additional tags for this measurement

Returns:
  nil (side effect only)

time-histogram!clj

(time-histogram! this metric-handle f)
(time-histogram! this metric-handle tags f)

Time the execution of function f and record in histogram.

Parameters: metric-handle - Handle returned from register-histogram! tags - Optional additional tags for this measurement f - Zero-argument function to time

Returns: Result of calling (f)

Time the execution of function f and record in histogram.

Parameters:
  metric-handle - Handle returned from register-histogram!
  tags          - Optional additional tags for this measurement
  f             - Zero-argument function to time

Returns:
  Result of calling (f)

time-summary!clj

(time-summary! this metric-handle f)
(time-summary! this metric-handle tags f)

Time the execution of function f and record in summary.

Parameters: metric-handle - Handle returned from register-summary! tags - Optional additional tags for this measurement f - Zero-argument function to time

Returns: Result of calling (f)

Time the execution of function f and record in summary.

Parameters:
  metric-handle - Handle returned from register-summary!
  tags          - Optional additional tags for this measurement
  f             - Zero-argument function to time

Returns:
  Result of calling (f)
sourceraw docstring

IMetricsExportercljprotocol

Protocol for exporting metrics data.

This handles serialization and export of accumulated metrics data to external systems (Prometheus endpoint, Datadog agent, etc.)

Protocol for exporting metrics data.

This handles serialization and export of accumulated metrics data
to external systems (Prometheus endpoint, Datadog agent, etc.)

export-metricclj

(export-metric this metric-name format)

Export a specific metric in the specified format.

Parameters: metric-name - Keyword name of metric to export format - Keyword format (:prometheus :json :datadog :openmetrics)

Returns: String representation of metric in requested format

Export a specific metric in the specified format.

Parameters:
  metric-name - Keyword name of metric to export
  format      - Keyword format (:prometheus :json :datadog :openmetrics)

Returns:
  String representation of metric in requested format

export-metricsclj

(export-metrics this format)

Export all metrics in the specified format.

Parameters: format - Keyword format (:prometheus :json :datadog :openmetrics)

Returns: String representation of metrics in requested format

Export all metrics in the specified format.

Parameters:
  format - Keyword format (:prometheus :json :datadog :openmetrics)

Returns:
  String representation of metrics in requested format

flush!clj

(flush! this)

Force flush of any buffered metrics data.

This ensures all pending metrics are sent to external systems. Typically called during application shutdown.

Returns: nil (side effect only)

Force flush of any buffered metrics data.

This ensures all pending metrics are sent to external systems.
Typically called during application shutdown.

Returns:
  nil (side effect only)

get-metric-valuesclj

(get-metric-values this metric-name)

Get raw metric values for a specific metric.

Parameters: metric-name - Keyword name of metric

Returns: Map with metric values and metadata: {:type :counter :value 42 :tags {:method 'GET' :status '200'} :timestamp 1625097600000}

Get raw metric values for a specific metric.

Parameters:
  metric-name - Keyword name of metric

Returns:
  Map with metric values and metadata:
  {:type :counter
   :value 42
   :tags {:method 'GET' :status '200'}
   :timestamp 1625097600000}

reset-metrics!clj

(reset-metrics! this)

Reset all metrics to their initial state.

Note: This is primarily for testing. Production systems should use metric TTL or external aggregation for metric lifecycle.

Returns: nil (side effect only)

Reset all metrics to their initial state.

Note: This is primarily for testing. Production systems should
use metric TTL or external aggregation for metric lifecycle.

Returns:
  nil (side effect only)
sourceraw docstring

IMetricsRegistrycljprotocol

Core metrics registry for managing metric definitions.

The registry tracks metric metadata, validates operations, and provides a central catalog of all metrics in the system.

Core metrics registry for managing metric definitions.

The registry tracks metric metadata, validates operations, and provides
a central catalog of all metrics in the system.

get-metricclj

(get-metric this name)

Get a specific metric by name.

Parameters: name - Keyword metric name

Returns: Metric description map or nil if not found

Get a specific metric by name.

Parameters:
  name - Keyword metric name

Returns:
  Metric description map or nil if not found

list-metricsclj

(list-metrics this)

Get all registered metrics.

Returns: Vector of maps describing each metric: [{:name :http.requests :type :counter :description 'HTTP requests received' :tags {:service 'wagoe'} :handle ...}]

Get all registered metrics.

Returns:
  Vector of maps describing each metric:
  [{:name :http.requests
    :type :counter
    :description 'HTTP requests received'
    :tags {:service 'wagoe'}
    :handle ...}]

register-counter!clj

(register-counter! this name description tags)

Register a new counter metric.

Parameters: name - Keyword metric name (e.g. :http.requests) description - String description for metric tags - Map of default tags to apply to all values

Returns: Metric handle/identifier for use with IMetricsEmitter

Register a new counter metric.

Parameters:
  name        - Keyword metric name (e.g. :http.requests)
  description - String description for metric
  tags        - Map of default tags to apply to all values

Returns:
  Metric handle/identifier for use with IMetricsEmitter

register-gauge!clj

(register-gauge! this name description tags)

Register a new gauge metric.

Parameters: name - Keyword metric name (e.g. :users.active) description - String description for metric tags - Map of default tags to apply to all values

Returns: Metric handle/identifier for use with IMetricsEmitter

Register a new gauge metric.

Parameters:
  name        - Keyword metric name (e.g. :users.active)
  description - String description for metric
  tags        - Map of default tags to apply to all values

Returns:
  Metric handle/identifier for use with IMetricsEmitter

register-histogram!clj

(register-histogram! this name description buckets tags)

Register a new histogram metric.

Parameters: name - Keyword metric name (e.g. :http.request.duration) description - String description for metric buckets - Vector of numeric bucket boundaries tags - Map of default tags to apply to all values

Returns: Metric handle/identifier for use with IMetricsEmitter

Register a new histogram metric.

Parameters:
  name        - Keyword metric name (e.g. :http.request.duration)
  description - String description for metric
  buckets     - Vector of numeric bucket boundaries
  tags        - Map of default tags to apply to all values

Returns:
  Metric handle/identifier for use with IMetricsEmitter

register-summary!clj

(register-summary! this name description quantiles tags)

Register a new summary metric.

Parameters: name - Keyword metric name (e.g. :db.query.duration) description - String description for metric quantiles - Vector of quantile values [0.5 0.95 0.99] tags - Map of default tags to apply to all values

Returns: Metric handle/identifier for use with IMetricsEmitter

Register a new summary metric.

Parameters:
  name        - Keyword metric name (e.g. :db.query.duration)
  description - String description for metric
  quantiles   - Vector of quantile values [0.5 0.95 0.99]
  tags        - Map of default tags to apply to all values

Returns:
  Metric handle/identifier for use with IMetricsEmitter

unregister!clj

(unregister! this name)

Remove a metric from the registry.

Parameters: name - Keyword metric name to remove

Returns: Boolean indicating if metric was found and removed

Remove a metric from the registry.

Parameters:
  name - Keyword metric name to remove

Returns:
  Boolean indicating if metric was found and removed
sourceraw docstring

incrementclj

(increment _metrics-collector _metric-name _tags)

Convenience function for incrementing counters. For now, this is a no-op placeholder until metrics infrastructure is set up.

Convenience function for incrementing counters.
For now, this is a no-op placeholder until metrics infrastructure is set up.
sourceraw docstring

observeclj

(observe _metrics-collector _metric-name _value _tags)

Convenience function for observing histogram/summary values. For now, this is a no-op placeholder until metrics infrastructure is set up.

Convenience function for observing histogram/summary values.
For now, this is a no-op placeholder until metrics infrastructure is set up.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close