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

collectors: add inbound fee metric #54

Merged
merged 3 commits into from
Jul 11, 2020

Conversation

joostjager
Copy link
Contributor

@joostjager joostjager commented Jul 2, 2020

This PR adds a cumulative metric for the routing fee that senders need to pay to the last hop to reach the node that is being monitored. It is an indication of the quality of inbound liquidity.

Example output to Prometheus:

# HELP inbound_fee fee charged for forwarding to this node
# TYPE inbound_fee gauge
inbound_fee{amount="0.001 BTC"} 4e-05
inbound_fee{amount="0.002 BTC"} 4.5e-05
inbound_fee{amount="0.004 BTC"} 4.75e-05
inbound_fee{amount="0.008 BTC"} 7.75e-05
inbound_fee{amount="0.016 BTC"} 0.00030125
inbound_fee{amount="0.032 BTC"} 0.000650625
inbound_fee{amount="0.064 BTC"} 0.00082515625
inbound_fee{amount="0.128 BTC"} 0.000912578125

When used in a primary-gateway setup, it is typically required to ignore the internal channels for this metric. This can be indicated by passing the pubkey of the primary node via the --primarynode command line flag.

collectors/channel_collector_test.go Show resolved Hide resolved
collectors/channels_collector.go Outdated Show resolved Hide resolved
collectors/channels_collector.go Show resolved Hide resolved
collectors/channels_collector.go Outdated Show resolved Hide resolved
collectors/channels_collector.go Outdated Show resolved Hide resolved
collectors/channels_collector.go Show resolved Hide resolved
collectors/channels_collector.go Outdated Show resolved Hide resolved
collectors/channels_collector.go Outdated Show resolved Hide resolved
collectors/channels_collector.go Show resolved Hide resolved
collectors/channels_collector.go Outdated Show resolved Hide resolved
Copy link
Member

@bhandras bhandras left a comment

Choose a reason for hiding this comment

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

LGTM, I think this is a nice metric to help evaluate inbound quality.

@@ -17,3 +17,5 @@ user-config/*
!user-config/.gitkeep
nginx/etc/ssl/*
nginx/etc/.htpasswd

cmd/lndmon/lndmon
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: newline?

Copy link
Contributor Author

@joostjager joostjager Jul 2, 2020

Choose a reason for hiding this comment

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

the idea was to separate our binaries from other peoples files to ignore

Copy link
Contributor

Choose a reason for hiding this comment

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

no I meant one after cmd/lndmon/lndmon but non-blocking

"github.com/stretchr/testify/require"
)

type inboundFeeTestCase struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this struct? Couldn't we just have testCases=[]struct{...} then pass 3 params to testGetInboundFee? I don't think the indenting would be too bad.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not three, but five in that case. Also the remotePolicies and remoteBalances. Sure you want that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did move the test cases into the function.

collectors/channel_collector_test.go Show resolved Hide resolved
// total amount. Each iteration, the best channel for that shard is
// selected based on the specific fee.
amountRemaining := amt
for amountRemaining > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this an accurate reflection of our available inbound if we don't limit the number of shards? Maybe I'm missing it in here, but it seems like we should be taking that into account, because they can't actually reach us if we exceed shard max.

Copy link
Contributor Author

@joostjager joostjager Jul 2, 2020

Choose a reason for hiding this comment

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

Max shards is configurable, so we can't make assumptions on that.

Copy link
Contributor

Choose a reason for hiding this comment

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

lnd's default is probably a fair representation of reality, but we can always come back and refine.

Copy link
Contributor

@carlaKC carlaKC left a comment

Choose a reason for hiding this comment

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

LGTM! Nice to start surfacing information like this 📈

@joostjager
Copy link
Contributor Author

joostjager commented Jul 3, 2020

Found one nil pointer bug while testing on staging, fixed.

for _, collectorFunc := range collectors {
err := prometheus.Register(collectorFunc(p.lnd))
collectors := []prometheus.Collector{
NewChainCollector(p.lnd),
Copy link
Member

Choose a reason for hiding this comment

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

Why's this preferable to the init functions?

Copy link
Contributor Author

@joostjager joostjager Jul 7, 2020

Choose a reason for hiding this comment

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

There is an initialization parameter now that comes from the config. (primary pub key)

Copy link
Member

Choose a reason for hiding this comment

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

Needs to be updated now after the merge of the get info collector. The main reason why the existing structure was used was so we'd just need to add the new collector in the file it was created in, rather than here as well. In the end something needs to be updated either way though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rebased

@Roasbeef Roasbeef merged commit 9e8c887 into lightninglabs:master Jul 11, 2020
@joostjager
Copy link
Contributor Author

I wanted to do a bit more testing before merge and also update the json dashboard files. But can do that in a follow-up PR.

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