<p>I read the doc and know expvar provides interface for global variables. But I don't understand the design purpose for this pkg. Need some expert opnion on this</p>
<hr/>**评论:**<br/><br/>Loves_Portishead: <pre><p>The idea is to make the running process inspectable. The stdlib package debug/pprof for example can be used to set up an http server that gives GC and go routine stats. You can do the same to allow a 3rd party to inspect your process by making your "server" type implement the relevant methods so you can effortlessly see what it's doing from outside.</p></pre>Loves_Portishead: <pre><p>Update to clarify "3rd party" in my initial description means something like collectd or telegraf with the JSON input source plugins.</p></pre>xopherus: <pre><p>Exactly. You can use this with Consul to put active resource stats within a health check, and alert on that. Or you could dump the stats to Prometheus to set up time-series data. </p></pre>fmpwizard: <pre><p>For a concrete example, at work we have a batch process that can take several hours. We use expvars to tell us where in the whole process we are at any given time, originally they were string vars but because we use datadog for monitoring, and they only support numeric values, we keep a list of numeric constants.</p>
<p>We also have other variables to tell us the rate at which we are processing the data that comes in. It is really handy and easy to setup.</p></pre>marksteve4: <pre><p>it's easy to understand</p></pre>Orange_Tux: <pre><p>We use in service to monitor how many requests have been succesfully processed and how many failed.</p>
<p>I while ago I write a blog post about it: <a href="https://orangetux.nl/post/expvar_in_action/" rel="nofollow">expvar in action</a>.</p></pre>marksteve4: <pre><p>the link is broken</p></pre>Orange_Tux: <pre><p>Thanks for noticing. It has been fixed now.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
0 回复
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传