mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-07 12:50:21 -06:00
Merge pull request #915 from opencloud-eu/dependabot/go_modules/go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc-0.61.0
build(deps): bump go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc from 0.60.0 to 0.61.0
This commit is contained in:
2
go.mod
2
go.mod
@@ -88,7 +88,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.0
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.60.0
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0
|
||||
go.opentelemetry.io/contrib/zpages v0.61.0
|
||||
go.opentelemetry.io/otel v1.36.0
|
||||
|
||||
4
go.sum
4
go.sum
@@ -1166,8 +1166,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.60.0 h1:x7wzEgXfnzJcHDwStJT+mxOz4etr2EcexjqhBvmoakw=
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.60.0/go.mod h1:rg+RlpR5dKwaS95IyyZqj5Wd4E13lk/msnTS0Xl9lJM=
|
||||
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/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.61.0 h1:tYvUj377Dn3k1wf1le/f8YWSNQ8k0byS3jK8PiIXu9Y=
|
||||
|
||||
102
vendor/go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/config.go
generated
vendored
102
vendor/go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/config.go
generated
vendored
@@ -9,18 +9,12 @@ import (
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/noop"
|
||||
"go.opentelemetry.io/otel/propagation"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
const (
|
||||
// ScopeName is the instrumentation scope name.
|
||||
ScopeName = "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
|
||||
// GRPCStatusCodeKey is convention for numeric status code of a gRPC request.
|
||||
GRPCStatusCodeKey = attribute.Key("rpc.grpc.status_code")
|
||||
)
|
||||
// ScopeName is the instrumentation scope name.
|
||||
const ScopeName = "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
|
||||
|
||||
// InterceptorFilter is a predicate used to determine whether a given request in
|
||||
// interceptor info should be instrumented. A InterceptorFilter must return true if
|
||||
@@ -47,15 +41,6 @@ type config struct {
|
||||
|
||||
ReceivedEvent bool
|
||||
SentEvent bool
|
||||
|
||||
tracer trace.Tracer
|
||||
meter metric.Meter
|
||||
|
||||
rpcDuration metric.Float64Histogram
|
||||
rpcInBytes metric.Int64Histogram
|
||||
rpcOutBytes metric.Int64Histogram
|
||||
rpcInMessages metric.Int64Histogram
|
||||
rpcOutMessages metric.Int64Histogram
|
||||
}
|
||||
|
||||
// Option applies an option value for a config.
|
||||
@@ -64,7 +49,7 @@ type Option interface {
|
||||
}
|
||||
|
||||
// newConfig returns a config configured with all the passed Options.
|
||||
func newConfig(opts []Option, role string) *config {
|
||||
func newConfig(opts []Option) *config {
|
||||
c := &config{
|
||||
Propagators: otel.GetTextMapPropagator(),
|
||||
TracerProvider: otel.GetTracerProvider(),
|
||||
@@ -73,87 +58,6 @@ func newConfig(opts []Option, role string) *config {
|
||||
for _, o := range opts {
|
||||
o.apply(c)
|
||||
}
|
||||
|
||||
c.tracer = c.TracerProvider.Tracer(
|
||||
ScopeName,
|
||||
trace.WithInstrumentationVersion(SemVersion()),
|
||||
)
|
||||
|
||||
c.meter = c.MeterProvider.Meter(
|
||||
ScopeName,
|
||||
metric.WithInstrumentationVersion(Version()),
|
||||
metric.WithSchemaURL(semconv.SchemaURL),
|
||||
)
|
||||
|
||||
var err error
|
||||
c.rpcDuration, err = c.meter.Float64Histogram("rpc."+role+".duration",
|
||||
metric.WithDescription("Measures the duration of inbound RPC."),
|
||||
metric.WithUnit("ms"))
|
||||
if err != nil {
|
||||
otel.Handle(err)
|
||||
if c.rpcDuration == nil {
|
||||
c.rpcDuration = noop.Float64Histogram{}
|
||||
}
|
||||
}
|
||||
|
||||
rpcRequestSize, err := c.meter.Int64Histogram("rpc."+role+".request.size",
|
||||
metric.WithDescription("Measures size of RPC request messages (uncompressed)."),
|
||||
metric.WithUnit("By"))
|
||||
if err != nil {
|
||||
otel.Handle(err)
|
||||
if rpcRequestSize == nil {
|
||||
rpcRequestSize = noop.Int64Histogram{}
|
||||
}
|
||||
}
|
||||
|
||||
rpcResponseSize, err := c.meter.Int64Histogram("rpc."+role+".response.size",
|
||||
metric.WithDescription("Measures size of RPC response messages (uncompressed)."),
|
||||
metric.WithUnit("By"))
|
||||
if err != nil {
|
||||
otel.Handle(err)
|
||||
if rpcResponseSize == nil {
|
||||
rpcResponseSize = noop.Int64Histogram{}
|
||||
}
|
||||
}
|
||||
|
||||
rpcRequestsPerRPC, err := c.meter.Int64Histogram("rpc."+role+".requests_per_rpc",
|
||||
metric.WithDescription("Measures the number of messages received per RPC. Should be 1 for all non-streaming RPCs."),
|
||||
metric.WithUnit("{count}"))
|
||||
if err != nil {
|
||||
otel.Handle(err)
|
||||
if rpcRequestsPerRPC == nil {
|
||||
rpcRequestsPerRPC = noop.Int64Histogram{}
|
||||
}
|
||||
}
|
||||
|
||||
rpcResponsesPerRPC, err := c.meter.Int64Histogram("rpc."+role+".responses_per_rpc",
|
||||
metric.WithDescription("Measures the number of messages received per RPC. Should be 1 for all non-streaming RPCs."),
|
||||
metric.WithUnit("{count}"))
|
||||
if err != nil {
|
||||
otel.Handle(err)
|
||||
if rpcResponsesPerRPC == nil {
|
||||
rpcResponsesPerRPC = noop.Int64Histogram{}
|
||||
}
|
||||
}
|
||||
|
||||
switch role {
|
||||
case "client":
|
||||
c.rpcInBytes = rpcResponseSize
|
||||
c.rpcInMessages = rpcResponsesPerRPC
|
||||
c.rpcOutBytes = rpcRequestSize
|
||||
c.rpcOutMessages = rpcRequestsPerRPC
|
||||
case "server":
|
||||
c.rpcInBytes = rpcRequestSize
|
||||
c.rpcInMessages = rpcRequestsPerRPC
|
||||
c.rpcOutBytes = rpcResponseSize
|
||||
c.rpcOutMessages = rpcResponsesPerRPC
|
||||
default:
|
||||
c.rpcInBytes = noop.Int64Histogram{}
|
||||
c.rpcInMessages = noop.Int64Histogram{}
|
||||
c.rpcOutBytes = noop.Int64Histogram{}
|
||||
c.rpcOutMessages = noop.Int64Histogram{}
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"io"
|
||||
"net"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
grpc_codes "google.golang.org/grpc/codes"
|
||||
@@ -23,8 +22,7 @@ import (
|
||||
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/internal"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.30.0"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
@@ -39,82 +37,15 @@ func (m messageType) Event(ctx context.Context, id int, _ interface{}) {
|
||||
}
|
||||
span.AddEvent("message", trace.WithAttributes(
|
||||
attribute.KeyValue(m),
|
||||
RPCMessageIDKey.Int(id),
|
||||
semconv.RPCMessageIDKey.Int(id),
|
||||
))
|
||||
}
|
||||
|
||||
var (
|
||||
messageSent = messageType(RPCMessageTypeSent)
|
||||
messageReceived = messageType(RPCMessageTypeReceived)
|
||||
messageSent = messageType(semconv.RPCMessageTypeSent)
|
||||
messageReceived = messageType(semconv.RPCMessageTypeReceived)
|
||||
)
|
||||
|
||||
// UnaryClientInterceptor returns a grpc.UnaryClientInterceptor suitable
|
||||
// for use in a grpc.NewClient call.
|
||||
//
|
||||
// Deprecated: Use [NewClientHandler] instead.
|
||||
func UnaryClientInterceptor(opts ...Option) grpc.UnaryClientInterceptor {
|
||||
cfg := newConfig(opts, "client")
|
||||
tracer := cfg.TracerProvider.Tracer(
|
||||
ScopeName,
|
||||
trace.WithInstrumentationVersion(Version()),
|
||||
)
|
||||
|
||||
return func(
|
||||
ctx context.Context,
|
||||
method string,
|
||||
req, reply interface{},
|
||||
cc *grpc.ClientConn,
|
||||
invoker grpc.UnaryInvoker,
|
||||
callOpts ...grpc.CallOption,
|
||||
) error {
|
||||
i := &InterceptorInfo{
|
||||
Method: method,
|
||||
Type: UnaryClient,
|
||||
}
|
||||
if cfg.InterceptorFilter != nil && !cfg.InterceptorFilter(i) {
|
||||
return invoker(ctx, method, req, reply, cc, callOpts...)
|
||||
}
|
||||
|
||||
name, attr, _ := telemetryAttributes(method, cc.Target())
|
||||
|
||||
startOpts := append([]trace.SpanStartOption{
|
||||
trace.WithSpanKind(trace.SpanKindClient),
|
||||
trace.WithAttributes(attr...),
|
||||
},
|
||||
cfg.SpanStartOptions...,
|
||||
)
|
||||
|
||||
ctx, span := tracer.Start(
|
||||
ctx,
|
||||
name,
|
||||
startOpts...,
|
||||
)
|
||||
defer span.End()
|
||||
|
||||
ctx = inject(ctx, cfg.Propagators)
|
||||
|
||||
if cfg.SentEvent {
|
||||
messageSent.Event(ctx, 1, req)
|
||||
}
|
||||
|
||||
err := invoker(ctx, method, req, reply, cc, callOpts...)
|
||||
|
||||
if cfg.ReceivedEvent {
|
||||
messageReceived.Event(ctx, 1, reply)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
s, _ := status.FromError(err)
|
||||
span.SetStatus(codes.Error, s.Message())
|
||||
span.SetAttributes(statusCodeAttr(s.Code()))
|
||||
} else {
|
||||
span.SetAttributes(statusCodeAttr(grpc_codes.OK))
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// clientStream wraps around the embedded grpc.ClientStream, and intercepts the RecvMsg and
|
||||
// SendMsg method call.
|
||||
type clientStream struct {
|
||||
@@ -213,7 +144,7 @@ func (w *clientStream) endSpan(err error) {
|
||||
//
|
||||
// Deprecated: Use [NewClientHandler] instead.
|
||||
func StreamClientInterceptor(opts ...Option) grpc.StreamClientInterceptor {
|
||||
cfg := newConfig(opts, "client")
|
||||
cfg := newConfig(opts)
|
||||
tracer := cfg.TracerProvider.Tracer(
|
||||
ScopeName,
|
||||
trace.WithInstrumentationVersion(Version()),
|
||||
@@ -235,7 +166,7 @@ func StreamClientInterceptor(opts ...Option) grpc.StreamClientInterceptor {
|
||||
return streamer(ctx, desc, cc, method, callOpts...)
|
||||
}
|
||||
|
||||
name, attr, _ := telemetryAttributes(method, cc.Target())
|
||||
name, attr := telemetryAttributes(method, cc.Target())
|
||||
|
||||
startOpts := append([]trace.SpanStartOption{
|
||||
trace.WithSpanKind(trace.SpanKindClient),
|
||||
@@ -265,81 +196,6 @@ func StreamClientInterceptor(opts ...Option) grpc.StreamClientInterceptor {
|
||||
}
|
||||
}
|
||||
|
||||
// UnaryServerInterceptor returns a grpc.UnaryServerInterceptor suitable
|
||||
// for use in a grpc.NewServer call.
|
||||
//
|
||||
// Deprecated: Use [NewServerHandler] instead.
|
||||
func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor {
|
||||
cfg := newConfig(opts, "server")
|
||||
tracer := cfg.TracerProvider.Tracer(
|
||||
ScopeName,
|
||||
trace.WithInstrumentationVersion(Version()),
|
||||
)
|
||||
|
||||
return func(
|
||||
ctx context.Context,
|
||||
req interface{},
|
||||
info *grpc.UnaryServerInfo,
|
||||
handler grpc.UnaryHandler,
|
||||
) (interface{}, error) {
|
||||
i := &InterceptorInfo{
|
||||
UnaryServerInfo: info,
|
||||
Type: UnaryServer,
|
||||
}
|
||||
if cfg.InterceptorFilter != nil && !cfg.InterceptorFilter(i) {
|
||||
return handler(ctx, req)
|
||||
}
|
||||
|
||||
ctx = extract(ctx, cfg.Propagators)
|
||||
name, attr, metricAttrs := 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()
|
||||
|
||||
if cfg.ReceivedEvent {
|
||||
messageReceived.Event(ctx, 1, req)
|
||||
}
|
||||
|
||||
before := time.Now()
|
||||
|
||||
resp, err := handler(ctx, req)
|
||||
|
||||
s, _ := status.FromError(err)
|
||||
if err != nil {
|
||||
statusCode, msg := serverStatus(s)
|
||||
span.SetStatus(statusCode, msg)
|
||||
if cfg.SentEvent {
|
||||
messageSent.Event(ctx, 1, s.Proto())
|
||||
}
|
||||
} else {
|
||||
if cfg.SentEvent {
|
||||
messageSent.Event(ctx, 1, resp)
|
||||
}
|
||||
}
|
||||
grpcStatusCodeAttr := statusCodeAttr(s.Code())
|
||||
span.SetAttributes(grpcStatusCodeAttr)
|
||||
|
||||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||||
elapsedTime := float64(time.Since(before)) / float64(time.Millisecond)
|
||||
|
||||
metricAttrs = append(metricAttrs, grpcStatusCodeAttr)
|
||||
cfg.rpcDuration.Record(ctx, elapsedTime, metric.WithAttributeSet(attribute.NewSet(metricAttrs...)))
|
||||
|
||||
return resp, err
|
||||
}
|
||||
}
|
||||
|
||||
// serverStream wraps around the embedded grpc.ServerStream, and intercepts the RecvMsg and
|
||||
// SendMsg method call.
|
||||
type serverStream struct {
|
||||
@@ -395,7 +251,7 @@ func wrapServerStream(ctx context.Context, ss grpc.ServerStream, cfg *config) *s
|
||||
//
|
||||
// Deprecated: Use [NewServerHandler] instead.
|
||||
func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor {
|
||||
cfg := newConfig(opts, "server")
|
||||
cfg := newConfig(opts)
|
||||
tracer := cfg.TracerProvider.Tracer(
|
||||
ScopeName,
|
||||
trace.WithInstrumentationVersion(Version()),
|
||||
@@ -417,7 +273,7 @@ func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor {
|
||||
}
|
||||
|
||||
ctx = extract(ctx, cfg.Propagators)
|
||||
name, attr, _ := telemetryAttributes(info.FullMethod, peerFromCtx(ctx))
|
||||
name, attr := telemetryAttributes(info.FullMethod, peerFromCtx(ctx))
|
||||
|
||||
startOpts := append([]trace.SpanStartOption{
|
||||
trace.WithSpanKind(trace.SpanKindServer),
|
||||
@@ -449,47 +305,32 @@ func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor {
|
||||
|
||||
// telemetryAttributes returns a span name and span and metric attributes from
|
||||
// the gRPC method and peer address.
|
||||
func telemetryAttributes(fullMethod, peerAddress string) (string, []attribute.KeyValue, []attribute.KeyValue) {
|
||||
func telemetryAttributes(fullMethod, sererAddr string) (string, []attribute.KeyValue) {
|
||||
name, methodAttrs := internal.ParseFullMethod(fullMethod)
|
||||
peerAttrs := peerAttr(peerAddress)
|
||||
srvAttrs := serverAddrAttrs(sererAddr)
|
||||
|
||||
attrs := make([]attribute.KeyValue, 0, 1+len(methodAttrs)+len(peerAttrs))
|
||||
attrs = append(attrs, RPCSystemGRPC)
|
||||
attrs := make([]attribute.KeyValue, 0, 1+len(methodAttrs)+len(srvAttrs))
|
||||
attrs = append(attrs, semconv.RPCSystemGRPC)
|
||||
attrs = append(attrs, methodAttrs...)
|
||||
metricAttrs := attrs[:1+len(methodAttrs)]
|
||||
attrs = append(attrs, peerAttrs...)
|
||||
return name, attrs, metricAttrs
|
||||
attrs = append(attrs, srvAttrs...)
|
||||
return name, attrs
|
||||
}
|
||||
|
||||
// peerAttr returns attributes about the peer address.
|
||||
func peerAttr(addr string) []attribute.KeyValue {
|
||||
host, p, err := net.SplitHostPort(addr)
|
||||
// serverAddrAttrs returns the server address attributes for the hostport.
|
||||
func serverAddrAttrs(hostport string) []attribute.KeyValue {
|
||||
h, pStr, err := net.SplitHostPort(hostport)
|
||||
if err != nil {
|
||||
return nil
|
||||
// The server.address attribute is required.
|
||||
return []attribute.KeyValue{semconv.ServerAddress(hostport)}
|
||||
}
|
||||
|
||||
if host == "" {
|
||||
host = "127.0.0.1"
|
||||
}
|
||||
port, err := strconv.Atoi(p)
|
||||
p, err := strconv.Atoi(pStr)
|
||||
if err != nil {
|
||||
return nil
|
||||
return []attribute.KeyValue{semconv.ServerAddress(h)}
|
||||
}
|
||||
|
||||
var attr []attribute.KeyValue
|
||||
if ip := net.ParseIP(host); ip != nil {
|
||||
attr = []attribute.KeyValue{
|
||||
semconv.NetSockPeerAddr(host),
|
||||
semconv.NetSockPeerPort(port),
|
||||
}
|
||||
} else {
|
||||
attr = []attribute.KeyValue{
|
||||
semconv.NetPeerName(host),
|
||||
semconv.NetPeerPort(port),
|
||||
}
|
||||
return []attribute.KeyValue{
|
||||
semconv.ServerAddress(h),
|
||||
semconv.ServerPort(p),
|
||||
}
|
||||
|
||||
return attr
|
||||
}
|
||||
|
||||
// peerFromCtx returns a peer address from a context, if one exists.
|
||||
@@ -503,7 +344,7 @@ func peerFromCtx(ctx context.Context) string {
|
||||
|
||||
// statusCodeAttr returns status code attribute based on given gRPC code.
|
||||
func statusCodeAttr(c grpc_codes.Code) attribute.KeyValue {
|
||||
return GRPCStatusCodeKey.Int64(int64(c))
|
||||
return semconv.RPCGRPCStatusCodeKey.Int64(int64(c))
|
||||
}
|
||||
|
||||
// serverStatus returns a span status code and message for a given gRPC
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Package internal provides internal functionality for the otelgrpc package.
|
||||
package internal // import "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/internal"
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.30.0"
|
||||
)
|
||||
|
||||
// ParseFullMethod returns a span name following the OpenTelemetry semantic
|
||||
|
||||
@@ -45,7 +45,7 @@ func (s *metadataSupplier) Keys() []string {
|
||||
// requests.
|
||||
// Deprecated: Unnecessary public func.
|
||||
func Inject(ctx context.Context, md *metadata.MD, opts ...Option) {
|
||||
c := newConfig(opts, "")
|
||||
c := newConfig(opts)
|
||||
c.Propagators.Inject(ctx, &metadataSupplier{
|
||||
metadata: md,
|
||||
})
|
||||
@@ -67,7 +67,7 @@ func inject(ctx context.Context, propagators propagation.TextMapPropagator) cont
|
||||
// This function is meant to be used on incoming requests.
|
||||
// Deprecated: Unnecessary public func.
|
||||
func Extract(ctx context.Context, md *metadata.MD, opts ...Option) (baggage.Baggage, trace.SpanContext) {
|
||||
c := newConfig(opts, "")
|
||||
c := newConfig(opts)
|
||||
ctx = c.Propagators.Extract(ctx, &metadataSupplier{
|
||||
metadata: md,
|
||||
})
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package otelgrpc // import "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
|
||||
|
||||
import (
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
|
||||
)
|
||||
|
||||
// Semantic conventions for attribute keys for gRPC.
|
||||
const (
|
||||
// Name of message transmitted or received.
|
||||
RPCNameKey = attribute.Key("name")
|
||||
|
||||
// Type of message transmitted or received.
|
||||
RPCMessageTypeKey = attribute.Key("message.type")
|
||||
|
||||
// Identifier of message transmitted or received.
|
||||
RPCMessageIDKey = attribute.Key("message.id")
|
||||
|
||||
// The compressed size of the message transmitted or received in bytes.
|
||||
RPCMessageCompressedSizeKey = attribute.Key("message.compressed_size")
|
||||
|
||||
// The uncompressed size of the message transmitted or received in
|
||||
// bytes.
|
||||
RPCMessageUncompressedSizeKey = attribute.Key("message.uncompressed_size")
|
||||
)
|
||||
|
||||
// Semantic conventions for common RPC attributes.
|
||||
var (
|
||||
// Semantic convention for gRPC as the remoting system.
|
||||
RPCSystemGRPC = semconv.RPCSystemGRPC
|
||||
|
||||
// Semantic convention for a message named message.
|
||||
RPCNameMessage = RPCNameKey.String("message")
|
||||
|
||||
// Semantic conventions for RPC message types.
|
||||
RPCMessageTypeSent = RPCMessageTypeKey.String("SENT")
|
||||
RPCMessageTypeReceived = RPCMessageTypeKey.String("RECEIVED")
|
||||
)
|
||||
@@ -13,10 +13,12 @@ import (
|
||||
"google.golang.org/grpc/stats"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
|
||||
"go.opentelemetry.io/otel/metric/noop"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.30.0"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
|
||||
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/internal"
|
||||
@@ -33,12 +35,91 @@ type gRPCContext struct {
|
||||
|
||||
type serverHandler struct {
|
||||
*config
|
||||
|
||||
tracer trace.Tracer
|
||||
|
||||
duration metric.Float64Histogram
|
||||
inSize metric.Int64Histogram
|
||||
outSize metric.Int64Histogram
|
||||
inMsg metric.Int64Histogram
|
||||
outMsg metric.Int64Histogram
|
||||
}
|
||||
|
||||
// NewServerHandler creates a stats.Handler for a gRPC server.
|
||||
func NewServerHandler(opts ...Option) stats.Handler {
|
||||
h := &serverHandler{
|
||||
config: newConfig(opts, "server"),
|
||||
c := newConfig(opts)
|
||||
h := &serverHandler{config: c}
|
||||
|
||||
h.tracer = c.TracerProvider.Tracer(
|
||||
ScopeName,
|
||||
trace.WithInstrumentationVersion(Version()),
|
||||
)
|
||||
|
||||
meter := c.MeterProvider.Meter(
|
||||
ScopeName,
|
||||
metric.WithInstrumentationVersion(Version()),
|
||||
metric.WithSchemaURL(semconv.SchemaURL),
|
||||
)
|
||||
|
||||
var err error
|
||||
h.duration, err = meter.Float64Histogram(
|
||||
semconv.RPCServerDurationName,
|
||||
metric.WithDescription(semconv.RPCServerDurationDescription),
|
||||
metric.WithUnit(semconv.RPCServerDurationUnit),
|
||||
)
|
||||
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),
|
||||
)
|
||||
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),
|
||||
)
|
||||
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),
|
||||
)
|
||||
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),
|
||||
)
|
||||
if err != nil {
|
||||
otel.Handle(err)
|
||||
if h.outMsg == nil {
|
||||
h.outMsg = noop.Int64Histogram{}
|
||||
}
|
||||
}
|
||||
|
||||
return h
|
||||
@@ -55,14 +136,14 @@ func (h *serverHandler) HandleConn(ctx context.Context, info stats.ConnStats) {
|
||||
|
||||
// TagRPC can attach some information to the given context.
|
||||
func (h *serverHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context {
|
||||
ctx = extract(ctx, h.config.Propagators)
|
||||
ctx = extract(ctx, h.Propagators)
|
||||
|
||||
name, attrs := internal.ParseFullMethod(info.FullMethodName)
|
||||
attrs = append(attrs, RPCSystemGRPC)
|
||||
attrs = append(attrs, semconv.RPCSystemGRPC)
|
||||
|
||||
record := true
|
||||
if h.config.Filter != nil {
|
||||
record = h.config.Filter(info)
|
||||
if h.Filter != nil {
|
||||
record = h.Filter(info)
|
||||
}
|
||||
|
||||
if record {
|
||||
@@ -70,12 +151,12 @@ func (h *serverHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) cont
|
||||
trace.ContextWithRemoteSpanContext(ctx, trace.SpanContextFromContext(ctx)),
|
||||
name,
|
||||
trace.WithSpanKind(trace.SpanKindServer),
|
||||
trace.WithAttributes(append(attrs, h.config.SpanAttributes...)...),
|
||||
trace.WithAttributes(append(attrs, h.SpanAttributes...)...),
|
||||
)
|
||||
}
|
||||
|
||||
gctx := gRPCContext{
|
||||
metricAttrs: append(attrs, h.config.MetricAttributes...),
|
||||
metricAttrs: append(attrs, h.MetricAttributes...),
|
||||
record: record,
|
||||
}
|
||||
|
||||
@@ -84,18 +165,96 @@ 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) {
|
||||
isServer := true
|
||||
h.handleRPC(ctx, rs, isServer)
|
||||
h.handleRPC(ctx, rs, h.duration, h.inSize, h.outSize, h.inMsg, h.outMsg, serverStatus)
|
||||
}
|
||||
|
||||
type clientHandler struct {
|
||||
*config
|
||||
|
||||
tracer trace.Tracer
|
||||
|
||||
duration metric.Float64Histogram
|
||||
inSize metric.Int64Histogram
|
||||
outSize metric.Int64Histogram
|
||||
inMsg metric.Int64Histogram
|
||||
outMsg metric.Int64Histogram
|
||||
}
|
||||
|
||||
// NewClientHandler creates a stats.Handler for a gRPC client.
|
||||
func NewClientHandler(opts ...Option) stats.Handler {
|
||||
h := &clientHandler{
|
||||
config: newConfig(opts, "client"),
|
||||
c := newConfig(opts)
|
||||
h := &clientHandler{config: c}
|
||||
|
||||
h.tracer = c.TracerProvider.Tracer(
|
||||
ScopeName,
|
||||
trace.WithInstrumentationVersion(Version()),
|
||||
)
|
||||
|
||||
meter := c.MeterProvider.Meter(
|
||||
ScopeName,
|
||||
metric.WithInstrumentationVersion(Version()),
|
||||
metric.WithSchemaURL(semconv.SchemaURL),
|
||||
)
|
||||
|
||||
var err error
|
||||
h.duration, err = meter.Float64Histogram(
|
||||
semconv.RPCClientDurationName,
|
||||
metric.WithDescription(semconv.RPCClientDurationDescription),
|
||||
metric.WithUnit(semconv.RPCClientDurationUnit),
|
||||
)
|
||||
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),
|
||||
)
|
||||
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),
|
||||
)
|
||||
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),
|
||||
)
|
||||
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),
|
||||
)
|
||||
if err != nil {
|
||||
otel.Handle(err)
|
||||
if h.inMsg == nil {
|
||||
h.inMsg = noop.Int64Histogram{}
|
||||
}
|
||||
}
|
||||
|
||||
return h
|
||||
@@ -104,11 +263,11 @@ func NewClientHandler(opts ...Option) stats.Handler {
|
||||
// TagRPC can attach some information to the given context.
|
||||
func (h *clientHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context {
|
||||
name, attrs := internal.ParseFullMethod(info.FullMethodName)
|
||||
attrs = append(attrs, RPCSystemGRPC)
|
||||
attrs = append(attrs, semconv.RPCSystemGRPC)
|
||||
|
||||
record := true
|
||||
if h.config.Filter != nil {
|
||||
record = h.config.Filter(info)
|
||||
if h.Filter != nil {
|
||||
record = h.Filter(info)
|
||||
}
|
||||
|
||||
if record {
|
||||
@@ -116,22 +275,26 @@ func (h *clientHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) cont
|
||||
ctx,
|
||||
name,
|
||||
trace.WithSpanKind(trace.SpanKindClient),
|
||||
trace.WithAttributes(append(attrs, h.config.SpanAttributes...)...),
|
||||
trace.WithAttributes(append(attrs, h.SpanAttributes...)...),
|
||||
)
|
||||
}
|
||||
|
||||
gctx := gRPCContext{
|
||||
metricAttrs: append(attrs, h.config.MetricAttributes...),
|
||||
metricAttrs: append(attrs, h.MetricAttributes...),
|
||||
record: record,
|
||||
}
|
||||
|
||||
return inject(context.WithValue(ctx, gRPCContextKey{}, &gctx), h.config.Propagators)
|
||||
return inject(context.WithValue(ctx, gRPCContextKey{}, &gctx), h.Propagators)
|
||||
}
|
||||
|
||||
// HandleRPC processes the RPC stats.
|
||||
func (h *clientHandler) HandleRPC(ctx context.Context, rs stats.RPCStats) {
|
||||
isServer := false
|
||||
h.handleRPC(ctx, rs, isServer)
|
||||
h.handleRPC(
|
||||
ctx, rs, h.duration, h.inSize, h.outSize, h.inMsg, h.outMsg,
|
||||
func(s *status.Status) (codes.Code, string) {
|
||||
return codes.Error, s.Message()
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// TagConn can attach some information to the given context.
|
||||
@@ -144,77 +307,86 @@ func (h *clientHandler) HandleConn(context.Context, stats.ConnStats) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
func (c *config) handleRPC(ctx context.Context, rs stats.RPCStats, isServer bool) { // nolint: revive // isServer is not a control flag.
|
||||
span := trace.SpanFromContext(ctx)
|
||||
var metricAttrs []attribute.KeyValue
|
||||
var messageId int64
|
||||
|
||||
func (c *config) handleRPC(
|
||||
ctx context.Context,
|
||||
rs stats.RPCStats,
|
||||
duration metric.Float64Histogram,
|
||||
inSize, outSize, inMsg, outMsg metric.Int64Histogram,
|
||||
recordStatus func(*status.Status) (codes.Code, string),
|
||||
) {
|
||||
gctx, _ := ctx.Value(gRPCContextKey{}).(*gRPCContext)
|
||||
if gctx != nil {
|
||||
if !gctx.record {
|
||||
return
|
||||
}
|
||||
metricAttrs = make([]attribute.KeyValue, 0, len(gctx.metricAttrs)+1)
|
||||
metricAttrs = append(metricAttrs, gctx.metricAttrs...)
|
||||
if gctx != nil && !gctx.record {
|
||||
return
|
||||
}
|
||||
|
||||
span := trace.SpanFromContext(ctx)
|
||||
var messageId int64
|
||||
|
||||
switch rs := rs.(type) {
|
||||
case *stats.Begin:
|
||||
case *stats.InPayload:
|
||||
if gctx != nil {
|
||||
messageId = atomic.AddInt64(&gctx.inMessages, 1)
|
||||
c.rpcInBytes.Record(ctx, int64(rs.Length), metric.WithAttributeSet(attribute.NewSet(metricAttrs...)))
|
||||
inSize.Record(ctx, int64(rs.Length), metric.WithAttributes(gctx.metricAttrs...))
|
||||
}
|
||||
|
||||
if c.ReceivedEvent {
|
||||
if c.ReceivedEvent && span.IsRecording() {
|
||||
span.AddEvent("message",
|
||||
trace.WithAttributes(
|
||||
semconv.MessageTypeReceived,
|
||||
semconv.MessageIDKey.Int64(messageId),
|
||||
semconv.MessageCompressedSizeKey.Int(rs.CompressedLength),
|
||||
semconv.MessageUncompressedSizeKey.Int(rs.Length),
|
||||
semconv.RPCMessageTypeReceived,
|
||||
semconv.RPCMessageIDKey.Int64(messageId),
|
||||
semconv.RPCMessageCompressedSizeKey.Int(rs.CompressedLength),
|
||||
semconv.RPCMessageUncompressedSizeKey.Int(rs.Length),
|
||||
),
|
||||
)
|
||||
}
|
||||
case *stats.OutPayload:
|
||||
if gctx != nil {
|
||||
messageId = atomic.AddInt64(&gctx.outMessages, 1)
|
||||
c.rpcOutBytes.Record(ctx, int64(rs.Length), metric.WithAttributeSet(attribute.NewSet(metricAttrs...)))
|
||||
outSize.Record(ctx, int64(rs.Length), metric.WithAttributes(gctx.metricAttrs...))
|
||||
}
|
||||
|
||||
if c.SentEvent {
|
||||
if c.SentEvent && span.IsRecording() {
|
||||
span.AddEvent("message",
|
||||
trace.WithAttributes(
|
||||
semconv.MessageTypeSent,
|
||||
semconv.MessageIDKey.Int64(messageId),
|
||||
semconv.MessageCompressedSizeKey.Int(rs.CompressedLength),
|
||||
semconv.MessageUncompressedSizeKey.Int(rs.Length),
|
||||
semconv.RPCMessageTypeSent,
|
||||
semconv.RPCMessageIDKey.Int64(messageId),
|
||||
semconv.RPCMessageCompressedSizeKey.Int(rs.CompressedLength),
|
||||
semconv.RPCMessageUncompressedSizeKey.Int(rs.Length),
|
||||
),
|
||||
)
|
||||
}
|
||||
case *stats.OutTrailer:
|
||||
case *stats.OutHeader:
|
||||
if p, ok := peer.FromContext(ctx); ok {
|
||||
span.SetAttributes(peerAttr(p.Addr.String())...)
|
||||
if span.IsRecording() {
|
||||
if p, ok := peer.FromContext(ctx); ok {
|
||||
span.SetAttributes(serverAddrAttrs(p.Addr.String())...)
|
||||
}
|
||||
}
|
||||
case *stats.End:
|
||||
var rpcStatusAttr attribute.KeyValue
|
||||
|
||||
var s *status.Status
|
||||
if rs.Error != nil {
|
||||
s, _ := status.FromError(rs.Error)
|
||||
if isServer {
|
||||
statusCode, msg := serverStatus(s)
|
||||
span.SetStatus(statusCode, msg)
|
||||
} else {
|
||||
span.SetStatus(codes.Error, s.Message())
|
||||
}
|
||||
s, _ = status.FromError(rs.Error)
|
||||
rpcStatusAttr = semconv.RPCGRPCStatusCodeKey.Int(int(s.Code()))
|
||||
} else {
|
||||
rpcStatusAttr = semconv.RPCGRPCStatusCodeKey.Int(int(grpc_codes.OK))
|
||||
}
|
||||
span.SetAttributes(rpcStatusAttr)
|
||||
span.End()
|
||||
if span.IsRecording() {
|
||||
if s != nil {
|
||||
c, m := recordStatus(s)
|
||||
span.SetStatus(c, m)
|
||||
}
|
||||
span.SetAttributes(rpcStatusAttr)
|
||||
span.End()
|
||||
}
|
||||
|
||||
var metricAttrs []attribute.KeyValue
|
||||
if gctx != nil {
|
||||
metricAttrs = make([]attribute.KeyValue, 0, len(gctx.metricAttrs)+1)
|
||||
metricAttrs = append(metricAttrs, gctx.metricAttrs...)
|
||||
}
|
||||
metricAttrs = append(metricAttrs, rpcStatusAttr)
|
||||
// Allocate vararg slice once.
|
||||
recordOpts := []metric.RecordOption{metric.WithAttributeSet(attribute.NewSet(metricAttrs...))}
|
||||
@@ -223,10 +395,10 @@ func (c *config) handleRPC(ctx context.Context, rs stats.RPCStats, isServer bool
|
||||
// Measure right before calling Record() to capture as much elapsed time as possible.
|
||||
elapsedTime := float64(rs.EndTime.Sub(rs.BeginTime)) / float64(time.Millisecond)
|
||||
|
||||
c.rpcDuration.Record(ctx, elapsedTime, recordOpts...)
|
||||
duration.Record(ctx, elapsedTime, recordOpts...)
|
||||
if gctx != nil {
|
||||
c.rpcInMessages.Record(ctx, atomic.LoadInt64(&gctx.inMessages), recordOpts...)
|
||||
c.rpcOutMessages.Record(ctx, atomic.LoadInt64(&gctx.outMessages), recordOpts...)
|
||||
inMsg.Record(ctx, atomic.LoadInt64(&gctx.inMessages), recordOpts...)
|
||||
outMsg.Record(ctx, atomic.LoadInt64(&gctx.outMessages), recordOpts...)
|
||||
}
|
||||
default:
|
||||
return
|
||||
|
||||
@@ -5,13 +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.60.0"
|
||||
return "0.61.0"
|
||||
// This string is updated by the pre_release.sh script during release
|
||||
}
|
||||
|
||||
// SemVersion is the semantic version to be supplied to tracer/meter creation.
|
||||
//
|
||||
// Deprecated: Use [Version] instead.
|
||||
func SemVersion() string {
|
||||
return Version()
|
||||
}
|
||||
|
||||
3
vendor/go.opentelemetry.io/otel/semconv/v1.17.0/README.md
generated
vendored
3
vendor/go.opentelemetry.io/otel/semconv/v1.17.0/README.md
generated
vendored
@@ -1,3 +0,0 @@
|
||||
# Semconv v1.17.0
|
||||
|
||||
[](https://pkg.go.dev/go.opentelemetry.io/otel/semconv/v1.17.0)
|
||||
188
vendor/go.opentelemetry.io/otel/semconv/v1.17.0/event.go
generated
vendored
188
vendor/go.opentelemetry.io/otel/semconv/v1.17.0/event.go
generated
vendored
@@ -1,188 +0,0 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Code generated from semantic convention specification. DO NOT EDIT.
|
||||
|
||||
package semconv // import "go.opentelemetry.io/otel/semconv/v1.17.0"
|
||||
|
||||
import "go.opentelemetry.io/otel/attribute"
|
||||
|
||||
// This semantic convention defines the attributes used to represent a feature
|
||||
// flag evaluation as an event.
|
||||
const (
|
||||
// FeatureFlagKeyKey is the attribute Key conforming to the
|
||||
// "feature_flag.key" semantic conventions. It represents the unique
|
||||
// identifier of the feature flag.
|
||||
//
|
||||
// Type: string
|
||||
// RequirementLevel: Required
|
||||
// Stability: stable
|
||||
// Examples: 'logo-color'
|
||||
FeatureFlagKeyKey = attribute.Key("feature_flag.key")
|
||||
|
||||
// FeatureFlagProviderNameKey is the attribute Key conforming to the
|
||||
// "feature_flag.provider_name" semantic conventions. It represents the
|
||||
// name of the service provider that performs the flag evaluation.
|
||||
//
|
||||
// Type: string
|
||||
// RequirementLevel: Recommended
|
||||
// Stability: stable
|
||||
// Examples: 'Flag Manager'
|
||||
FeatureFlagProviderNameKey = attribute.Key("feature_flag.provider_name")
|
||||
|
||||
// FeatureFlagVariantKey is the attribute Key conforming to the
|
||||
// "feature_flag.variant" semantic conventions. It represents the sHOULD be
|
||||
// a semantic identifier for a value. If one is unavailable, a stringified
|
||||
// version of the value can be used.
|
||||
//
|
||||
// Type: string
|
||||
// RequirementLevel: Recommended
|
||||
// Stability: stable
|
||||
// Examples: 'red', 'true', 'on'
|
||||
// Note: A semantic identifier, commonly referred to as a variant, provides
|
||||
// a means
|
||||
// for referring to a value without including the value itself. This can
|
||||
// provide additional context for understanding the meaning behind a value.
|
||||
// For example, the variant `red` maybe be used for the value `#c05543`.
|
||||
//
|
||||
// A stringified version of the value can be used in situations where a
|
||||
// semantic identifier is unavailable. String representation of the value
|
||||
// should be determined by the implementer.
|
||||
FeatureFlagVariantKey = attribute.Key("feature_flag.variant")
|
||||
)
|
||||
|
||||
// FeatureFlagKey returns an attribute KeyValue conforming to the
|
||||
// "feature_flag.key" semantic conventions. It represents the unique identifier
|
||||
// of the feature flag.
|
||||
func FeatureFlagKey(val string) attribute.KeyValue {
|
||||
return FeatureFlagKeyKey.String(val)
|
||||
}
|
||||
|
||||
// FeatureFlagProviderName returns an attribute KeyValue conforming to the
|
||||
// "feature_flag.provider_name" semantic conventions. It represents the name of
|
||||
// the service provider that performs the flag evaluation.
|
||||
func FeatureFlagProviderName(val string) attribute.KeyValue {
|
||||
return FeatureFlagProviderNameKey.String(val)
|
||||
}
|
||||
|
||||
// FeatureFlagVariant returns an attribute KeyValue conforming to the
|
||||
// "feature_flag.variant" semantic conventions. It represents the sHOULD be a
|
||||
// semantic identifier for a value. If one is unavailable, a stringified
|
||||
// version of the value can be used.
|
||||
func FeatureFlagVariant(val string) attribute.KeyValue {
|
||||
return FeatureFlagVariantKey.String(val)
|
||||
}
|
||||
|
||||
// RPC received/sent message.
|
||||
const (
|
||||
// MessageTypeKey is the attribute Key conforming to the "message.type"
|
||||
// semantic conventions. It represents the whether this is a received or
|
||||
// sent message.
|
||||
//
|
||||
// Type: Enum
|
||||
// RequirementLevel: Optional
|
||||
// Stability: stable
|
||||
MessageTypeKey = attribute.Key("message.type")
|
||||
|
||||
// MessageIDKey is the attribute Key conforming to the "message.id"
|
||||
// semantic conventions. It represents the mUST be calculated as two
|
||||
// different counters starting from `1` one for sent messages and one for
|
||||
// received message.
|
||||
//
|
||||
// Type: int
|
||||
// RequirementLevel: Optional
|
||||
// Stability: stable
|
||||
// Note: This way we guarantee that the values will be consistent between
|
||||
// different implementations.
|
||||
MessageIDKey = attribute.Key("message.id")
|
||||
|
||||
// MessageCompressedSizeKey is the attribute Key conforming to the
|
||||
// "message.compressed_size" semantic conventions. It represents the
|
||||
// compressed size of the message in bytes.
|
||||
//
|
||||
// Type: int
|
||||
// RequirementLevel: Optional
|
||||
// Stability: stable
|
||||
MessageCompressedSizeKey = attribute.Key("message.compressed_size")
|
||||
|
||||
// MessageUncompressedSizeKey is the attribute Key conforming to the
|
||||
// "message.uncompressed_size" semantic conventions. It represents the
|
||||
// uncompressed size of the message in bytes.
|
||||
//
|
||||
// Type: int
|
||||
// RequirementLevel: Optional
|
||||
// Stability: stable
|
||||
MessageUncompressedSizeKey = attribute.Key("message.uncompressed_size")
|
||||
)
|
||||
|
||||
var (
|
||||
// sent
|
||||
MessageTypeSent = MessageTypeKey.String("SENT")
|
||||
// received
|
||||
MessageTypeReceived = MessageTypeKey.String("RECEIVED")
|
||||
)
|
||||
|
||||
// MessageID returns an attribute KeyValue conforming to the "message.id"
|
||||
// semantic conventions. It represents the mUST be calculated as two different
|
||||
// counters starting from `1` one for sent messages and one for received
|
||||
// message.
|
||||
func MessageID(val int) attribute.KeyValue {
|
||||
return MessageIDKey.Int(val)
|
||||
}
|
||||
|
||||
// MessageCompressedSize returns an attribute KeyValue conforming to the
|
||||
// "message.compressed_size" semantic conventions. It represents the compressed
|
||||
// size of the message in bytes.
|
||||
func MessageCompressedSize(val int) attribute.KeyValue {
|
||||
return MessageCompressedSizeKey.Int(val)
|
||||
}
|
||||
|
||||
// MessageUncompressedSize returns an attribute KeyValue conforming to the
|
||||
// "message.uncompressed_size" semantic conventions. It represents the
|
||||
// uncompressed size of the message in bytes.
|
||||
func MessageUncompressedSize(val int) attribute.KeyValue {
|
||||
return MessageUncompressedSizeKey.Int(val)
|
||||
}
|
||||
|
||||
// The attributes used to report a single exception associated with a span.
|
||||
const (
|
||||
// ExceptionEscapedKey is the attribute Key conforming to the
|
||||
// "exception.escaped" semantic conventions. It represents the sHOULD be
|
||||
// set to true if the exception event is recorded at a point where it is
|
||||
// known that the exception is escaping the scope of the span.
|
||||
//
|
||||
// Type: boolean
|
||||
// RequirementLevel: Optional
|
||||
// Stability: stable
|
||||
// Note: An exception is considered to have escaped (or left) the scope of
|
||||
// a span,
|
||||
// if that span is ended while the exception is still logically "in
|
||||
// flight".
|
||||
// This may be actually "in flight" in some languages (e.g. if the
|
||||
// exception
|
||||
// is passed to a Context manager's `__exit__` method in Python) but will
|
||||
// usually be caught at the point of recording the exception in most
|
||||
// languages.
|
||||
//
|
||||
// It is usually not possible to determine at the point where an exception
|
||||
// is thrown
|
||||
// whether it will escape the scope of a span.
|
||||
// However, it is trivial to know that an exception
|
||||
// will escape, if one checks for an active exception just before ending
|
||||
// the span,
|
||||
// as done in the [example above](#recording-an-exception).
|
||||
//
|
||||
// It follows that an exception may still escape the scope of the span
|
||||
// even if the `exception.escaped` attribute was not set or set to false,
|
||||
// since the event might have been recorded at a time where it was not
|
||||
// clear whether the exception will escape.
|
||||
ExceptionEscapedKey = attribute.Key("exception.escaped")
|
||||
)
|
||||
|
||||
// ExceptionEscaped returns an attribute KeyValue conforming to the
|
||||
// "exception.escaped" semantic conventions. It represents the sHOULD be set to
|
||||
// true if the exception event is recorded at a point where it is known that
|
||||
// the exception is escaping the scope of the span.
|
||||
func ExceptionEscaped(val bool) attribute.KeyValue {
|
||||
return ExceptionEscapedKey.Bool(val)
|
||||
}
|
||||
10
vendor/go.opentelemetry.io/otel/semconv/v1.17.0/http.go
generated
vendored
10
vendor/go.opentelemetry.io/otel/semconv/v1.17.0/http.go
generated
vendored
@@ -1,10 +0,0 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package semconv // import "go.opentelemetry.io/otel/semconv/v1.17.0"
|
||||
|
||||
// HTTP scheme attributes.
|
||||
var (
|
||||
HTTPSchemeHTTP = HTTPSchemeKey.String("http")
|
||||
HTTPSchemeHTTPS = HTTPSchemeKey.String("https")
|
||||
)
|
||||
1999
vendor/go.opentelemetry.io/otel/semconv/v1.17.0/resource.go
generated
vendored
1999
vendor/go.opentelemetry.io/otel/semconv/v1.17.0/resource.go
generated
vendored
File diff suppressed because it is too large
Load Diff
3364
vendor/go.opentelemetry.io/otel/semconv/v1.17.0/trace.go
generated
vendored
3364
vendor/go.opentelemetry.io/otel/semconv/v1.17.0/trace.go
generated
vendored
File diff suppressed because it is too large
Load Diff
155
vendor/go.opentelemetry.io/otel/semconv/v1.30.0/MIGRATION.md
generated
vendored
Normal file
155
vendor/go.opentelemetry.io/otel/semconv/v1.30.0/MIGRATION.md
generated
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
# 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
|
||||
3
vendor/go.opentelemetry.io/otel/semconv/v1.30.0/README.md
generated
vendored
Normal file
3
vendor/go.opentelemetry.io/otel/semconv/v1.30.0/README.md
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# Semconv v1.30.0
|
||||
|
||||
[](https://pkg.go.dev/go.opentelemetry.io/otel/semconv/v1.30.0)
|
||||
12333
vendor/go.opentelemetry.io/otel/semconv/v1.30.0/attribute_group.go
generated
vendored
Normal file
12333
vendor/go.opentelemetry.io/otel/semconv/v1.30.0/attribute_group.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@@ -4,6 +4,6 @@
|
||||
// Package semconv implements OpenTelemetry semantic conventions.
|
||||
//
|
||||
// OpenTelemetry semantic conventions are agreed standardized naming
|
||||
// patterns for OpenTelemetry things. This package represents the conventions
|
||||
// as of the v1.17.0 version of the OpenTelemetry specification.
|
||||
package semconv // import "go.opentelemetry.io/otel/semconv/v1.17.0"
|
||||
// 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"
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package semconv // import "go.opentelemetry.io/otel/semconv/v1.17.0"
|
||||
package semconv // import "go.opentelemetry.io/otel/semconv/v1.30.0"
|
||||
|
||||
const (
|
||||
// ExceptionEventName is the name of the Span event representing an exception.
|
||||
1750
vendor/go.opentelemetry.io/otel/semconv/v1.30.0/metric.go
generated
vendored
Normal file
1750
vendor/go.opentelemetry.io/otel/semconv/v1.30.0/metric.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,9 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package semconv // import "go.opentelemetry.io/otel/semconv/v1.17.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.17.0"
|
||||
const SchemaURL = "https://opentelemetry.io/schemas/1.30.0"
|
||||
6
vendor/modules.txt
vendored
6
vendor/modules.txt
vendored
@@ -2035,8 +2035,8 @@ 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.60.0
|
||||
## explicit; go 1.22.0
|
||||
# go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.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
|
||||
# go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0
|
||||
@@ -2062,11 +2062,11 @@ go.opentelemetry.io/otel/propagation
|
||||
go.opentelemetry.io/otel/semconv/internal
|
||||
go.opentelemetry.io/otel/semconv/internal/v4
|
||||
go.opentelemetry.io/otel/semconv/v1.10.0
|
||||
go.opentelemetry.io/otel/semconv/v1.17.0
|
||||
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.4.0
|
||||
# go.opentelemetry.io/otel/exporters/jaeger v1.17.0
|
||||
## explicit; go 1.19
|
||||
|
||||
Reference in New Issue
Block a user