Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prometheus Metrics #113

Closed
wants to merge 9 commits into from
Closed

Conversation

Philip-21
Copy link

Pr fixes for #34

Creating prometheus instrumentation for FFEVM

Signed-off-by: Philip-21 <philipuzomaobiora@gmail.com>
@Philip-21 Philip-21 requested a review from a team as a code owner February 22, 2024 07:43
Signed-off-by: Philip-21 <philipuzomaobiora@gmail.com>
Signed-off-by: Philip-21 <philipuzomaobiora@gmail.com>
Copy link
Contributor

@Chengxuan Chengxuan left a comment

Choose a reason for hiding this comment

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

@Philip-21 thanks for looking at adding the metrics!

Instead of using the prometheus library directly, there is a standard util in firefly-common which can help organise metrics when it grows bigger. An example usage can be found here: https://github.com/hyperledger/firefly-transaction-manager/blob/main/internal/metrics/metrics.go

@Philip-21
Copy link
Author

Philip-21 commented Feb 23, 2024

@Philip-21 thanks for looking at adding the metrics!

Instead of using the prometheus library directly, there is a standard util in firefly-common which can help organise metrics when it grows bigger. An example usage can be found here: https://github.com/hyperledger/firefly-transaction-manager/blob/main/internal/metrics/metrics.go

Thanks for the feedback, will make necessary implementations

Signed-off-by: Philip-21 <philipuzomaobiora@gmail.com>
Signed-off-by: Philip-21 <philipuzomaobiora@gmail.com>
@Philip-21
Copy link
Author

Hey @Chengxuan please checkout the changes I have made, I made necessary adjustments for handling the metrics, my main issue is being able to configure the metrics server to run properly, I need your reviews on this please ?
I hope I'm doing the right thing👀

@Chengxuan
Copy link
Contributor

@Philip-21 Thanks for the update. I realised what I explained above wasn't very clear.

FFTM already has a metrics manager and I believe that metrics manager is the one that EVM connect should use for collecting metrics so that the custom metrics collected in EVM connect are served at the same metrics server as other metrics.

https://github.com/hyperledger/firefly-evmconnect/blob/main/cmd/evmconnect.go#L102 is where EVM connect uses FFTM to initialize the HTTP & metrics server.

There is already an example showing how Tx Handler registers and emits its custom metrics in https://github.com/hyperledger/firefly-transaction-manager/blob/main/internal/metrics/metrics.go through txHandlerMetricsManager.

Therefore, EVM connect could follow the same pattern. e.g. there can be a new evmMetricsManager, and a new interface
similar to https://github.com/hyperledger/firefly-transaction-manager/blob/main/pkg/txhandler/txhandler.go#L76

Signed-off-by: Philip-21 <philipuzomaobiora@gmail.com>
Signed-off-by: Philip-21 <philipuzomaobiora@gmail.com>
Signed-off-by: Philip-21 <philipuzomaobiora@gmail.com>
@Philip-21
Copy link
Author

Hey @Chengxuan I have created Evm handlers for handling and emitting metrics, Please have a look on how i defined them and configured them to run and initialize in the evmconnect.go file

Signed-off-by: Philip-21 <philipuzomaobiora@gmail.com>
@Chengxuan
Copy link
Contributor

Hi @Philip-21 , Thanks for giving it another try.

The MetricsRegistry that is hooked up with the API server (which is defined in FFTM code) is created in here: https://github.com/hyperledger/firefly-transaction-manager/blob/main/internal/metrics/metrics.go#L47.

Therefore, as a consumer of that library, FF evmconnect need to find a way to emit metrics using a MetricsManager that belongs to the MetricsRegistry defined in FFTM code.

In this PR, a new MetricsRegistry is created here but it's not hooked up with any API that is defined in FFTM code, so the collected metrics will be in an isolated registry and won't be exposed to any REST API endpoint.

@Philip-21
Copy link
Author

Philip-21 commented Mar 28, 2024

Hi @Philip-21 , Thanks for giving it another try.

The MetricsRegistry that is hooked up with the API server (which is defined in FFTM code) is created in here: https://github.com/hyperledger/firefly-transaction-manager/blob/main/internal/metrics/metrics.go#L47.

Therefore, as a consumer of that library, FF evmconnect need to find a way to emit metrics using a MetricsManager that belongs to the MetricsRegistry defined in FFTM code.

In this PR, a new MetricsRegistry is created here but it's not hooked up with any API that is defined in FFTM code, so the collected metrics will be in an isolated registry and won't be exposed to any REST API endpoint.

Thanks for the feedback and the breakdown, i will make adjustments

@Philip-21
Copy link
Author

Philip-21 commented Mar 29, 2024

I've ben unable to import the metrics registry from the fftm to be used for the Evmmetrics manager, since the metric registry for the fftm is located in the internal package i am unable to import and use it, leads to an import error , i am still figuring out a better approach to this, please what could be the best way

@Chengxuan
Copy link
Contributor

Chengxuan commented Apr 2, 2024

@Philip-21 one option is to use a public interface and implement the internal object with the required methods then pass through it to evmconnect during initialization. But other proposals are welcome as well.

If you decided to go with a public interface, you might want to take a look at https://github.com/hyperledger/firefly-transaction-manager/blob/543a25094959495265d042083db8120169fcecf2/pkg/txhandler/txhandler.go#L76 , I feel that interface is generic enough to be re-used as it doesn't contain transaction handler specific knowledge.

@Philip-21
Copy link
Author

Hey @Chengxuan , I think its best we use the txhandler.TransactionMetrics, for handling various prometheus metrics methods. instead of creating EvmTransactionHandlerMetrics.

But does txhandler.TransactionMetrics have a way of swapping signature contents which will initialize the Prometheus Api instance defined in FFTM code.

@Chengxuan
Copy link
Contributor

Hi @Philip-21 here is an example of adding event metrics in FFTM repo: hyperledger/firefly-transaction-manager#121 which could be a useful learning point for adding metrics for EVM connect.

@Philip-21
Copy link
Author

Hi @Philip-21 here is an example of adding event metrics in FFTM repo: hyperledger/firefly-transaction-manager#121 which could be a useful learning point for adding metrics for EVM connect.

Alright looking through ........

@Chengxuan
Copy link
Contributor

Closing this PR for now as it seems the work has been parked. Please feel free to re-open when you continue @Philip-21 👍

@Chengxuan Chengxuan closed this Aug 30, 2024
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