Skip to content

add metrics to engineAPI#4183

Draft
advaita-saha wants to merge 2 commits into
masterfrom
measure-api
Draft

add metrics to engineAPI#4183
advaita-saha wants to merge 2 commits into
masterfrom
measure-api

Conversation

@advaita-saha
Copy link
Copy Markdown
Contributor

No description provided.

@advaita-saha advaita-saha requested a review from tersec April 27, 2026 12:32

{.push raises: [].}

declareGauge nec_engine_api_request_duration_ms,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

time metrics should always be counters that accumulate total time, else a fast call will overwrite a slow call

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

also, we typically use toFloatSeconds for this kind of metric

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

well the purpose of adding the metrics to engineAPI for now is to detect the exact scenarios which causes the fCU & getPayload call to take longer than usual, which inturn causes sometimes a missed proposal or orphaned block

So for this detection, getting the average time won't really help. So I went with declareGauge for now

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Example of spikes which I want to identify and debug
Screenshot from 2026-04-27 18-23-31

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

getting the average time

a counter gives cumulative time - if one api request takes 10s and the other takes 2s, the counter will show 12 while the gauge shows 2. You've lost the 10 and the graph will be missing information.

In the case that you call the metrics api often enough, the two are same but if you call it less frequently, a counter loses less information.

@advaita-saha advaita-saha marked this pull request as draft April 27, 2026 13:16
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