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

[CORE-711] Always log market id when pair information is missing. (backport #694) #700

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions protocol/daemons/pricefeed/metrics/market_pairs.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package metrics

import (
"fmt"
"sync"

"github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/client/types"
Expand All @@ -19,7 +20,7 @@ var (
// these market pairs are very unlikely to be updated, so this solution, while not perfect, is
// acceptable for the use case of logging/metrics in order to manage code complexity.
marketToPair = map[types.MarketId]string{}
// lock syncronizes access to the marketToPair map.
// lock synchronizes access to the marketToPair map.
lock sync.Mutex
)

Expand All @@ -39,7 +40,7 @@ func GetMarketPairForTelemetry(marketId types.MarketId) string {

marketPair, exists := marketToPair[marketId]
if !exists {
return INVALID
return fmt.Sprintf("invalid_id:%v", marketId)
}

return marketPair
Expand Down
2 changes: 1 addition & 1 deletion protocol/daemons/pricefeed/metrics/market_pairs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestGetMarketPairForTelemetry(t *testing.T) {
},
"absent id": {
marketId: 99,
expected: "INVALID",
expected: "invalid_id:99",
},
}
metrics.SetMarketPairForTelemetry(1, "BTC-USD")
Expand Down
3 changes: 2 additions & 1 deletion protocol/daemons/pricefeed/metrics/metrics_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package metrics_test

import (
"fmt"
"testing"

"github.com/dydxprotocol/v4-chain/protocol/testutil/daemons/pricefeed/exchange_config"
Expand All @@ -27,7 +28,7 @@ func TestGetLabelForMarketIdSuccess(t *testing.T) {
func TestGetLabelForMarketIdFailure(t *testing.T) {
require.Equal(
t,
metrics.GetLabelForStringValue(metrics.MarketId, pricefeedmetrics.INVALID),
metrics.GetLabelForStringValue(metrics.MarketId, fmt.Sprintf("invalid_id:%d", INVALID_ID)),
pricefeedmetrics.GetLabelForMarketId(INVALID_ID),
)
}
Expand Down
Loading