This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: stats API (stats.bitswap and stats.repo) #1198
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,22 +16,22 @@ module.exports = { | |
throw err | ||
} | ||
|
||
stats.Wantlist = stats.Wantlist || [] | ||
stats.Wantlist = stats.Wantlist.map((entry) => { | ||
stats.wantlist = stats.wantlist || [] | ||
stats.wantlist = stats.wantlist.map((entry) => { | ||
const buf = Buffer.from(entry.cid.hash.data) | ||
const cid = new CID(entry.cid.version, entry.cid.codec, buf) | ||
return cid.toBaseEncodedString() | ||
}) | ||
stats.Peers = stats.Peers || [] | ||
stats.peers = stats.peers || [] | ||
|
||
print(`bitswap status | ||
blocks received: ${stats.BlocksReceived} | ||
dup blocks received: ${stats.DupBlksReceived} | ||
dup data received: ${stats.DupDataReceived}B | ||
wantlist [${stats.Wantlist.length} keys] | ||
${stats.Wantlist.join('\n ')} | ||
partners [${stats.Peers.length}] | ||
${stats.Peers.join('\n ')}`) | ||
blocks received: ${stats.blocksReceived} | ||
dup blocks received: ${stats.dupBlksReceived} | ||
dup data received: ${stats.dupDataReceived}B | ||
wantlist [${stats.wantlist.length} keys] | ||
${stats.wantlist.join('\n ')} | ||
partners [${stats.peers.length}] | ||
${stats.peers.join('\n ')}`) | ||
}) | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After Rebase, enable the CLI Bitswap test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done and it works!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict' | ||
|
||
const print = require('../../utils').print | ||
|
||
module.exports = { | ||
command: 'stat', | ||
|
||
describe: 'Get stats for the currently used repo', | ||
|
||
builder: { | ||
human: { | ||
type: 'boolean', | ||
default: false | ||
} | ||
}, | ||
|
||
handler (argv) { | ||
argv.ipfs.repo.stat({human: argv.human}, (err, stats) => { | ||
if (err) { | ||
throw err | ||
} | ||
|
||
print(`repo status | ||
number of objects: ${stats.numObjects} | ||
repo size: ${stats.repoSize} | ||
repo path: ${stats.repoPath} | ||
version: ${stats.version} | ||
maximum storage: ${stats.storageMax}`) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
command: 'stats <command>', | ||
|
||
description: 'Query IPFS statistics.', | ||
|
||
builder (yargs) { | ||
return yargs.commandDir('stats') | ||
}, | ||
|
||
handler (argv) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use strict' | ||
|
||
const CID = require('cids') | ||
const print = require('../../utils').print | ||
|
||
module.exports = { | ||
command: 'bitswap', | ||
|
||
describe: 'Show some diagnostic information on the bitswap agent.', | ||
|
||
builder: {}, | ||
|
||
handler (argv) { | ||
argv.ipfs.stats.bitswap((err, stats) => { | ||
if (err) { | ||
throw err | ||
} | ||
|
||
stats.wantlist = stats.wantlist || [] | ||
stats.wantlist = stats.wantlist.map((entry) => { | ||
const buf = Buffer.from(entry.cid.hash.data) | ||
const cid = new CID(entry.cid.version, entry.cid.codec, buf) | ||
return cid.toBaseEncodedString() | ||
}) | ||
stats.peers = stats.peers || [] | ||
|
||
print(`bitswap status | ||
blocks received: ${stats.blocksReceived} | ||
dup blocks received: ${stats.dupBlksReceived} | ||
dup data received: ${stats.dupDataReceived}B | ||
wantlist [${stats.wantlist.length} keys] | ||
${stats.wantlist.join('\n ')} | ||
partners [${stats.peers.length}] | ||
${stats.peers.join('\n ')}`) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict' | ||
|
||
const print = require('../../utils').print | ||
|
||
module.exports = { | ||
command: 'repo', | ||
|
||
describe: 'Get stats for the currently used repo', | ||
|
||
builder: { | ||
human: { | ||
type: 'boolean', | ||
default: false | ||
} | ||
}, | ||
|
||
handler (argv) { | ||
argv.ipfs.stats.repo({human: argv.human}, (err, stats) => { | ||
if (err) { | ||
throw err | ||
} | ||
|
||
print(`repo status | ||
number of objects: ${stats.numObjects} | ||
repo size: ${stats.repoSize} | ||
repo path: ${stats.repoPath} | ||
version: ${stats.version} | ||
maximum storage: ${stats.storageMax}`) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'use strict' | ||
|
||
module.exports = function stats (self) { | ||
return { | ||
bitswap: require('./bitswap')(self).stat, | ||
repo: require('./repo')(self).stat | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why move these to the Graph section??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would agree if moved to the Node Management Section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's on the Node Management section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm, I got fooled twice by GH interface. all good :)