Skip to content

Conversation

@guillaumemichel
Copy link
Contributor

Adding two metric counters:

  • number of keys provided so far (each key is expected to be provided once)
  • number of keys reprovided so far (each key is expected to be periodically reprovided)

@guillaumemichel guillaumemichel requested a review from a team as a code owner June 13, 2025 07:31
@guillaumemichel guillaumemichel requested a review from lidel June 13, 2025 07:34
Comment on lines 121 to 122
provideCounter: metrics.New("ipfs.boxo.provider.provideCount", "Number of provides since node is running").Counter(),
reprovideCounter: metrics.New("ipfs.boxo.provider.reprovideCount", "Number of reprovides since node is running").Counter(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Regarding the metric name... I believe all metrics in boxo use metrics.NewCtx and figure out their metric prefix from a context.

In HTTP I hardcoded that prefix though, which probably wasn't intelligent:

ctx := imetrics.CtxScope(context.Background(), "exchange_httpnet")

If you can get a context, then it doesn't hurt using it. And otherwise, the metric name would, based on prior art, be provider_provide_count and reprovider_reprovide_count.

(I think, I'm not very sure about this. I am more sure that the ipfs.boxo prefix is probably not part of any existing metric).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the heads up. I got confused with the doc.

I followed the same approach as you did in

ctx := imetrics.CtxScope(context.Background(), "exchange_httpnet")

@gammazero gammazero merged commit 8b23fbb into main Jun 16, 2025
14 checks passed
@gammazero gammazero deleted the reprovide-metrics branch June 16, 2025 21:34
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.

4 participants