summaryrefslogtreecommitdiffstats
path: root/jsonrpc2/defs.go
blob: e3677de7b22c08bc49564ec28aa8df77b4fc2887 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package jsonrpc2

import (
	"golang.org/x/exp/event"
)

func Method(v string) event.Label       { return event.String("method", v) }
func RPCID(v string) event.Label        { return event.String("id", v) }
func RPCDirection(v string) event.Label { return event.String("direction", v) }
func StatusCode(v string) event.Label   { return event.String("status.code", v) }

var (
	Started       = event.NewCounter("started", &event.MetricOptions{Description: "Count of started RPCs."})
	Finished      = event.NewCounter("finished", &event.MetricOptions{Description: "Count of finished RPCs (includes error)."})
	ReceivedBytes = event.NewIntDistribution("received_bytes", &event.MetricOptions{
		Description: "Bytes received.",
		Unit:        event.UnitBytes,
	})
	SentBytes = event.NewIntDistribution("sent_bytes", &event.MetricOptions{
		Description: "Bytes sent.",
		Unit:        event.UnitBytes,
	})
	Latency = event.NewDuration("latency", &event.MetricOptions{
		Description: "Elapsed time of an RPC.",
		Unit:        event.UnitMilliseconds,
	})
)

const (
	Inbound  = "in"
	Outbound = "out"
)