Skip to content

Conversation

@nguyer
Copy link
Contributor

@nguyer nguyer commented Mar 4, 2022

This PR introduces blockchain metrics for:

  • FireFly performing a blockchain transaction with a smart contract method
  • FireFly querying the blockchain with a smart contract method
  • Events emitted by a smart contract that FireFly is listening for

Each of these has two labels location and methodName for transactions/queries or signature (for events). The location is a blockchain specific appropriate string for describing where the event came from. The value of this label is
in the format of "<key1>=<value1>,<key2>=<value2>". For Ethereum, it is just address=<contract_address>.

Fabric metrics will also be added in a subsequent PR.

Resolves #559

nguyer added 2 commits March 4, 2022 09:20
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
@codecov-commenter
Copy link

codecov-commenter commented Mar 4, 2022

Codecov Report

Merging #584 (1a8bf1d) into main (06f0ed3) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main      #584   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          309       310    +1     
  Lines        18705     18763   +58     
=========================================
+ Hits         18705     18763   +58     
Impacted Files Coverage Δ
internal/blockchain/ethereum/ethereum.go 100.00% <100.00%> (ø)
internal/blockchain/fabric/fabric.go 100.00% <100.00%> (ø)
internal/events/batch_pin_complete.go 100.00% <100.00%> (ø)
internal/events/blockchain_event.go 100.00% <100.00%> (ø)
internal/events/token_pool_created.go 100.00% <100.00%> (ø)
internal/events/tokens_approved.go 100.00% <100.00%> (ø)
internal/events/tokens_transferred.go 100.00% <100.00%> (ø)
internal/metrics/contracts.go 100.00% <100.00%> (ø)
internal/metrics/metrics.go 100.00% <100.00%> (ø)
internal/metrics/prometheus.go 100.00% <100.00%> (ø)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 06f0ed3...1a8bf1d. Read the comment docs.

Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
Info JSONObject `json:"info,omitempty"`
Timestamp *FFTime `json:"timestamp,omitempty"`
TX TransactionRef `json:"tx"`
Location string `json:"-"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to avoid these?
e.g. only include them on blockchain.Event, rather than fftypes.BlockchainEvent which is an external API object.

If we keep them here, they definitely need comments to explain they aren't available.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Possibly. Let me try that.

nguyer added 2 commits March 21, 2022 10:01
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
@nguyer nguyer force-pushed the blockchain-metrics branch from 1a8bf1d to b4fde14 Compare March 21, 2022 15:02
@nguyer nguyer requested a review from nickgaski as a code owner March 21, 2022 15:02
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
if err := em.persistBlockchainEvent(ctx, chainEvent); err != nil {
return err
}
em.emitBlockchainEventMetric(*ev)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just wondering why the mem copy here, rather than a pass-by-reference?
I think the blockchain.Event structure is reasonably large.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I've adjusted this, thanks!

Copy link
Contributor

@peterbroadhurst peterbroadhurst left a comment

Choose a reason for hiding this comment

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

Changes look great thanks @nguyer
Marked approval with one minor efficiency comment to consider (passing &event.Event rather than event.Event)

Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
@nguyer nguyer merged commit 7c38c94 into hyperledger:main Mar 21, 2022
@nguyer nguyer deleted the blockchain-metrics branch March 21, 2022 18: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.

Add blockchain metrics to FireFly Core

3 participants