-
Notifications
You must be signed in to change notification settings - Fork 348
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
Added instrumentation for admin dashboard interface #245
Open
segphault
wants to merge
19
commits into
next
Choose a base branch
from
ryan_adminui
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,430
−121
Open
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
8ecbb1f
Added instrumentation for admin dashboard interface
6b7a48a
Added option for stats collection, disabled by default
bec43ce
Added admin user interface
d0da434
Moving config
dalanmiller 0732833
Pass Server instance to admin endpoints
ba722a0
Request tracking now captures site where request originated
99a594c
Incorporated Annie's design improvements into admin UI
4386dce
Merge branch 'ryan_adminui' of https://github.com/rethinkdb/horizon i…
4bceda1
Fixed broken styling
da71382
Refactored model and stubbed out data browser
2782596
Added rudimentary data browser
eb29385
Added styling for data browser prototype
c648d39
Refactored adminui to clean up model
e962a33
Added CSS helper and moved tree expander to its own template
faaad31
Added support for pagination
46121ea
Allow user to select a collection in the data browser
d3330e7
replace current websocket implementation with engine.io, made tests w…
flipace fa1d898
Merge branch 'next' into ryan_adminui
5b8eff3
Adjust client stat tracking for engine.io
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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
'use strict'; | ||
|
||
const r = require('rethinkdb'); | ||
|
||
const admin_db = r.db('horizon_internal'); | ||
const client_table = admin_db.table('stats_clients'); | ||
const request_table = admin_db.table('stats_requests'); | ||
|
||
class Admin { | ||
constructor(server) { | ||
this.server = server; | ||
} | ||
|
||
clear_tables() { | ||
this._run_query( | ||
r.expr(["stats_clients", "stats_requests"]) | ||
.forEach(admin_db.table(r.row).delete())); | ||
} | ||
|
||
add_request(req, client) { | ||
if (req.raw.type.startsWith("admin:")) return; | ||
|
||
this._run_query( | ||
request_table.insert({ | ||
id: [client.id, req.id], | ||
request: req.id, raw: req.raw, | ||
time: r.now(), cursors: 0, | ||
client: {id: client.id, ip: client.get_address()} | ||
})); | ||
} | ||
|
||
add_cursor(client, req) { | ||
if (req.raw.type.startsWith("admin:")) return; | ||
|
||
this._run_query( | ||
request_table | ||
.get([client.id, req.id]) | ||
.update({cursors: r.row('cursors').add(1)})); | ||
} | ||
|
||
remove_cursor(client, req) { | ||
if (req.raw.type.startsWith("admin:")) return; | ||
|
||
this._run_query( | ||
request_table | ||
.get([client.id, req.id]) | ||
.update({cursors: r.row('cursors').sub(1)})); | ||
} | ||
|
||
add_client(client) { | ||
this._run_query( | ||
client_table.insert({ | ||
connected: true, id: client.id, | ||
time: r.now(), ip: client.get_address()})); | ||
} | ||
|
||
remove_client(client) { | ||
this._run_query( | ||
request_table | ||
.between([client.id, r.minval], [client.id, r.maxval]) | ||
.update({cursors: 0})); | ||
|
||
this._run_query( | ||
client_table | ||
.get(client.id) | ||
.update({connected: false, disconnected: r.now()})); | ||
} | ||
|
||
_run_query(query) { | ||
query.run(this.server._reql_conn.connection()); | ||
} | ||
} | ||
|
||
module.exports = { Admin }; |
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,33 @@ | ||
'use strict'; | ||
|
||
const r = require('rethinkdb'); | ||
|
||
const admin_db = r.db('horizon_internal'); | ||
const client_table = admin_db.table('stats_clients'); | ||
const request_table = admin_db.table('stats_requests'); | ||
|
||
const change_settings = { | ||
include_initial: true, | ||
include_states: true, | ||
include_types: true | ||
}; | ||
|
||
module.exports = { | ||
clients(req, metadata) { | ||
return client_table | ||
.getAll(true, {index: 'connected'}) | ||
.changes(change_settings); | ||
}, | ||
|
||
requests(req, metadata) { | ||
return (req.options.live ? | ||
request_table.getAll(true, {index: "cursors"}) : | ||
request_table.orderBy({index: r.desc("time")}).limit(100)) | ||
.changes(change_settings); | ||
}, | ||
|
||
collections(req, metadata) { | ||
return admin_db.table("collections") | ||
.changes(change_settings); | ||
} | ||
} |
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
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.
Maybe name this something scarier like
rawRequest