luvit / lit

Toolkit for developing, sharing, and running luvit/lua programs and libraries.
http://lit.luvit.io/
Apache License 2.0
245 stars 58 forks source link

Add memory and file descriptor metrics to Lit server. #178

Closed sam-falvo closed 8 years ago

sam-falvo commented 8 years ago

To access, hit the /metrics endpoint of the Lit server. This will produce a plain text, machine-readable result informing the user of the total memory consumed by the Lit server, as well as the total number of file descriptors used by Lit at the time the metrics were requested.

creationix commented 8 years ago

Looks great. Is there any particular reason you're using plain-text? All the other lit endpoints return JSON.

sam-falvo commented 8 years ago

Ease of getting something working. I'll send a second patch that makes it emit JSON. Is there a recommended JSON serialization library I should look into? Or is hard-wired JSON sufficient?

creationix commented 8 years ago

There is no JSON in lua, but luvit comes with one.

local jsonEncode = require('json').encode
local json = jsonEncode(somevalue)
squeek502 commented 8 years ago

Also note that if a route returns a table, it will get auto-converted into JSON.

creationix commented 8 years ago

Thanks @squeek502, I forgot about that.

sam-falvo commented 8 years ago

Thanks; I'll make that change in a few minutes. Stand by!

sam-falvo commented 8 years ago

Done!

creationix commented 8 years ago

+1

sam-falvo commented 8 years ago

Now with more asynchronous flavor and wholesome concurrency!

creationix commented 8 years ago

Should probably add self documenting entry in the TOC result at the / route.

creationix commented 8 years ago

Since this is already closed I just tweaked it myself https://github.com/luvit/lit/commit/b07a7f02480ec824dda5a9e3f0c6fd0840685766