OEV-1414 Add feedAddress to meta metrics#502
Conversation
|
There was a problem hiding this comment.
Pull request overview
This PR updates Meta client OTEL metrics to include a per-feed/per-contract address dimension, improving observability by allowing status/latency/errors/bid counts to be segmented by destination.
Changes:
- Added a new
feedAddressparameter to MetaMetrics recording methods and propagated it through MetaClient call sites. - Attached an address attribute to Meta-related metrics (status code, latency, bids received, and error counters).
- Updated unit tests to cover the new method signatures.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| pkg/txm/clientwrappers/dualbroadcast/meta_metrics.go | Adds an address attribute to Meta metrics and updates metric recording method signatures. |
| pkg/txm/clientwrappers/dualbroadcast/meta_metrics_test.go | Updates tests to call the updated MetaMetrics methods with a feed address argument. |
| pkg/txm/clientwrappers/dualbroadcast/meta_client.go | Passes an address through when recording Meta metrics during request/operation lifecycle. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| func (m *MetaMetrics) RecordStatusCode(ctx context.Context, statusCode int, feedAddress string) { | ||
| m.statusCodeCounter.Add(ctx, 1, | ||
| metric.WithAttributes( | ||
| attribute.String("chainID", m.chainID), | ||
| attribute.String("statusCode", strconv.Itoa(statusCode)), | ||
| attribute.String("feedAddress", strings.ToLower(feedAddress)), |
There was a problem hiding this comment.
You can pass feedAddress as a common.Address param and avoid spamming txMeta.FwdrDestAddress.Hex() in the caller and also avoid strings.ToLower(feedAddress) since all callers will be consistent with .Hex() call
| func (m *MetaMetrics) RecordStatusCode(ctx context.Context, statusCode int, feedAddress string) { | |
| m.statusCodeCounter.Add(ctx, 1, | |
| metric.WithAttributes( | |
| attribute.String("chainID", m.chainID), | |
| attribute.String("statusCode", strconv.Itoa(statusCode)), | |
| attribute.String("feedAddress", strings.ToLower(feedAddress)), | |
| func (m *MetaMetrics) RecordStatusCode(ctx context.Context, statusCode int, feedAddress common.Address) { | |
| m.statusCodeCounter.Add(ctx, 1, | |
| metric.WithAttributes( | |
| attribute.String("chainID", m.chainID), | |
| attribute.String("statusCode", strconv.Itoa(statusCode)), | |
| attribute.String("feedAddress", feedAddress.Hex()), |
There was a problem hiding this comment.
Ah yes, passing address is a lot nicer 👍
Will update.
also avoid strings.ToLower(feedAddress) since all callers will be consistent with .Hex() call
WDYM with this?
The toLower call is to prevent mixed-case addresses from being labels in PromQL, because PromQL doesn't have a lowercase function, making it impossible to match a mixed-case address with a lowercased address.
| tx.AttemptCount == 1 && !tx.IsPurgeable { | ||
| // Auction & Validate | ||
| meta, err := a.SendRequest(ctx, tx, attempt, *meta.DualBroadcastParams, tx.ToAddress) | ||
| meta, err := a.SendRequest(ctx, tx, attempt, txMeta, tx.ToAddress) |
There was a problem hiding this comment.
SendRequest only has one caller. It would be better if we explode the params and separate the DualBroadcastParams from the feedAddress. We can pass both independently keep the DualBroadcastParams as is and just pass feeAddress to the underlying callers. This avoid spamming *txMeta.FwdrDestAddress .
| meta, err := a.SendRequest(ctx, tx, attempt, txMeta, tx.ToAddress) | |
| meta, err := a.SendRequest(ctx, tx, attempt, *meta.DualBroadcastParams, tx.ToAddress, feedAddress) |
There was a problem hiding this comment.
Makes sense, updated
| if txMeta == nil || txMeta.FwdrDestAddress == nil || txMeta.DualBroadcastParams == nil { | ||
| return nil, errors.New("missing tx meta fields for dual broadcast request") | ||
| } |
There was a problem hiding this comment.
I would consider this redundant as we make the same check right before we call SendRequest.
There was a problem hiding this comment.
And there's only one caller, fair
| txMeta, err := tx.GetMeta() | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| // #1 | ||
| if meta != nil && | ||
| meta.DualBroadcast != nil && *meta.DualBroadcast && meta.DualBroadcastParams != nil && meta.FwdrDestAddress != nil && | ||
| if txMeta != nil && | ||
| txMeta.DualBroadcast != nil && *txMeta.DualBroadcast && txMeta.DualBroadcastParams != nil && txMeta.FwdrDestAddress != nil && |
There was a problem hiding this comment.
No need to rename this local variable, meta seems clear enough.
There was a problem hiding this comment.
Agree on its own, but consider line 207, there we reassign/shadow meta to a different variable, so it changes from TxMeta struct to a MetacalldataResponse struct.
This makes it impossible to call meta.FwdrDestAddress after line 207.
There was a problem hiding this comment.
Ok makes sense. We could also rename the returned value of SendRequest since meta is now used inside here, whatever feels best.
There was a problem hiding this comment.
Good point, I've opted for renaming the returned value from SendRequest instead
| m.latencyHistogram.Record(ctx, duration.Milliseconds(), | ||
| metric.WithAttributes( | ||
| attribute.String("chainID", m.chainID), | ||
| attribute.String("feedAddress", strings.ToLower(feedAddress.Hex())), |
There was a problem hiding this comment.
I would consider not using strings.ToLower as this forces other callers to ensure they call it in other places to stay consistent. If they miss it, then some attributes will be upper case and other lower case. Just by calling .Hex() , which is required by the attribute param, we ensure everyone does the same.
There was a problem hiding this comment.
The toLower call is to prevent mixed-case addresses from being labels in PromQL, because PromQL doesn't have a lowercase function, making it impossible to match a mixed-case address with a lowercased address.
We encountered this already in matching SDS metrics (lowercased addresses) with RDDPE metrics (checksummed addresses), see https://github.com/smartcontractkit/rdd-prometheus-exporter/pull/139.
There was a problem hiding this comment.
But Hex() doesn't return a random mixed case, it returns the EIP55-compliant hex string. Can't we use that standard for querying?
There was a problem hiding this comment.
True, that's likely better and more consistent. I'll have to update SDS for that
There was a problem hiding this comment.
Removed the lowercase here
What
Add feedAddress to meta client related metrics
Why
To improve observability