open-telemetry / open-telemetry/opentelemetry-cpp

Prometheus exporter: Add text-based tests

Open
#2,338 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Stale triage/accepted
Dominant language
C++
Stars
1.4k
Forks
632
Avg merge
1d 13h
Merged PRs (30d)
75

Description

Improve testing of the Prometheus exporter by comparing the serialized output with expectations.

In opentelemetry-go, tests are compared with the contents of a test file, such as https://github.com/open-telemetry/opentelemetry-go/blob/main/exporters/prometheus/testdata/gauge.txt

This makes it easy for anyone familiar with prometheus to determine if the test is producing the expected output, and clearly highlights any breaking changes to the final text format produced by the exporter. This is possible because prometheus does not include timestamps on metrics, making it possible to match the serialized output exactly on test runs.

I believe this could be accomplished by invoking Serialize on the produced metric families.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Prometheus exporter tests and reviewing the linked Serialize implementation in prometheus-cpp's core/src/text_serializer.cc. Compare serialized metric-family output against text fixtures modeled on the opentelemetry-go gauge.txt example. Done means the exporter tests verify exact text output and expose format changes clearly.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, prometheus
Domain
observability, testing-qa
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.