prometheus / prometheus/client_python

Increase the usage of augmented assignment statements

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

Nobody has claimed this yet.

Dominant language
Python
Stars
4.4k
Forks
876
Avg merge
8d 4h
Merged PRs (30d)
1

Description

👀 Some source code analysis tools can help to find opportunities for improving software components.
💭 I propose to increase the usage of augmented assignment statements accordingly.

diff --git a/prometheus_client/exposition.py b/prometheus_client/exposition.py
index e374144..1c10055 100644
--- a/prometheus_client/exposition.py
+++ b/prometheus_client/exposition.py
@@ -179,9 +179,9 @@ def generate_latest(registry=REGISTRY):
             mtype = metric.type
             # Munging from OpenMetrics into Prometheus format.
             if mtype == 'counter':
-                mname = mname + '_total'
+                mname += '_total'
             elif mtype == 'info':
-                mname = mname + '_info'
+                mname += '_info'
                 mtype = 'gauge'
             elif mtype == 'stateset':
                 mtype = 'gauge'

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 in prometheus_client/exposition.py at generate_latest and review the three metric-type branches shown in the issue. Make the targeted augmented-assignment changes and confirm that the generated Prometheus output remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
observability
Issue type
Refactor
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.