Merge pull request #1122 from opencloud-eu/dependabot/go_modules/go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc-0.62.0

build(deps): bump go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc from 0.61.0 to 0.62.0
This commit is contained in:
Ralf Haferkamp
2025-06-27 13:08:18 +02:00
committed by GitHub
16 changed files with 822 additions and 14497 deletions

2
go.mod
View File

@@ -89,7 +89,7 @@ require (
github.com/xhit/go-simple-mail/v2 v2.16.0
go-micro.dev/v4 v4.11.0
go.etcd.io/bbolt v1.4.1
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.62.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0
go.opentelemetry.io/contrib/zpages v0.62.0
go.opentelemetry.io/otel v1.37.0

8
go.sum
View File

@@ -1177,8 +1177,8 @@ go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0 h1:q4XOmH/0opmeuJtPsbFNivyl7bCt7yRBbeEm2sC/XtQ=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0/go.mod h1:snMWehoOh2wsEwnvvwtDyFCxVeDAODenXHtn5vzrKjo=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.62.0 h1:rbRJ8BBoVMsQShESYZ0FkvcITu8X8QNwJogcLUmDNNw=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.62.0/go.mod h1:ru6KHrNtNHxM4nD/vd6QrLVWgKhxPYgblq4VAtNawTQ=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 h1:F7Jx+6hwnZ41NSFTO5q4LYDtJRXBf2PD0rNBkeB/lus=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0/go.mod h1:UHB22Z8QsdRDrnAtX4PntOl36ajSxcdUMt1sF7Y6E7Q=
go.opentelemetry.io/contrib/zpages v0.62.0 h1:9fUYTLmrK0x/lweM2uM+BOx069jLx8PxVqWhegGJ9Bo=
@@ -1197,8 +1197,8 @@ go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/Wgbsd
go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E=
go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI=
go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg=
go.opentelemetry.io/otel/sdk/metric v1.36.0 h1:r0ntwwGosWGaa0CrSt8cuNuTcccMXERFwHX4dThiPis=
go.opentelemetry.io/otel/sdk/metric v1.36.0/go.mod h1:qTNOhFDfKRwX0yXOqJYegL5WRaW376QbB7P4Pb0qva4=
go.opentelemetry.io/otel/sdk/metric v1.37.0 h1:90lI228XrB9jCMuSdA0673aubgRobVZFhbjxHHspCPc=
go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVWZWpRE+9WyVCpbo5ps=
go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4=
go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0=
go.opentelemetry.io/proto/otlp v1.7.0 h1:jX1VolD6nHuFzOYso2E73H85i92Mv8JQYk0K9vz09os=

View File

@@ -4,6 +4,8 @@
package otelgrpc // import "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
import (
"context"
"google.golang.org/grpc/stats"
"go.opentelemetry.io/otel"
@@ -39,6 +41,9 @@ type config struct {
SpanAttributes []attribute.KeyValue
MetricAttributes []attribute.KeyValue
PublicEndpoint bool
PublicEndpointFn func(ctx context.Context, info *stats.RPCTagInfo) bool
ReceivedEvent bool
SentEvent bool
}
@@ -61,6 +66,38 @@ func newConfig(opts []Option) *config {
return c
}
type publicEndpointOption struct{ p bool }
func (o publicEndpointOption) apply(c *config) {
c.PublicEndpoint = o.p
}
// WithPublicEndpoint configures the Handler to link the span with an incoming
// span context. If this option is not provided, then the association is a child
// association instead of a link.
func WithPublicEndpoint() Option {
return publicEndpointOption{p: true}
}
type publicEndpointFnOption struct {
fn func(context.Context, *stats.RPCTagInfo) bool
}
func (o publicEndpointFnOption) apply(c *config) {
if o.fn != nil {
c.PublicEndpointFn = o.fn
}
}
// WithPublicEndpointFn runs with every request, and allows conditionally
// configuring the Handler to link the span with an incoming span context. If
// this option is not provided or returns false, then the association is a
// child association instead of a link.
// Note: WithPublicEndpoint takes precedence over WithPublicEndpointFn.
func WithPublicEndpointFn(fn func(context.Context, *stats.RPCTagInfo) bool) Option {
return publicEndpointFnOption{fn: fn}
}
type propagatorsOption struct{ p propagation.TextMapPropagator }
func (o propagatorsOption) apply(c *config) {

View File

@@ -4,7 +4,7 @@
package otelgrpc // import "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
// gRPC tracing middleware
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/rpc.md
// https://opentelemetry.io/docs/specs/semconv/rpc/
import (
"context"
"errors"
@@ -15,14 +15,13 @@ import (
"google.golang.org/grpc"
grpc_codes "google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/peer"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/internal"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
semconv "go.opentelemetry.io/otel/semconv/v1.30.0"
semconv "go.opentelemetry.io/otel/semconv/v1.34.0"
"go.opentelemetry.io/otel/trace"
)
@@ -196,118 +195,11 @@ func StreamClientInterceptor(opts ...Option) grpc.StreamClientInterceptor {
}
}
// serverStream wraps around the embedded grpc.ServerStream, and intercepts the RecvMsg and
// SendMsg method call.
type serverStream struct {
grpc.ServerStream
ctx context.Context
receivedMessageID int
sentMessageID int
receivedEvent bool
sentEvent bool
}
func (w *serverStream) Context() context.Context {
return w.ctx
}
func (w *serverStream) RecvMsg(m interface{}) error {
err := w.ServerStream.RecvMsg(m)
if err == nil {
w.receivedMessageID++
if w.receivedEvent {
messageReceived.Event(w.Context(), w.receivedMessageID, m)
}
}
return err
}
func (w *serverStream) SendMsg(m interface{}) error {
err := w.ServerStream.SendMsg(m)
w.sentMessageID++
if w.sentEvent {
messageSent.Event(w.Context(), w.sentMessageID, m)
}
return err
}
func wrapServerStream(ctx context.Context, ss grpc.ServerStream, cfg *config) *serverStream {
return &serverStream{
ServerStream: ss,
ctx: ctx,
receivedEvent: cfg.ReceivedEvent,
sentEvent: cfg.SentEvent,
}
}
// StreamServerInterceptor returns a grpc.StreamServerInterceptor suitable
// for use in a grpc.NewServer call.
//
// Deprecated: Use [NewServerHandler] instead.
func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor {
cfg := newConfig(opts)
tracer := cfg.TracerProvider.Tracer(
ScopeName,
trace.WithInstrumentationVersion(Version()),
)
return func(
srv interface{},
ss grpc.ServerStream,
info *grpc.StreamServerInfo,
handler grpc.StreamHandler,
) error {
ctx := ss.Context()
i := &InterceptorInfo{
StreamServerInfo: info,
Type: StreamServer,
}
if cfg.InterceptorFilter != nil && !cfg.InterceptorFilter(i) {
return handler(srv, wrapServerStream(ctx, ss, cfg))
}
ctx = extract(ctx, cfg.Propagators)
name, attr := telemetryAttributes(info.FullMethod, peerFromCtx(ctx))
startOpts := append([]trace.SpanStartOption{
trace.WithSpanKind(trace.SpanKindServer),
trace.WithAttributes(attr...),
},
cfg.SpanStartOptions...,
)
ctx, span := tracer.Start(
trace.ContextWithRemoteSpanContext(ctx, trace.SpanContextFromContext(ctx)),
name,
startOpts...,
)
defer span.End()
err := handler(srv, wrapServerStream(ctx, ss, cfg))
if err != nil {
s, _ := status.FromError(err)
statusCode, msg := serverStatus(s)
span.SetStatus(statusCode, msg)
span.SetAttributes(statusCodeAttr(s.Code()))
} else {
span.SetAttributes(statusCodeAttr(grpc_codes.OK))
}
return err
}
}
// telemetryAttributes returns a span name and span and metric attributes from
// the gRPC method and peer address.
func telemetryAttributes(fullMethod, sererAddr string) (string, []attribute.KeyValue) {
func telemetryAttributes(fullMethod, serverAddr string) (string, []attribute.KeyValue) {
name, methodAttrs := internal.ParseFullMethod(fullMethod)
srvAttrs := serverAddrAttrs(sererAddr)
srvAttrs := serverAddrAttrs(serverAddr)
attrs := make([]attribute.KeyValue, 0, 1+len(methodAttrs)+len(srvAttrs))
attrs = append(attrs, semconv.RPCSystemGRPC)
@@ -333,15 +225,6 @@ func serverAddrAttrs(hostport string) []attribute.KeyValue {
}
}
// peerFromCtx returns a peer address from a context, if one exists.
func peerFromCtx(ctx context.Context) string {
p, ok := peer.FromContext(ctx)
if !ok {
return ""
}
return p.Addr.String()
}
// statusCodeAttr returns status code attribute based on given gRPC code.
func statusCodeAttr(c grpc_codes.Code) attribute.KeyValue {
return semconv.RPCGRPCStatusCodeKey.Int64(int64(c))

View File

@@ -8,7 +8,7 @@ import (
"strings"
"go.opentelemetry.io/otel/attribute"
semconv "go.opentelemetry.io/otel/semconv/v1.30.0"
semconv "go.opentelemetry.io/otel/semconv/v1.34.0"
)
// ParseFullMethod returns a span name following the OpenTelemetry semantic

View File

@@ -17,8 +17,8 @@ import (
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/noop"
semconv "go.opentelemetry.io/otel/semconv/v1.30.0"
semconv "go.opentelemetry.io/otel/semconv/v1.34.0"
"go.opentelemetry.io/otel/semconv/v1.34.0/rpcconv"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/internal"
@@ -38,11 +38,11 @@ type serverHandler struct {
tracer trace.Tracer
duration metric.Float64Histogram
inSize metric.Int64Histogram
outSize metric.Int64Histogram
inMsg metric.Int64Histogram
outMsg metric.Int64Histogram
duration rpcconv.ServerDuration
inSize rpcconv.ServerRequestSize
outSize rpcconv.ServerResponseSize
inMsg rpcconv.ServerRequestsPerRPC
outMsg rpcconv.ServerResponsesPerRPC
}
// NewServerHandler creates a stats.Handler for a gRPC server.
@@ -62,64 +62,29 @@ func NewServerHandler(opts ...Option) stats.Handler {
)
var err error
h.duration, err = meter.Float64Histogram(
semconv.RPCServerDurationName,
metric.WithDescription(semconv.RPCServerDurationDescription),
metric.WithUnit(semconv.RPCServerDurationUnit),
)
h.duration, err = rpcconv.NewServerDuration(meter)
if err != nil {
otel.Handle(err)
if h.duration == nil {
h.duration = noop.Float64Histogram{}
}
}
h.inSize, err = meter.Int64Histogram(
semconv.RPCServerRequestSizeName,
metric.WithDescription(semconv.RPCServerRequestSizeDescription),
metric.WithUnit(semconv.RPCServerRequestSizeUnit),
)
h.inSize, err = rpcconv.NewServerRequestSize(meter)
if err != nil {
otel.Handle(err)
if h.inSize == nil {
h.inSize = noop.Int64Histogram{}
}
}
h.outSize, err = meter.Int64Histogram(
semconv.RPCServerResponseSizeName,
metric.WithDescription(semconv.RPCServerResponseSizeDescription),
metric.WithUnit(semconv.RPCServerResponseSizeUnit),
)
h.outSize, err = rpcconv.NewServerResponseSize(meter)
if err != nil {
otel.Handle(err)
if h.outSize == nil {
h.outSize = noop.Int64Histogram{}
}
}
h.inMsg, err = meter.Int64Histogram(
semconv.RPCServerRequestsPerRPCName,
metric.WithDescription(semconv.RPCServerRequestsPerRPCDescription),
metric.WithUnit(semconv.RPCServerRequestsPerRPCUnit),
)
h.inMsg, err = rpcconv.NewServerRequestsPerRPC(meter)
if err != nil {
otel.Handle(err)
if h.inMsg == nil {
h.inMsg = noop.Int64Histogram{}
}
}
h.outMsg, err = meter.Int64Histogram(
semconv.RPCServerResponsesPerRPCName,
metric.WithDescription(semconv.RPCServerResponsesPerRPCDescription),
metric.WithUnit(semconv.RPCServerResponsesPerRPCUnit),
)
h.outMsg, err = rpcconv.NewServerResponsesPerRPC(meter)
if err != nil {
otel.Handle(err)
if h.outMsg == nil {
h.outMsg = noop.Int64Histogram{}
}
}
return h
@@ -147,11 +112,21 @@ func (h *serverHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) cont
}
if record {
opts := []trace.SpanStartOption{
trace.WithSpanKind(trace.SpanKindServer),
trace.WithAttributes(append(attrs, h.SpanAttributes...)...),
}
if h.PublicEndpoint || (h.PublicEndpointFn != nil && h.PublicEndpointFn(ctx, info)) {
opts = append(opts, trace.WithNewRoot())
// Linking incoming span context if any for public endpoint.
if s := trace.SpanContextFromContext(ctx); s.IsValid() && s.IsRemote() {
opts = append(opts, trace.WithLinks(trace.Link{SpanContext: s}))
}
}
ctx, _ = h.tracer.Start(
trace.ContextWithRemoteSpanContext(ctx, trace.SpanContextFromContext(ctx)),
name,
trace.WithSpanKind(trace.SpanKindServer),
trace.WithAttributes(append(attrs, h.SpanAttributes...)...),
opts...,
)
}
@@ -165,7 +140,16 @@ func (h *serverHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) cont
// HandleRPC processes the RPC stats.
func (h *serverHandler) HandleRPC(ctx context.Context, rs stats.RPCStats) {
h.handleRPC(ctx, rs, h.duration, h.inSize, h.outSize, h.inMsg, h.outMsg, serverStatus)
h.handleRPC(
ctx,
rs,
h.duration.Inst(),
h.inSize,
h.outSize,
h.inMsg.Inst(),
h.outMsg.Inst(),
serverStatus,
)
}
type clientHandler struct {
@@ -173,11 +157,11 @@ type clientHandler struct {
tracer trace.Tracer
duration metric.Float64Histogram
inSize metric.Int64Histogram
outSize metric.Int64Histogram
inMsg metric.Int64Histogram
outMsg metric.Int64Histogram
duration rpcconv.ClientDuration
inSize rpcconv.ClientResponseSize
outSize rpcconv.ClientRequestSize
inMsg rpcconv.ClientResponsesPerRPC
outMsg rpcconv.ClientRequestsPerRPC
}
// NewClientHandler creates a stats.Handler for a gRPC client.
@@ -197,64 +181,29 @@ func NewClientHandler(opts ...Option) stats.Handler {
)
var err error
h.duration, err = meter.Float64Histogram(
semconv.RPCClientDurationName,
metric.WithDescription(semconv.RPCClientDurationDescription),
metric.WithUnit(semconv.RPCClientDurationUnit),
)
h.duration, err = rpcconv.NewClientDuration(meter)
if err != nil {
otel.Handle(err)
if h.duration == nil {
h.duration = noop.Float64Histogram{}
}
}
h.outSize, err = meter.Int64Histogram(
semconv.RPCClientRequestSizeName,
metric.WithDescription(semconv.RPCClientRequestSizeDescription),
metric.WithUnit(semconv.RPCClientRequestSizeUnit),
)
h.inSize, err = rpcconv.NewClientResponseSize(meter)
if err != nil {
otel.Handle(err)
if h.outSize == nil {
h.outSize = noop.Int64Histogram{}
}
}
h.inSize, err = meter.Int64Histogram(
semconv.RPCClientResponseSizeName,
metric.WithDescription(semconv.RPCClientResponseSizeDescription),
metric.WithUnit(semconv.RPCClientResponseSizeUnit),
)
h.outSize, err = rpcconv.NewClientRequestSize(meter)
if err != nil {
otel.Handle(err)
if h.inSize == nil {
h.inSize = noop.Int64Histogram{}
}
}
h.outMsg, err = meter.Int64Histogram(
semconv.RPCClientRequestsPerRPCName,
metric.WithDescription(semconv.RPCClientRequestsPerRPCDescription),
metric.WithUnit(semconv.RPCClientRequestsPerRPCUnit),
)
h.inMsg, err = rpcconv.NewClientResponsesPerRPC(meter)
if err != nil {
otel.Handle(err)
if h.outMsg == nil {
h.outMsg = noop.Int64Histogram{}
}
}
h.inMsg, err = meter.Int64Histogram(
semconv.RPCClientResponsesPerRPCName,
metric.WithDescription(semconv.RPCClientResponsesPerRPCDescription),
metric.WithUnit(semconv.RPCClientResponsesPerRPCUnit),
)
h.outMsg, err = rpcconv.NewClientRequestsPerRPC(meter)
if err != nil {
otel.Handle(err)
if h.inMsg == nil {
h.inMsg = noop.Int64Histogram{}
}
}
return h
@@ -290,7 +239,13 @@ func (h *clientHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) cont
// HandleRPC processes the RPC stats.
func (h *clientHandler) HandleRPC(ctx context.Context, rs stats.RPCStats) {
h.handleRPC(
ctx, rs, h.duration, h.inSize, h.outSize, h.inMsg, h.outMsg,
ctx,
rs,
h.duration.Inst(),
h.inSize,
h.outSize,
h.inMsg.Inst(),
h.outMsg.Inst(),
func(s *status.Status) (codes.Code, string) {
return codes.Error, s.Message()
},
@@ -307,11 +262,16 @@ func (h *clientHandler) HandleConn(context.Context, stats.ConnStats) {
// no-op
}
type int64Hist interface {
Record(context.Context, int64, ...attribute.KeyValue)
}
func (c *config) handleRPC(
ctx context.Context,
rs stats.RPCStats,
duration metric.Float64Histogram,
inSize, outSize, inMsg, outMsg metric.Int64Histogram,
inSize, outSize int64Hist,
inMsg, outMsg metric.Int64Histogram,
recordStatus func(*status.Status) (codes.Code, string),
) {
gctx, _ := ctx.Value(gRPCContextKey{}).(*gRPCContext)
@@ -327,7 +287,7 @@ func (c *config) handleRPC(
case *stats.InPayload:
if gctx != nil {
messageId = atomic.AddInt64(&gctx.inMessages, 1)
inSize.Record(ctx, int64(rs.Length), metric.WithAttributes(gctx.metricAttrs...))
inSize.Record(ctx, int64(rs.Length), gctx.metricAttrs...)
}
if c.ReceivedEvent && span.IsRecording() {
@@ -343,7 +303,7 @@ func (c *config) handleRPC(
case *stats.OutPayload:
if gctx != nil {
messageId = atomic.AddInt64(&gctx.outMessages, 1)
outSize.Record(ctx, int64(rs.Length), metric.WithAttributes(gctx.metricAttrs...))
outSize.Record(ctx, int64(rs.Length), gctx.metricAttrs...)
}
if c.SentEvent && span.IsRecording() {

View File

@@ -5,6 +5,6 @@ package otelgrpc // import "go.opentelemetry.io/contrib/instrumentation/google.g
// Version is the current release version of the gRPC instrumentation.
func Version() string {
return "0.61.0"
return "0.62.0"
// This string is updated by the pre_release.sh script during release
}

View File

@@ -1,155 +0,0 @@
# Semantic Convention Changes
The `go.opentelemetry.io/otel/semconv/v1.30.0` should be a drop-in replacement for `go.opentelemetry.io/otel/semconv/v1.28.0` with the following exceptions.
Note: `go.opentelemetry.io/otel/semconv/v1.29.0` does not exist due to bugs from the upstream [OpenTelemetry Semantic Conventions].
## Dropped deprecations
The following declarations have been deprecated in the [OpenTelemetry Semantic Conventions].
Refer to the respective documentation in that repository for deprecation instructions for each type.
- `CodeColumn`
- `CodeColumnKey`
- `CodeFunction`
- `CodeFunctionKey`
- `DBCassandraConsistencyLevelAll`
- `DBCassandraConsistencyLevelAny`
- `DBCassandraConsistencyLevelEachQuorum`
- `DBCassandraConsistencyLevelKey`
- `DBCassandraConsistencyLevelLocalOne`
- `DBCassandraConsistencyLevelLocalQuorum`
- `DBCassandraConsistencyLevelLocalSerial`
- `DBCassandraConsistencyLevelOne`
- `DBCassandraConsistencyLevelQuorum`
- `DBCassandraConsistencyLevelSerial`
- `DBCassandraConsistencyLevelThree`
- `DBCassandraConsistencyLevelTwo`
- `DBCassandraCoordinatorDC`
- `DBCassandraCoordinatorDCKey`
- `DBCassandraCoordinatorID`
- `DBCassandraCoordinatorIDKey`
- `DBCassandraIdempotence`
- `DBCassandraIdempotenceKey`
- `DBCassandraPageSize`
- `DBCassandraPageSizeKey`
- `DBCassandraSpeculativeExecutionCount`
- `DBCassandraSpeculativeExecutionCountKey`
- `DBCosmosDBClientID`
- `DBCosmosDBClientIDKey`
- `DBCosmosDBConnectionModeDirect`
- `DBCosmosDBConnectionModeGateway`
- `DBCosmosDBConnectionModeKey`
- `DBCosmosDBOperationTypeBatch`
- `DBCosmosDBOperationTypeCreate`
- `DBCosmosDBOperationTypeDelete`
- `DBCosmosDBOperationTypeExecute`
- `DBCosmosDBOperationTypeExecuteJavascript`
- `DBCosmosDBOperationTypeHead`
- `DBCosmosDBOperationTypeHeadFeed`
- `DBCosmosDBOperationTypeInvalid`
- `DBCosmosDBOperationTypeKey`
- `DBCosmosDBOperationTypePatch`
- `DBCosmosDBOperationTypeQuery`
- `DBCosmosDBOperationTypeQueryPlan`
- `DBCosmosDBOperationTypeRead`
- `DBCosmosDBOperationTypeReadFeed`
- `DBCosmosDBOperationTypeReplace`
- `DBCosmosDBOperationTypeUpsert`
- `DBCosmosDBRequestCharge`
- `DBCosmosDBRequestChargeKey`
- `DBCosmosDBRequestContentLength`
- `DBCosmosDBRequestContentLengthKey`
- `DBCosmosDBSubStatusCode`
- `DBCosmosDBSubStatusCodeKey`
- `DBElasticsearchNodeName`
- `DBElasticsearchNodeNameKey`
- `DBSystemAdabas`
- `DBSystemCache`
- `DBSystemCassandra`
- `DBSystemClickhouse`
- `DBSystemCloudscape`
- `DBSystemCockroachdb`
- `DBSystemColdfusion`
- `DBSystemCosmosDB`
- `DBSystemCouchDB`
- `DBSystemCouchbase`
- `DBSystemDb2`
- `DBSystemDerby`
- `DBSystemDynamoDB`
- `DBSystemEDB`
- `DBSystemElasticsearch`
- `DBSystemFilemaker`
- `DBSystemFirebird`
- `DBSystemFirstSQL`
- `DBSystemGeode`
- `DBSystemH2`
- `DBSystemHBase`
- `DBSystemHSQLDB`
- `DBSystemHanaDB`
- `DBSystemHive`
- `DBSystemInfluxdb`
- `DBSystemInformix`
- `DBSystemIngres`
- `DBSystemInstantDB`
- `DBSystemInterbase`
- `DBSystemIntersystemsCache`
- `DBSystemKey`
- `DBSystemMSSQL`
- `DBSystemMariaDB`
- `DBSystemMaxDB`
- `DBSystemMemcached`
- `DBSystemMongoDB`
- `DBSystemMssqlcompact`
- `DBSystemMySQL`
- `DBSystemNeo4j`
- `DBSystemNetezza`
- `DBSystemOpensearch`
- `DBSystemOracle`
- `DBSystemOtherSQL`
- `DBSystemPervasive`
- `DBSystemPointbase`
- `DBSystemPostgreSQL`
- `DBSystemProgress`
- `DBSystemRedis`
- `DBSystemRedshift`
- `DBSystemSpanner`
- `DBSystemSqlite`
- `DBSystemSybase`
- `DBSystemTeradata`
- `DBSystemTrino`
- `DBSystemVertica`
- `EventName`
- `EventNameKey`
- `ExceptionEscaped`
- `ExceptionEscapedKey`
- `GenAIOpenaiRequestSeed`
- `GenAIOpenaiRequestSeedKey`
- `ProcessExecutableBuildIDProfiling`
- `ProcessExecutableBuildIDProfilingKey`
- `SystemNetworkStateClose`
- `SystemNetworkStateCloseWait`
- `SystemNetworkStateClosing`
- `SystemNetworkStateDelete`
- `SystemNetworkStateEstablished`
- `SystemNetworkStateFinWait1`
- `SystemNetworkStateFinWait2`
- `SystemNetworkStateKey`
- `SystemNetworkStateLastAck`
- `SystemNetworkStateListen`
- `SystemNetworkStateSynRecv`
- `SystemNetworkStateSynSent`
- `SystemNetworkStateTimeWait`
- `VCSRepositoryChangeID`
- `VCSRepositoryChangeIDKey`
- `VCSRepositoryChangeTitle`
- `VCSRepositoryChangeTitleKey`
- `VCSRepositoryRefName`
- `VCSRepositoryRefNameKey`
- `VCSRepositoryRefRevision`
- `VCSRepositoryRefRevisionKey`
- `VCSRepositoryRefTypeBranch`
- `VCSRepositoryRefTypeKey`
- `VCSRepositoryRefTypeTag`
[OpenTelemetry Semantic Conventions]: https://github.com/open-telemetry/semantic-conventions

View File

@@ -1,3 +0,0 @@
# Semconv v1.30.0
[![PkgGoDev](https://pkg.go.dev/badge/go.opentelemetry.io/otel/semconv/v1.30.0)](https://pkg.go.dev/go.opentelemetry.io/otel/semconv/v1.30.0)

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +0,0 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
// Package semconv implements OpenTelemetry semantic conventions.
//
// OpenTelemetry semantic conventions are agreed standardized naming
// patterns for OpenTelemetry things. This package represents the v1.30.0
// version of the OpenTelemetry semantic conventions.
package semconv // import "go.opentelemetry.io/otel/semconv/v1.30.0"

View File

@@ -1,9 +0,0 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package semconv // import "go.opentelemetry.io/otel/semconv/v1.30.0"
const (
// ExceptionEventName is the name of the Span event representing an exception.
ExceptionEventName = "exception"
)

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +0,0 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package semconv // import "go.opentelemetry.io/otel/semconv/v1.30.0"
// SchemaURL is the schema URL that matches the version of the semantic conventions
// that this package defines. Semconv packages starting from v1.4.0 must declare
// non-empty schema URL in the form https://opentelemetry.io/schemas/<version>
const SchemaURL = "https://opentelemetry.io/schemas/1.30.0"

View File

@@ -0,0 +1,713 @@
// Code generated from semantic convention specification. DO NOT EDIT.
// Package httpconv provides types and functionality for OpenTelemetry semantic
// conventions in the "rpc" namespace.
package rpcconv
import (
"context"
"sync"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/noop"
)
var (
addOptPool = &sync.Pool{New: func() any { return &[]metric.AddOption{} }}
recOptPool = &sync.Pool{New: func() any { return &[]metric.RecordOption{} }}
)
// ClientDuration is an instrument used to record metric values conforming to the
// "rpc.client.duration" semantic conventions. It represents the measures the
// duration of outbound RPC.
type ClientDuration struct {
metric.Float64Histogram
}
// NewClientDuration returns a new ClientDuration instrument.
func NewClientDuration(
m metric.Meter,
opt ...metric.Float64HistogramOption,
) (ClientDuration, error) {
// Check if the meter is nil.
if m == nil {
return ClientDuration{noop.Float64Histogram{}}, nil
}
i, err := m.Float64Histogram(
"rpc.client.duration",
append([]metric.Float64HistogramOption{
metric.WithDescription("Measures the duration of outbound RPC."),
metric.WithUnit("ms"),
}, opt...)...,
)
if err != nil {
return ClientDuration{noop.Float64Histogram{}}, err
}
return ClientDuration{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ClientDuration) Inst() metric.Float64Histogram {
return m.Float64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ClientDuration) Name() string {
return "rpc.client.duration"
}
// Unit returns the semantic convention unit of the instrument
func (ClientDuration) Unit() string {
return "ms"
}
// Description returns the semantic convention description of the instrument
func (ClientDuration) Description() string {
return "Measures the duration of outbound RPC."
}
// Record records val to the current distribution.
//
// While streaming RPCs may record this metric as start-of-batch
// to end-of-batch, it's hard to interpret in practice.
//
// **Streaming**: N/A.
func (m ClientDuration) Record(ctx context.Context, val float64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Float64Histogram.Record(ctx, val)
}
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Float64Histogram.Record(ctx, val, *o...)
}
// ClientRequestSize is an instrument used to record metric values conforming to
// the "rpc.client.request.size" semantic conventions. It represents the measures
// the size of RPC request messages (uncompressed).
type ClientRequestSize struct {
metric.Int64Histogram
}
// NewClientRequestSize returns a new ClientRequestSize instrument.
func NewClientRequestSize(
m metric.Meter,
opt ...metric.Int64HistogramOption,
) (ClientRequestSize, error) {
// Check if the meter is nil.
if m == nil {
return ClientRequestSize{noop.Int64Histogram{}}, nil
}
i, err := m.Int64Histogram(
"rpc.client.request.size",
append([]metric.Int64HistogramOption{
metric.WithDescription("Measures the size of RPC request messages (uncompressed)."),
metric.WithUnit("By"),
}, opt...)...,
)
if err != nil {
return ClientRequestSize{noop.Int64Histogram{}}, err
}
return ClientRequestSize{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ClientRequestSize) Inst() metric.Int64Histogram {
return m.Int64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ClientRequestSize) Name() string {
return "rpc.client.request.size"
}
// Unit returns the semantic convention unit of the instrument
func (ClientRequestSize) Unit() string {
return "By"
}
// Description returns the semantic convention description of the instrument
func (ClientRequestSize) Description() string {
return "Measures the size of RPC request messages (uncompressed)."
}
// Record records val to the current distribution.
//
// **Streaming**: Recorded per message in a streaming batch
func (m ClientRequestSize) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Int64Histogram.Record(ctx, val)
}
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Int64Histogram.Record(ctx, val, *o...)
}
// ClientRequestsPerRPC is an instrument used to record metric values conforming
// to the "rpc.client.requests_per_rpc" semantic conventions. It represents the
// measures the number of messages received per RPC.
type ClientRequestsPerRPC struct {
metric.Int64Histogram
}
// NewClientRequestsPerRPC returns a new ClientRequestsPerRPC instrument.
func NewClientRequestsPerRPC(
m metric.Meter,
opt ...metric.Int64HistogramOption,
) (ClientRequestsPerRPC, error) {
// Check if the meter is nil.
if m == nil {
return ClientRequestsPerRPC{noop.Int64Histogram{}}, nil
}
i, err := m.Int64Histogram(
"rpc.client.requests_per_rpc",
append([]metric.Int64HistogramOption{
metric.WithDescription("Measures the number of messages received per RPC."),
metric.WithUnit("{count}"),
}, opt...)...,
)
if err != nil {
return ClientRequestsPerRPC{noop.Int64Histogram{}}, err
}
return ClientRequestsPerRPC{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ClientRequestsPerRPC) Inst() metric.Int64Histogram {
return m.Int64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ClientRequestsPerRPC) Name() string {
return "rpc.client.requests_per_rpc"
}
// Unit returns the semantic convention unit of the instrument
func (ClientRequestsPerRPC) Unit() string {
return "{count}"
}
// Description returns the semantic convention description of the instrument
func (ClientRequestsPerRPC) Description() string {
return "Measures the number of messages received per RPC."
}
// Record records val to the current distribution.
//
// Should be 1 for all non-streaming RPCs.
//
// **Streaming**: This metric is required for server and client streaming RPCs
func (m ClientRequestsPerRPC) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Int64Histogram.Record(ctx, val)
}
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Int64Histogram.Record(ctx, val, *o...)
}
// ClientResponseSize is an instrument used to record metric values conforming to
// the "rpc.client.response.size" semantic conventions. It represents the
// measures the size of RPC response messages (uncompressed).
type ClientResponseSize struct {
metric.Int64Histogram
}
// NewClientResponseSize returns a new ClientResponseSize instrument.
func NewClientResponseSize(
m metric.Meter,
opt ...metric.Int64HistogramOption,
) (ClientResponseSize, error) {
// Check if the meter is nil.
if m == nil {
return ClientResponseSize{noop.Int64Histogram{}}, nil
}
i, err := m.Int64Histogram(
"rpc.client.response.size",
append([]metric.Int64HistogramOption{
metric.WithDescription("Measures the size of RPC response messages (uncompressed)."),
metric.WithUnit("By"),
}, opt...)...,
)
if err != nil {
return ClientResponseSize{noop.Int64Histogram{}}, err
}
return ClientResponseSize{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ClientResponseSize) Inst() metric.Int64Histogram {
return m.Int64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ClientResponseSize) Name() string {
return "rpc.client.response.size"
}
// Unit returns the semantic convention unit of the instrument
func (ClientResponseSize) Unit() string {
return "By"
}
// Description returns the semantic convention description of the instrument
func (ClientResponseSize) Description() string {
return "Measures the size of RPC response messages (uncompressed)."
}
// Record records val to the current distribution.
//
// **Streaming**: Recorded per response in a streaming batch
func (m ClientResponseSize) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Int64Histogram.Record(ctx, val)
}
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Int64Histogram.Record(ctx, val, *o...)
}
// ClientResponsesPerRPC is an instrument used to record metric values conforming
// to the "rpc.client.responses_per_rpc" semantic conventions. It represents the
// measures the number of messages sent per RPC.
type ClientResponsesPerRPC struct {
metric.Int64Histogram
}
// NewClientResponsesPerRPC returns a new ClientResponsesPerRPC instrument.
func NewClientResponsesPerRPC(
m metric.Meter,
opt ...metric.Int64HistogramOption,
) (ClientResponsesPerRPC, error) {
// Check if the meter is nil.
if m == nil {
return ClientResponsesPerRPC{noop.Int64Histogram{}}, nil
}
i, err := m.Int64Histogram(
"rpc.client.responses_per_rpc",
append([]metric.Int64HistogramOption{
metric.WithDescription("Measures the number of messages sent per RPC."),
metric.WithUnit("{count}"),
}, opt...)...,
)
if err != nil {
return ClientResponsesPerRPC{noop.Int64Histogram{}}, err
}
return ClientResponsesPerRPC{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ClientResponsesPerRPC) Inst() metric.Int64Histogram {
return m.Int64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ClientResponsesPerRPC) Name() string {
return "rpc.client.responses_per_rpc"
}
// Unit returns the semantic convention unit of the instrument
func (ClientResponsesPerRPC) Unit() string {
return "{count}"
}
// Description returns the semantic convention description of the instrument
func (ClientResponsesPerRPC) Description() string {
return "Measures the number of messages sent per RPC."
}
// Record records val to the current distribution.
//
// Should be 1 for all non-streaming RPCs.
//
// **Streaming**: This metric is required for server and client streaming RPCs
func (m ClientResponsesPerRPC) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Int64Histogram.Record(ctx, val)
}
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Int64Histogram.Record(ctx, val, *o...)
}
// ServerDuration is an instrument used to record metric values conforming to the
// "rpc.server.duration" semantic conventions. It represents the measures the
// duration of inbound RPC.
type ServerDuration struct {
metric.Float64Histogram
}
// NewServerDuration returns a new ServerDuration instrument.
func NewServerDuration(
m metric.Meter,
opt ...metric.Float64HistogramOption,
) (ServerDuration, error) {
// Check if the meter is nil.
if m == nil {
return ServerDuration{noop.Float64Histogram{}}, nil
}
i, err := m.Float64Histogram(
"rpc.server.duration",
append([]metric.Float64HistogramOption{
metric.WithDescription("Measures the duration of inbound RPC."),
metric.WithUnit("ms"),
}, opt...)...,
)
if err != nil {
return ServerDuration{noop.Float64Histogram{}}, err
}
return ServerDuration{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ServerDuration) Inst() metric.Float64Histogram {
return m.Float64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ServerDuration) Name() string {
return "rpc.server.duration"
}
// Unit returns the semantic convention unit of the instrument
func (ServerDuration) Unit() string {
return "ms"
}
// Description returns the semantic convention description of the instrument
func (ServerDuration) Description() string {
return "Measures the duration of inbound RPC."
}
// Record records val to the current distribution.
//
// While streaming RPCs may record this metric as start-of-batch
// to end-of-batch, it's hard to interpret in practice.
//
// **Streaming**: N/A.
func (m ServerDuration) Record(ctx context.Context, val float64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Float64Histogram.Record(ctx, val)
}
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Float64Histogram.Record(ctx, val, *o...)
}
// ServerRequestSize is an instrument used to record metric values conforming to
// the "rpc.server.request.size" semantic conventions. It represents the measures
// the size of RPC request messages (uncompressed).
type ServerRequestSize struct {
metric.Int64Histogram
}
// NewServerRequestSize returns a new ServerRequestSize instrument.
func NewServerRequestSize(
m metric.Meter,
opt ...metric.Int64HistogramOption,
) (ServerRequestSize, error) {
// Check if the meter is nil.
if m == nil {
return ServerRequestSize{noop.Int64Histogram{}}, nil
}
i, err := m.Int64Histogram(
"rpc.server.request.size",
append([]metric.Int64HistogramOption{
metric.WithDescription("Measures the size of RPC request messages (uncompressed)."),
metric.WithUnit("By"),
}, opt...)...,
)
if err != nil {
return ServerRequestSize{noop.Int64Histogram{}}, err
}
return ServerRequestSize{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ServerRequestSize) Inst() metric.Int64Histogram {
return m.Int64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ServerRequestSize) Name() string {
return "rpc.server.request.size"
}
// Unit returns the semantic convention unit of the instrument
func (ServerRequestSize) Unit() string {
return "By"
}
// Description returns the semantic convention description of the instrument
func (ServerRequestSize) Description() string {
return "Measures the size of RPC request messages (uncompressed)."
}
// Record records val to the current distribution.
//
// **Streaming**: Recorded per message in a streaming batch
func (m ServerRequestSize) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Int64Histogram.Record(ctx, val)
}
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Int64Histogram.Record(ctx, val, *o...)
}
// ServerRequestsPerRPC is an instrument used to record metric values conforming
// to the "rpc.server.requests_per_rpc" semantic conventions. It represents the
// measures the number of messages received per RPC.
type ServerRequestsPerRPC struct {
metric.Int64Histogram
}
// NewServerRequestsPerRPC returns a new ServerRequestsPerRPC instrument.
func NewServerRequestsPerRPC(
m metric.Meter,
opt ...metric.Int64HistogramOption,
) (ServerRequestsPerRPC, error) {
// Check if the meter is nil.
if m == nil {
return ServerRequestsPerRPC{noop.Int64Histogram{}}, nil
}
i, err := m.Int64Histogram(
"rpc.server.requests_per_rpc",
append([]metric.Int64HistogramOption{
metric.WithDescription("Measures the number of messages received per RPC."),
metric.WithUnit("{count}"),
}, opt...)...,
)
if err != nil {
return ServerRequestsPerRPC{noop.Int64Histogram{}}, err
}
return ServerRequestsPerRPC{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ServerRequestsPerRPC) Inst() metric.Int64Histogram {
return m.Int64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ServerRequestsPerRPC) Name() string {
return "rpc.server.requests_per_rpc"
}
// Unit returns the semantic convention unit of the instrument
func (ServerRequestsPerRPC) Unit() string {
return "{count}"
}
// Description returns the semantic convention description of the instrument
func (ServerRequestsPerRPC) Description() string {
return "Measures the number of messages received per RPC."
}
// Record records val to the current distribution.
//
// Should be 1 for all non-streaming RPCs.
//
// **Streaming** : This metric is required for server and client streaming RPCs
func (m ServerRequestsPerRPC) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Int64Histogram.Record(ctx, val)
}
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Int64Histogram.Record(ctx, val, *o...)
}
// ServerResponseSize is an instrument used to record metric values conforming to
// the "rpc.server.response.size" semantic conventions. It represents the
// measures the size of RPC response messages (uncompressed).
type ServerResponseSize struct {
metric.Int64Histogram
}
// NewServerResponseSize returns a new ServerResponseSize instrument.
func NewServerResponseSize(
m metric.Meter,
opt ...metric.Int64HistogramOption,
) (ServerResponseSize, error) {
// Check if the meter is nil.
if m == nil {
return ServerResponseSize{noop.Int64Histogram{}}, nil
}
i, err := m.Int64Histogram(
"rpc.server.response.size",
append([]metric.Int64HistogramOption{
metric.WithDescription("Measures the size of RPC response messages (uncompressed)."),
metric.WithUnit("By"),
}, opt...)...,
)
if err != nil {
return ServerResponseSize{noop.Int64Histogram{}}, err
}
return ServerResponseSize{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ServerResponseSize) Inst() metric.Int64Histogram {
return m.Int64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ServerResponseSize) Name() string {
return "rpc.server.response.size"
}
// Unit returns the semantic convention unit of the instrument
func (ServerResponseSize) Unit() string {
return "By"
}
// Description returns the semantic convention description of the instrument
func (ServerResponseSize) Description() string {
return "Measures the size of RPC response messages (uncompressed)."
}
// Record records val to the current distribution.
//
// **Streaming**: Recorded per response in a streaming batch
func (m ServerResponseSize) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Int64Histogram.Record(ctx, val)
}
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Int64Histogram.Record(ctx, val, *o...)
}
// ServerResponsesPerRPC is an instrument used to record metric values conforming
// to the "rpc.server.responses_per_rpc" semantic conventions. It represents the
// measures the number of messages sent per RPC.
type ServerResponsesPerRPC struct {
metric.Int64Histogram
}
// NewServerResponsesPerRPC returns a new ServerResponsesPerRPC instrument.
func NewServerResponsesPerRPC(
m metric.Meter,
opt ...metric.Int64HistogramOption,
) (ServerResponsesPerRPC, error) {
// Check if the meter is nil.
if m == nil {
return ServerResponsesPerRPC{noop.Int64Histogram{}}, nil
}
i, err := m.Int64Histogram(
"rpc.server.responses_per_rpc",
append([]metric.Int64HistogramOption{
metric.WithDescription("Measures the number of messages sent per RPC."),
metric.WithUnit("{count}"),
}, opt...)...,
)
if err != nil {
return ServerResponsesPerRPC{noop.Int64Histogram{}}, err
}
return ServerResponsesPerRPC{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ServerResponsesPerRPC) Inst() metric.Int64Histogram {
return m.Int64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ServerResponsesPerRPC) Name() string {
return "rpc.server.responses_per_rpc"
}
// Unit returns the semantic convention unit of the instrument
func (ServerResponsesPerRPC) Unit() string {
return "{count}"
}
// Description returns the semantic convention description of the instrument
func (ServerResponsesPerRPC) Description() string {
return "Measures the number of messages sent per RPC."
}
// Record records val to the current distribution.
//
// Should be 1 for all non-streaming RPCs.
//
// **Streaming**: This metric is required for server and client streaming RPCs
func (m ServerResponsesPerRPC) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Int64Histogram.Record(ctx, val)
}
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Int64Histogram.Record(ctx, val, *o...)
}

4
vendor/modules.txt vendored
View File

@@ -2057,7 +2057,7 @@ go.opencensus.io/trace/tracestate
## explicit; go 1.22.0
go.opentelemetry.io/auto/sdk
go.opentelemetry.io/auto/sdk/internal/telemetry
# go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0
# go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.62.0
## explicit; go 1.23.0
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/internal
@@ -2088,8 +2088,8 @@ go.opentelemetry.io/otel/semconv/v1.20.0
go.opentelemetry.io/otel/semconv/v1.20.0/httpconv
go.opentelemetry.io/otel/semconv/v1.21.0
go.opentelemetry.io/otel/semconv/v1.26.0
go.opentelemetry.io/otel/semconv/v1.30.0
go.opentelemetry.io/otel/semconv/v1.34.0
go.opentelemetry.io/otel/semconv/v1.34.0/rpcconv
go.opentelemetry.io/otel/semconv/v1.4.0
# go.opentelemetry.io/otel/exporters/jaeger v1.17.0
## explicit; go 1.19