メトリクス & テレメトリ
メトリクス & テレメトリ
Section titled “メトリクス & テレメトリ”カウンター、ゲージ、ヒストグラムを使用してアプリケーションメトリクスを記録します。
local metrics = require("metrics")カウンターをインクリメント
Section titled “カウンターをインクリメント”metrics.counter_inc("requests_total", {method = "POST"})| パラメータ | 型 | 説明 |
|---|---|---|
name | string | メトリクス名 |
labels | table? | ラベルのキーバリューペア |
戻り値: boolean, error
カウンターに加算
Section titled “カウンターに加算”metrics.counter_add("bytes_total", 1024, {direction = "out"})| パラメータ | 型 | 説明 |
|---|---|---|
name | string | メトリクス名 |
value | number | 加算する値 |
labels | table? | ラベルのキーバリューペア |
戻り値: boolean, error
ゲージを設定
Section titled “ゲージを設定”metrics.gauge_set("queue_depth", 42, {queue = "emails"})| パラメータ | 型 | 説明 |
|---|---|---|
name | string | メトリクス名 |
value | number | 現在の値 |
labels | table? | ラベルのキーバリューペア |
戻り値: boolean, error
ゲージをインクリメント
Section titled “ゲージをインクリメント”metrics.gauge_inc("connections", {pool = "db"})| パラメータ | 型 | 説明 |
|---|---|---|
name | string | メトリクス名 |
labels | table? | ラベルのキーバリューペア |
戻り値: boolean, error
ゲージをデクリメント
Section titled “ゲージをデクリメント”metrics.gauge_dec("connections", {pool = "db"})| パラメータ | 型 | 説明 |
|---|---|---|
name | string | メトリクス名 |
labels | table? | ラベルのキーバリューペア |
戻り値: boolean, error
ヒストグラム
Section titled “ヒストグラム”観測値の記録
Section titled “観測値の記録”metrics.histogram("duration_seconds", 0.123, {method = "GET"})| パラメータ | 型 | 説明 |
|---|---|---|
name | string | メトリクス名 |
value | number | 観測値 |
labels | table? | ラベルのキーバリューペア |
戻り値: boolean, error
| 条件 | 種別 | 再試行可能 |
|---|---|---|
| コレクターが利用不可 | errors.INTERNAL | no |
エラーの処理についてはエラー処理を参照。