Skip to content

Conversation

tombrk
Copy link
Member

@tombrk tombrk commented Jun 13, 2025

Uses tooling from OTel (https://github.com/open-telemetry/weaver) to strongly schematize all metrics of blackbox_exporter.

This gives:

  • Type-safe client_golang constructors for all metrics that make are:
    • hard to mis-use (e.g. each label is a different type, to prevent ordering mismatch using the type system)
    • discoverable (IDE auto-complete, godoc)
  • Documentation (internal/metrics/metrics.md) that lists all metrics, labels and their respective possible values

I chose blackbox_exporter as a sufficiently simple target to try this approach and serve as a ground for future discussions around schematizing Prometheus metrics.

Templates for codegen are at https://github.com/sh0rez/promconv/tree/main/templates/registry/go

metric_name: blackbox_exporter_config_last_reload_successful
brief: "Blackbox exporter config loaded successfully"
instrument: "gauge"
unit: "1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You didn't get any warning from Weaver? This is not the correct Otel unit type I think (just curious)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a valid unit!

Instruments for utilization metrics (that measure the fraction out of a total) are dimensionless and SHOULD use the default unit 1 (the unity).
https://opentelemetry.io/docs/specs/semconv/general/metrics/#instrument-units

However, I still think its the wrong unit here, as it should be seconds lol

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

One thing I would ensure is to embed/import the generation in the Makefile and CI of this project, so those yamls and Go files don't diverge.

@bwplotka
Copy link
Member

NOTE: Current schema model is not great for changes later on without open-telemetry/opentelemetry-specification#4492 -- so we might want to be careful with committing to a certain yaml model.

@github-actions github-actions bot added the stale label Sep 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants