prometheus / prometheus/client_rust

Footgun when retrieving multiple metrics from the same family

Open
#300 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
606
Forks
113
Avg merge
9h 7m
Merged PRs (30d)
8

Description

Another footgun that I discovered the hard way (production) is to get_or_create multiple metrics within a family and assign to multiple variables and then deadlock. It isn't apparent that a lock is held and returned. Perhaps renaming get_or_create to get_or_create_with_lock would be an improvement, or provide a closure to get_or_create.

This then keeps the scope of the lock to local.

I realise there is Rustdoc on this, but that's easy to be missed.

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 Rust API and Rustdoc for get_or_create, then reproduce the reported deadlock when retrieving multiple metrics from one family. Compare the proposed naming and closure approaches, including their API impact. Done means the lock scope is explicit and the multiple-metric use case no longer deadlocks.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
observability
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.