{"id":160388,"date":"2020-09-26T08:54:27","date_gmt":"2020-09-26T00:54:27","guid":{"rendered":"http:\/\/4563.org\/?p=160388"},"modified":"2020-09-26T08:54:27","modified_gmt":"2020-09-26T00:54:27","slug":"gin-web-%e6%a1%86%e6%9e%b6%e7%9a%84%e7%9b%91%e6%8e%a7%e6%8c%87%e6%a0%87","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=160388","title":{"rendered":"gin web \u6846\u67b6\u7684\u76d1\u63a7\u6307\u6807"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  gin web \u6846\u67b6\u7684\u76d1\u63a7\u6307\u6807               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Lpl <\/span>  <span><i><\/i> 0<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u6700\u8fd1\u5199\u4e86\u4e00\u4e2a metric exporter\uff0c\u57fa\u4e8e gin web \u6846\u67b6\u3002\u62bd\u51fa\u6765\u4e86\u51e0\u4e2a\u4f7f\u7528 gin \u7684\u65f6\u5019\u53ef\u80fd\u4f1a\u7528\u5230\u7684\u76d1\u63a7\u6307\u6807\uff1a<\/p>\n<pre><code>| Metric                  | Type      | Description                    | | ----------------------- | --------- | ------------------------------ | | gin_request_total       | Counter   | \u670d\u52a1\u63a5\u6536\u5230\u7684\u8bf7\u6c42\u603b\u6570           | | gin_request_uv          | Counter   | \u670d\u52a1\u63a5\u6536\u5230\u7684 IP \u603b\u6570           | | gin_uri_request_total   | Counter   | \u6bcf\u4e2a URI \u63a5\u6536\u5230\u7684\u670d\u52a1\u8bf7\u6c42\u6570    | | gin_request_body_total  | Counter   | \u670d\u52a1\u63a5\u6536\u5230\u7684\u8bf7\u6c42\u91cf\uff0c\u5355\u4f4d: \u5b57\u8282 | | gin_response_body_total | Counter   | \u670d\u52a1\u8fd4\u56de\u7684\u8bf7\u6c42\u91cf\uff0c\u5355\u4f4d: \u5b57\u8282   | | gin_request_duration    | Histogram | \u670d\u52a1\u5904\u7406\u8bf7\u6c42\u4f7f\u7528\u7684\u65f6\u95f4         | | gin_slow_request_total  | Counter   | \u670d\u52a1\u63a5\u6536\u5230\u7684\u6162\u8bf7\u6c42\u8ba1\u6570         |  <\/code><\/pre>\n<p>\u540c\u65f6\u4e5f\u652f\u6301\u5728\u5e94\u7528\u4e2d\u81ea\u5b9a\u4e49\u76d1\u63a7\u6307\u6807<\/p>\n<pre><code>gaugeMetric := &amp;ginmetrics.Metric{     Type:        ginmetrics.Counter,     Name:        \"example_gauge_metric\",     Description: \"an example of gauge type metric\",     Labels:      []string{\"label1\"}, }  \/\/ \u5c06\u81ea\u5b9a\u4e49\u7684 Metric \u6dfb\u52a0\u8fdb\u5168\u5c40\u5bf9\u8c61 _ = ginmetrics.GetMonitor().AddMetric(gaugeMetric)  \/\/ \u8bbe\u7f6e\u81ea\u5b9a\u4e49 Metric \u7684\u76d1\u63a7\u503c _ = ginmetrics.GetMonitor().GetMetric(\"example_gauge_metric\").   SetGaugeValue([]string{\"label_value1\"}, 0.1) <\/code><\/pre>\n<p>\u5982\u679c\u4f7f\u7528\u4e0a\u6709\u95ee\u9898\uff0c\u6216\u8005\u6709\u4ec0\u4e48 feature \u5efa\u8bae\uff0c\u6b22\u8fce\u63d0\u51fa~<\/p>\n<p>\u4ed3\u5e93\u5730\u5740\uff1ahttps:\/\/github.com\/penglongli\/gin-metrics<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>1<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3467246\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : richzhu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6b63\u597d\u9700\u8981\uff0cstart \u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>gin web \u6846\u67b6\u7684\u76d1\u63a7\u6307\u6807 \u8cc7&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/160388"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=160388"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/160388\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=160388"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=160388"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=160388"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}