package rpcconv

import "go.opentelemetry.io/otel/semconv/v1.40.0/rpcconv"

Package rpcconv provides types and functionality for OpenTelemetry semantic conventions in the "rpc" namespace.

Index

Types

type ClientCallDuration

type ClientCallDuration struct {
	metric.Float64Histogram
}

ClientCallDuration is an instrument used to record metric values conforming to the "rpc.client.call.duration" semantic conventions. It represents the measures the duration of an outgoing Remote Procedure Call (RPC).

func NewClientCallDuration

func NewClientCallDuration(
	m metric.Meter,
	opt ...metric.Float64HistogramOption,
) (ClientCallDuration, error)

NewClientCallDuration returns a new ClientCallDuration instrument.

func (ClientCallDuration) AttrErrorType

AttrErrorType returns an optional attribute for the "error.type" semantic convention. It represents the describes a class of error the operation ended with.

func (ClientCallDuration) AttrMethod

func (ClientCallDuration) AttrMethod(val string) attribute.KeyValue

AttrMethod returns an optional attribute for the "rpc.method" semantic convention. It represents the fully-qualified logical name of the method from the RPC interface perspective.

func (ClientCallDuration) AttrResponseStatusCode

func (ClientCallDuration) AttrResponseStatusCode(val string) attribute.KeyValue

AttrResponseStatusCode returns an optional attribute for the "rpc.response.status_code" semantic convention. It represents the status code of the RPC returned by the RPC server or generated by the client.

func (ClientCallDuration) AttrServerAddress

func (ClientCallDuration) AttrServerAddress(val string) attribute.KeyValue

AttrServerAddress returns an optional attribute for the "server.address" semantic convention. It represents a string identifying a group of RPC server instances request is sent to.

func (ClientCallDuration) AttrServerPort

func (ClientCallDuration) AttrServerPort(val int) attribute.KeyValue

AttrServerPort returns an optional attribute for the "server.port" semantic convention. It represents the server port number.

func (ClientCallDuration) Description

func (ClientCallDuration) Description() string

Description returns the semantic convention description of the instrument

func (ClientCallDuration) Inst

Inst returns the underlying metric instrument.

func (ClientCallDuration) Name

func (ClientCallDuration) Name() string

Name returns the semantic convention name of the instrument.

func (ClientCallDuration) Record

func (m ClientCallDuration) Record(
	ctx context.Context,
	val float64,
	systemName SystemNameAttr,
	attrs ...attribute.KeyValue,
)

Record records val to the current distribution for attrs.

The systemName is the the Remote Procedure Call (RPC) system.

All additional attrs passed are included in the recorded value.

When this metric is reported alongside an RPC client span, the metric value SHOULD be the same as the RPC client span duration.

func (ClientCallDuration) RecordSet

func (m ClientCallDuration) RecordSet(ctx context.Context, val float64, set attribute.Set)

RecordSet records val to the current distribution for set.

When this metric is reported alongside an RPC client span, the metric value SHOULD be the same as the RPC client span duration.

func (ClientCallDuration) Unit

func (ClientCallDuration) Unit() string

Unit returns the semantic convention unit of the instrument

type ErrorTypeAttr

type ErrorTypeAttr string

ErrorTypeAttr is an attribute conforming to the error.type semantic conventions. It represents the describes a class of error the operation ended with.

var (
	// ErrorTypeOther is a fallback error value to be used when the instrumentation
	// doesn't define a custom value.
	ErrorTypeOther ErrorTypeAttr = "_OTHER"
)

type ServerCallDuration

type ServerCallDuration struct {
	metric.Float64Histogram
}

ServerCallDuration is an instrument used to record metric values conforming to the "rpc.server.call.duration" semantic conventions. It represents the measures the duration of an incoming Remote Procedure Call (RPC).

func NewServerCallDuration

func NewServerCallDuration(
	m metric.Meter,
	opt ...metric.Float64HistogramOption,
) (ServerCallDuration, error)

NewServerCallDuration returns a new ServerCallDuration instrument.

func (ServerCallDuration) AttrErrorType

AttrErrorType returns an optional attribute for the "error.type" semantic convention. It represents the describes a class of error the operation ended with.

func (ServerCallDuration) AttrMethod

func (ServerCallDuration) AttrMethod(val string) attribute.KeyValue

AttrMethod returns an optional attribute for the "rpc.method" semantic convention. It represents the fully-qualified logical name of the method from the RPC interface perspective.

func (ServerCallDuration) AttrResponseStatusCode

func (ServerCallDuration) AttrResponseStatusCode(val string) attribute.KeyValue

AttrResponseStatusCode returns an optional attribute for the "rpc.response.status_code" semantic convention. It represents the status code of the RPC returned by the RPC server or generated by the client.

func (ServerCallDuration) AttrServerAddress

func (ServerCallDuration) AttrServerAddress(val string) attribute.KeyValue

AttrServerAddress returns an optional attribute for the "server.address" semantic convention. It represents a string identifying a group of RPC server instances request is sent to.

func (ServerCallDuration) AttrServerPort

func (ServerCallDuration) AttrServerPort(val int) attribute.KeyValue

AttrServerPort returns an optional attribute for the "server.port" semantic convention. It represents the server port number.

func (ServerCallDuration) Description

func (ServerCallDuration) Description() string

Description returns the semantic convention description of the instrument

func (ServerCallDuration) Inst

Inst returns the underlying metric instrument.

func (ServerCallDuration) Name

func (ServerCallDuration) Name() string

Name returns the semantic convention name of the instrument.

func (ServerCallDuration) Record

func (m ServerCallDuration) Record(
	ctx context.Context,
	val float64,
	systemName SystemNameAttr,
	attrs ...attribute.KeyValue,
)

Record records val to the current distribution for attrs.

The systemName is the the Remote Procedure Call (RPC) system.

All additional attrs passed are included in the recorded value.

When this metric is reported alongside an RPC server span, the metric value SHOULD be the same as the RPC server span duration.

func (ServerCallDuration) RecordSet

func (m ServerCallDuration) RecordSet(ctx context.Context, val float64, set attribute.Set)

RecordSet records val to the current distribution for set.

When this metric is reported alongside an RPC server span, the metric value SHOULD be the same as the RPC server span duration.

func (ServerCallDuration) Unit

func (ServerCallDuration) Unit() string

Unit returns the semantic convention unit of the instrument

type SystemNameAttr

type SystemNameAttr string

SystemNameAttr is an attribute conforming to the rpc.system.name semantic conventions. It represents the Remote Procedure Call (RPC) system.

var (
	// SystemNameGRPC is the [gRPC].
	//
	// [gRPC]: https://grpc.io/
	SystemNameGRPC SystemNameAttr = "grpc"
	// SystemNameDubbo is the [Apache Dubbo].
	//
	// [Apache Dubbo]: https://dubbo.apache.org/
	SystemNameDubbo SystemNameAttr = "dubbo"
	// SystemNameConnectrpc is the [Connect RPC].
	//
	// [Connect RPC]: https://connectrpc.com/
	SystemNameConnectrpc SystemNameAttr = "connectrpc"
	// SystemNameJSONRPC is the [JSON-RPC].
	//
	// [JSON-RPC]: https://www.jsonrpc.org/
	SystemNameJSONRPC SystemNameAttr = "jsonrpc"
)

Source Files

metric.go

Version
v1.43.0 (latest)
Published
Apr 3, 2026
Platform
linux/amd64
Imports
5 packages
Last checked
21 minutes ago

Tools for package owners.