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

fix(metrics): use http user-agent if libp2p fails #47

Merged
merged 2 commits into from
Feb 3, 2025

Conversation

lidel
Copy link
Contributor

@lidel lidel commented Feb 2, 2025

This will correctly record agent version that ended up with libp2p identify error

Closes #45

@lidel lidel requested a review from aschmahmann February 2, 2025 00:23
acme/writer.go Outdated
}
// TODO: revisit once js0libp2p cleans up default user agents to something unique and not "libp2p/"
if strings.HasPrefix(agentVersion, "libp2p/") || strings.HasPrefix(agentVersion, "js-libp2p/") {
case strings.HasPrefix(agentVersion, "libp2p/") || strings.HasPrefix(agentVersion, "js-libp2p/"): // TODO: revisit once js0libp2p cleans up default user agents to something unique and not "libp2p/"
Copy link
Contributor Author

@lidel lidel Feb 2, 2025

Choose a reason for hiding this comment

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

@achingbrain do you remember how does HTTP User-Agent and libp2p identify's agentVersion look like in requests made by https://www.npmjs.com/package/@libp2p/auto-tls?

We use libp2p one on success, but want to fallback to User-Agent from http request if we could not do libp2p identify, and would like this PR to correctly identify @libp2p/auto-tls in both success and error scenarios.

(not blocking this PR, we can refine this later)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Filled #48 to figure it out without blocking this PR.

Copy link
Contributor

@achingbrain achingbrain Feb 3, 2025

Choose a reason for hiding this comment

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

We don't specify anything right now so it would probably fall back to the acme-client default settings.

Something like node-acme-client/5.4.0, I think. It would be better if it logged the js-libp2p version too.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or do you mean setting up the acme challenge response? Again, we just use the default so I think it just ends up as "node" currently.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

libp2p/js-libp2p#2932 + this PR will do the trick, thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd think about maybe doing a contains here rather than hasPrefix, the libp2p agent string is:

$libp2pVersion $platformVersion,

Helia does

$heliaVersion $libp2pVersion $platformVersion

@lidel lidel force-pushed the record-http-user-agent branch from 784b5fe to 7bb23dc Compare February 3, 2025 18:59
@lidel lidel merged commit b1e8aa5 into main Feb 3, 2025
4 checks passed
@lidel lidel deleted the record-http-user-agent branch February 3, 2025 19:04
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.

metrics: show libp2p probe errors per user agent
2 participants