| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
package jsonrpc2 |
| 6 |
|
| 7 |
import ( |
| 8 |
"golang.org/x/exp/event" |
| 9 |
) |
| 10 |
|
| 11 |
func Method(v string) event.Label { return event.String("method", v) } |
| 12 |
func RPCID(v string) event.Label { return event.String("id", v) } |
| 13 |
func RPCDirection(v string) event.Label { return event.String("direction", v) } |
| 14 |
func StatusCode(v string) event.Label { return event.String("status.code", v) } |
| 15 |
|
| 16 |
var ( |
| 17 |
Started = event.NewCounter("started", &event.MetricOptions{Description: "Count of started RPCs."}) |
| 18 |
Finished = event.NewCounter("finished", &event.MetricOptions{Description: "Count of finished RPCs (includes error)."}) |
| 19 |
ReceivedBytes = event.NewIntDistribution("received_bytes", &event.MetricOptions{ |
| 20 |
Description: "Bytes received.", |
| 21 |
Unit: event.UnitBytes, |
| 22 |
}) |
| 23 |
SentBytes = event.NewIntDistribution("sent_bytes", &event.MetricOptions{ |
| 24 |
Description: "Bytes sent.", |
| 25 |
Unit: event.UnitBytes, |
| 26 |
}) |
| 27 |
Latency = event.NewDuration("latency", &event.MetricOptions{ |
| 28 |
Description: "Elapsed time of an RPC.", |
| 29 |
Unit: event.UnitMilliseconds, |
| 30 |
}) |
| 31 |
) |
| 32 |
|
| 33 |
const ( |
| 34 |
Inbound = "in" |
| 35 |
Outbound = "out" |
| 36 |
) |