Skip to content

tricoder: add prometheus compatible metrics http endpoint#5

Open
DhanasekaranBaskar wants to merge 5 commits intoCloud-Foundations:masterfrom
DhanasekaranBaskar:master
Open

tricoder: add prometheus compatible metrics http endpoint#5
DhanasekaranBaskar wants to merge 5 commits intoCloud-Foundations:masterfrom
DhanasekaranBaskar:master

Conversation

@DhanasekaranBaskar
Copy link

Summary

This PR adds a built-in text metrics exporter to tricorder, exposing all metrics via a new /prometheus-metrics/ HTTP endpoint. It also updates documentation headings to Go #-style sections.

Motivation

Tricorder currently exposes metrics via HTML, JSON, and Go RPC. This change extends tricorder’s functionality by introducing a text exposition–based metrics endpoint over HTTP, allowing external monitoring systems to scrape tricorder metrics directly without external adapters.

Key Changes

  • Text exporter

    • Derives metric names from tricorder paths (e.g. /foo/bar/bazfoo_bar_baz), lowercased and sanitized.
    • Infers counter vs gauge from metric name, unit, and kind:
      • *-total metrics, network stats under /sys/netif, and selected event-style metrics are treated as counters.
      • Memory capacity and usage metrics are forced to gauges.
    • Encodes units into metric names (e.g. _seconds, _bytes, _celsius, with _total for counters).
    • Normalizes time and duration values to seconds; PrometheusNumericValue exposes the same normalized values.
    • Handles metric kinds explicitly:
      • List metrics are skipped and not exported.
      • String, bool, and time kinds use dedicated encodings (*_info, *_bool_info, *_time_seconds).
      • All other supported kinds are exported via numeric encoding.
    • Exports distributions as histograms with sorted cumulative buckets and normalized units, plus _sum and _count.
  • Metric initialization

    • Uses Go-RPC-style metric representations (GoTime, GoDuration) via InitPromMetric / UpdatePromMetric, keeping the exporter independent of JSON encodings.
  • HTTP endpoint

    • New /prometheus-metrics/ endpoint registered on the default HTTP mux.
    • Gzip-enabled, correct content type, and consistent trailing-slash behavior.
  • Documentation

    • Updates major comment headings to Go #-style sections.
    • Notes availability of the new text metrics export.

Compatibility

This change is fully additive. Existing endpoints and APIs remain unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants