[chore]: Bump go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc (#3888)
This commit is contained in:
parent
85e17b3e78
commit
252a17a691
22
go.mod
22
go.mod
|
@ -72,14 +72,14 @@ require (
|
|||
github.com/uptrace/bun/extra/bunotel v1.2.10
|
||||
github.com/wagslane/go-password-validator v0.3.0
|
||||
github.com/yuin/goldmark v1.7.8
|
||||
go.opentelemetry.io/otel v1.34.0
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.34.0
|
||||
go.opentelemetry.io/otel v1.35.0
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.35.0
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.34.0
|
||||
go.opentelemetry.io/otel/exporters/prometheus v0.56.0
|
||||
go.opentelemetry.io/otel/metric v1.34.0
|
||||
go.opentelemetry.io/otel/sdk v1.34.0
|
||||
go.opentelemetry.io/otel/metric v1.35.0
|
||||
go.opentelemetry.io/otel/sdk v1.35.0
|
||||
go.opentelemetry.io/otel/sdk/metric v1.34.0
|
||||
go.opentelemetry.io/otel/trace v1.34.0
|
||||
go.opentelemetry.io/otel/trace v1.35.0
|
||||
go.uber.org/automaxprocs v1.6.0
|
||||
golang.org/x/crypto v0.36.0
|
||||
golang.org/x/image v0.24.0
|
||||
|
@ -151,7 +151,7 @@ require (
|
|||
github.com/gorilla/handlers v1.5.2 // indirect
|
||||
github.com/gorilla/securecookie v1.1.2 // indirect
|
||||
github.com/gorilla/sessions v1.2.2 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/huandu/xstrings v1.4.0 // indirect
|
||||
github.com/imdario/mergo v0.3.16 // indirect
|
||||
|
@ -209,7 +209,7 @@ require (
|
|||
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
|
||||
go.mongodb.org/mongo-driver v1.14.0 // indirect
|
||||
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.34.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.35.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v1.5.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
golang.org/x/arch v0.13.0 // indirect
|
||||
|
@ -217,10 +217,10 @@ require (
|
|||
golang.org/x/mod v0.22.0 // indirect
|
||||
golang.org/x/sync v0.12.0 // indirect
|
||||
golang.org/x/tools v0.28.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250115164207-1a7da9e5054f // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect
|
||||
google.golang.org/grpc v1.69.4 // indirect
|
||||
google.golang.org/protobuf v1.36.3 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a // indirect
|
||||
google.golang.org/grpc v1.71.0 // indirect
|
||||
google.golang.org/protobuf v1.36.5 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
modernc.org/libc v1.61.13 // indirect
|
||||
|
|
|
@ -240,8 +240,8 @@ github.com/gorilla/sessions v1.2.2 h1:lqzMYz6bOfvn2WriPUjNByzeXIlVzURcPmgMczkmTj
|
|||
github.com/gorilla/sessions v1.2.2/go.mod h1:ePLdVu+jbEgHH+KWw8I1z2wqd0BAdAQh/8LRvBeoNcQ=
|
||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1 h1:VNqngBF40hVlDloBruUehVYC3ArSgIyScOAyMRqBxRg=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1/go.mod h1:RBRO7fro65R6tjKzYgLAFo0t1QEXY1Dp+i/bvpRiqiQ=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1 h1:e9Rjr40Z98/clHv5Yg79Is0NtosR5LXRvdr7o/6NwbA=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1/go.mod h1:tIxuGz/9mpox++sgp9fJjHO0+q1X9/UOWd798aAm22M=
|
||||
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
|
||||
|
@ -493,24 +493,24 @@ go.mongodb.org/mongo-driver v1.14.0 h1:P98w8egYRjYe3XDjxhYJagTokP/H6HzlsnojRgZRd
|
|||
go.mongodb.org/mongo-driver v1.14.0/go.mod h1:Vzb0Mk/pa7e6cWw85R4F/endUC3u0U9jGcNU603k65c=
|
||||
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/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY=
|
||||
go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.34.0 h1:OeNbIYk/2C15ckl7glBlOBp5+WlYsOElzTNmiPW/x60=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.34.0/go.mod h1:7Bept48yIeqxP2OZ9/AqIpYS94h2or0aB4FypJTc8ZM=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.34.0 h1:tgJ0uaNS4c98WRNUEx5U3aDlrDOI5Rs+1Vifcw4DJ8U=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.34.0/go.mod h1:U7HYyW0zt/a9x5J1Kjs+r1f/d4ZHnYFclhYY2+YbeoE=
|
||||
go.opentelemetry.io/otel v1.35.0 h1:xKWKPxrxB6OtMCbmMY021CqC45J+3Onta9MqjhnusiQ=
|
||||
go.opentelemetry.io/otel v1.35.0/go.mod h1:UEqy8Zp11hpkUrL73gSlELM0DupHoiq72dR+Zqel/+Y=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.35.0 h1:1fTNlAIJZGWLP5FVu0fikVry1IsiUnXjf7QFvoNN3Xw=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.35.0/go.mod h1:zjPK58DtkqQFn+YUMbx0M2XV3QgKU0gS9LeGohREyK4=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.35.0 h1:m639+BofXTvcY1q8CGs4ItwQarYtJPOWmVobfM1HpVI=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.35.0/go.mod h1:LjReUci/F4BUyv+y4dwnq3h/26iNOeC3wAIqgvTIZVo=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.34.0 h1:BEj3SPM81McUZHYjRS5pEgNgnmzGJ5tRpU5krWnV8Bs=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.34.0/go.mod h1:9cKLGBDzI/F3NoHLQGm4ZrYdIHsvGt6ej6hUowxY0J4=
|
||||
go.opentelemetry.io/otel/exporters/prometheus v0.56.0 h1:GnCIi0QyG0yy2MrJLzVrIM7laaJstj//flf1zEJCG+E=
|
||||
go.opentelemetry.io/otel/exporters/prometheus v0.56.0/go.mod h1:JQcVZtbIIPM+7SWBB+T6FK+xunlyidwLp++fN0sUaOk=
|
||||
go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ=
|
||||
go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE=
|
||||
go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A=
|
||||
go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU=
|
||||
go.opentelemetry.io/otel/metric v1.35.0 h1:0znxYu2SNyuMSQT4Y9WDWej0VpcsxkuklLa4/siN90M=
|
||||
go.opentelemetry.io/otel/metric v1.35.0/go.mod h1:nKVFgxBZ2fReX6IlyW28MgZojkoAkJGaE8CpgeAU3oE=
|
||||
go.opentelemetry.io/otel/sdk v1.35.0 h1:iPctf8iprVySXSKJffSS79eOjl9pvxV9ZqOWT0QejKY=
|
||||
go.opentelemetry.io/otel/sdk v1.35.0/go.mod h1:+ga1bZliga3DxJ3CQGg3updiaAJoNECOgJREo9KHGQg=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w=
|
||||
go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k=
|
||||
go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE=
|
||||
go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt/xgMs=
|
||||
go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc=
|
||||
go.opentelemetry.io/proto/otlp v1.5.0 h1:xJvq7gMzB31/d406fB8U5CBdyQGw4P399D1aQWU/3i4=
|
||||
go.opentelemetry.io/proto/otlp v1.5.0/go.mod h1:keN8WnHxOy8PG0rQZjJJ5A2ebUoafqWp0eVQ4yIXvJ4=
|
||||
go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs=
|
||||
|
@ -623,14 +623,14 @@ golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxb
|
|||
golang.org/x/tools v0.28.0 h1:WuB6qZ4RPCQo5aP3WdKZS7i595EdWqWR8vqJTlwTVK8=
|
||||
golang.org/x/tools v0.28.0/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250115164207-1a7da9e5054f h1:gap6+3Gk41EItBuyi4XX/bp4oqJ3UwuIMl25yGinuAA=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250115164207-1a7da9e5054f/go.mod h1:Ic02D47M+zbarjYYUlK57y316f2MoN0gjAwI3f2S95o=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f h1:OxYkA3wjPsZyBylwymxSHa7ViiW1Sml4ToBrncvFehI=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f/go.mod h1:+2Yz8+CLJbIfL9z73EW45avw8Lmge3xVElCP9zEKi50=
|
||||
google.golang.org/grpc v1.69.4 h1:MF5TftSMkd8GLw/m0KM6V8CMOCY6NZ1NQDPGFgbTt4A=
|
||||
google.golang.org/grpc v1.69.4/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4=
|
||||
google.golang.org/protobuf v1.36.3 h1:82DV7MYdb8anAVi3qge1wSnMDrnKK7ebr+I0hHRN1BU=
|
||||
google.golang.org/protobuf v1.36.3/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a h1:nwKuGPlUAt+aR+pcrkfFRrTU1BVrSmYyYMxYbUIVHr0=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a/go.mod h1:3kWAYMk1I75K4vykHtKt2ycnOgpA6974V7bREqbsenU=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a h1:51aaUVRocpvUOSQKM6Q7VuoaktNIaMCLuhZB6DKksq4=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a/go.mod h1:uRxBH1mhmO8PGhU89cMcHaXKZqO+OfakD8QQO0oYwlQ=
|
||||
google.golang.org/grpc v1.71.0 h1:kF77BGdPTQ4/JZWMlb9VpJ5pa25aqvVqogsxNHHdeBg=
|
||||
google.golang.org/grpc v1.71.0/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec=
|
||||
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
|
||||
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
|
|
|
@ -196,7 +196,7 @@ func ForwardResponseMessage(ctx context.Context, mux *ServeMux, marshaler Marsha
|
|||
return
|
||||
}
|
||||
|
||||
if !doForwardTrailers {
|
||||
if !doForwardTrailers && mux.writeContentLength {
|
||||
w.Header().Set("Content-Length", strconv.Itoa(len(buf)))
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ type ServeMux struct {
|
|||
routingErrorHandler RoutingErrorHandlerFunc
|
||||
disablePathLengthFallback bool
|
||||
unescapingMode UnescapingMode
|
||||
writeContentLength bool
|
||||
}
|
||||
|
||||
// ServeMuxOption is an option that can be given to a ServeMux on construction.
|
||||
|
@ -258,6 +259,13 @@ func WithDisablePathLengthFallback() ServeMuxOption {
|
|||
}
|
||||
}
|
||||
|
||||
// WithWriteContentLength returns a ServeMuxOption to enable writing content length on non-streaming responses
|
||||
func WithWriteContentLength() ServeMuxOption {
|
||||
return func(serveMux *ServeMux) {
|
||||
serveMux.writeContentLength = true
|
||||
}
|
||||
}
|
||||
|
||||
// WithHealthEndpointAt returns a ServeMuxOption that will add an endpoint to the created ServeMux at the path specified by endpointPath.
|
||||
// When called the handler will forward the request to the upstream grpc service health check (defined in the
|
||||
// gRPC Health Checking Protocol).
|
||||
|
|
|
@ -126,6 +126,15 @@ func populateFieldValueFromPath(msgValue protoreflect.Message, fieldPath []strin
|
|||
}
|
||||
}
|
||||
|
||||
// Check if oneof already set
|
||||
if of := fieldDescriptor.ContainingOneof(); of != nil && !of.IsSynthetic() {
|
||||
if f := msgValue.WhichOneof(of); f != nil {
|
||||
if fieldDescriptor.Message() == nil || fieldDescriptor.FullName() != f.FullName() {
|
||||
return fmt.Errorf("field already set for oneof %q", of.FullName().Name())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the last element, we're done
|
||||
if i == len(fieldPath)-1 {
|
||||
break
|
||||
|
@ -140,13 +149,6 @@ func populateFieldValueFromPath(msgValue protoreflect.Message, fieldPath []strin
|
|||
msgValue = msgValue.Mutable(fieldDescriptor).Message()
|
||||
}
|
||||
|
||||
// Check if oneof already set
|
||||
if of := fieldDescriptor.ContainingOneof(); of != nil && !of.IsSynthetic() {
|
||||
if f := msgValue.WhichOneof(of); f != nil {
|
||||
return fmt.Errorf("field already set for oneof %q", of.FullName().Name())
|
||||
}
|
||||
}
|
||||
|
||||
switch {
|
||||
case fieldDescriptor.IsList():
|
||||
return populateRepeatedField(fieldDescriptor, msgValue.Mutable(fieldDescriptor).List(), values)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
.cache/
|
||||
.tools/
|
||||
venv/
|
||||
.idea/
|
||||
|
|
|
@ -25,13 +25,13 @@ linters:
|
|||
- perfsprint
|
||||
- revive
|
||||
- staticcheck
|
||||
- tenv
|
||||
- testifylint
|
||||
- typecheck
|
||||
- unconvert
|
||||
- unused
|
||||
- unparam
|
||||
- usestdlibvars
|
||||
- usetesting
|
||||
|
||||
issues:
|
||||
# Maximum issues count per one linter.
|
||||
|
@ -175,132 +175,60 @@ linters-settings:
|
|||
# This means that linting errors with less than 0.8 confidence will be ignored.
|
||||
# Default: 0.8
|
||||
confidence: 0.01
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md
|
||||
rules:
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#blank-imports
|
||||
- name: blank-imports
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bool-literal-in-expr
|
||||
- name: bool-literal-in-expr
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#constant-logical-expr
|
||||
- name: constant-logical-expr
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-as-argument
|
||||
# TODO (#3372) re-enable linter when it is compatible. https://github.com/golangci/golangci-lint/issues/3280
|
||||
- name: context-as-argument
|
||||
disabled: true
|
||||
arguments:
|
||||
allowTypesBefore: "*testing.T"
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-keys-type
|
||||
- allowTypesBefore: "*testing.T"
|
||||
- name: context-keys-type
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#deep-exit
|
||||
- name: deep-exit
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#defer
|
||||
- name: defer
|
||||
disabled: false
|
||||
arguments:
|
||||
- ["call-chain", "loop"]
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#dot-imports
|
||||
- name: dot-imports
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#duplicated-imports
|
||||
- name: duplicated-imports
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#early-return
|
||||
- name: early-return
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-block
|
||||
arguments:
|
||||
- "preserveScope"
|
||||
- name: empty-block
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-lines
|
||||
- name: empty-lines
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-naming
|
||||
- name: error-naming
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-return
|
||||
- name: error-return
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-strings
|
||||
- name: error-strings
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#errorf
|
||||
- name: errorf
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#exported
|
||||
- name: exported
|
||||
disabled: false
|
||||
arguments:
|
||||
- "sayRepetitiveInsteadOfStutters"
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#flag-parameter
|
||||
- name: flag-parameter
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#identical-branches
|
||||
- name: identical-branches
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#if-return
|
||||
- name: if-return
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#increment-decrement
|
||||
- name: increment-decrement
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#indent-error-flow
|
||||
- name: indent-error-flow
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#import-shadowing
|
||||
- name: import-shadowing
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#package-comments
|
||||
- name: increment-decrement
|
||||
- name: indent-error-flow
|
||||
arguments:
|
||||
- "preserveScope"
|
||||
- name: package-comments
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range
|
||||
- name: range
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-in-closure
|
||||
- name: range-val-in-closure
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-address
|
||||
- name: range-val-address
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#redefines-builtin-id
|
||||
- name: redefines-builtin-id
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-format
|
||||
- name: string-format
|
||||
disabled: false
|
||||
arguments:
|
||||
- - panic
|
||||
- '/^[^\n]*$/'
|
||||
- must not contain line breaks
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#struct-tag
|
||||
- name: struct-tag
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#superfluous-else
|
||||
- name: superfluous-else
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#time-equal
|
||||
- name: time-equal
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-naming
|
||||
- name: var-naming
|
||||
disabled: false
|
||||
arguments:
|
||||
- ["ID"] # AllowList
|
||||
- ["Otel", "Aws", "Gcp"] # DenyList
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-declaration
|
||||
- name: var-declaration
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unconditional-recursion
|
||||
- "preserveScope"
|
||||
- name: time-equal
|
||||
- name: unconditional-recursion
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-return
|
||||
- name: unexported-return
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unhandled-error
|
||||
- name: unhandled-error
|
||||
disabled: false
|
||||
arguments:
|
||||
- "fmt.Fprint"
|
||||
- "fmt.Fprintf"
|
||||
|
@ -308,15 +236,14 @@ linters-settings:
|
|||
- "fmt.Print"
|
||||
- "fmt.Printf"
|
||||
- "fmt.Println"
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unnecessary-stmt
|
||||
- name: unnecessary-stmt
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#useless-break
|
||||
- name: useless-break
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#waitgroup-by-value
|
||||
- name: var-declaration
|
||||
- name: var-naming
|
||||
arguments:
|
||||
- ["ID"] # AllowList
|
||||
- ["Otel", "Aws", "Gcp"] # DenyList
|
||||
- name: waitgroup-by-value
|
||||
disabled: false
|
||||
testifylint:
|
||||
enable-all: true
|
||||
disable:
|
||||
|
|
|
@ -11,6 +11,46 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
<!-- Released section -->
|
||||
<!-- Don't change this section unless doing release -->
|
||||
|
||||
## [1.35.0/0.57.0/0.11.0] 2025-03-05
|
||||
|
||||
This release is the last to support [Go 1.22].
|
||||
The next release will require at least [Go 1.23].
|
||||
|
||||
### Added
|
||||
|
||||
- Add `ValueFromAttribute` and `KeyValueFromAttribute` in `go.opentelemetry.io/otel/log`. (#6180)
|
||||
- Add `EventName` and `SetEventName` to `Record` in `go.opentelemetry.io/otel/log`. (#6187)
|
||||
- Add `EventName` to `RecordFactory` in `go.opentelemetry.io/otel/log/logtest`. (#6187)
|
||||
- `AssertRecordEqual` in `go.opentelemetry.io/otel/log/logtest` checks `Record.EventName`. (#6187)
|
||||
- Add `EventName` and `SetEventName` to `Record` in `go.opentelemetry.io/otel/sdk/log`. (#6193)
|
||||
- Add `EventName` to `RecordFactory` in `go.opentelemetry.io/otel/sdk/log/logtest`. (#6193)
|
||||
- Emit `Record.EventName` field in `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc`. (#6211)
|
||||
- Emit `Record.EventName` field in `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp`. (#6211)
|
||||
- Emit `Record.EventName` field in `go.opentelemetry.io/otel/exporters/stdout/stdoutlog` (#6210)
|
||||
- The `go.opentelemetry.io/otel/semconv/v1.28.0` package.
|
||||
The package contains semantic conventions from the `v1.28.0` version of the OpenTelemetry Semantic Conventions.
|
||||
See the [migration documentation](./semconv/v1.28.0/MIGRATION.md) for information on how to upgrade from `go.opentelemetry.io/otel/semconv/v1.27.0`(#6236)
|
||||
- The `go.opentelemetry.io/otel/semconv/v1.30.0` package.
|
||||
The package contains semantic conventions from the `v1.30.0` version of the OpenTelemetry Semantic Conventions.
|
||||
See the [migration documentation](./semconv/v1.30.0/MIGRATION.md) for information on how to upgrade from `go.opentelemetry.io/otel/semconv/v1.28.0`(#6240)
|
||||
- Document the pitfalls of using `Resource` as a comparable type.
|
||||
`Resource.Equal` and `Resource.Equivalent` should be used instead. (#6272)
|
||||
- Support [Go 1.24]. (#6304)
|
||||
- Add `FilterProcessor` and `EnabledParameters` in `go.opentelemetry.io/otel/sdk/log`.
|
||||
It replaces `go.opentelemetry.io/otel/sdk/log/internal/x.FilterProcessor`.
|
||||
Compared to previous version it additionally gives the possibility to filter by resource and instrumentation scope. (#6317)
|
||||
|
||||
### Changed
|
||||
|
||||
- Update `github.com/prometheus/common` to `v0.62.0`, which changes the `NameValidationScheme` to `NoEscaping`.
|
||||
This allows metrics names to keep original delimiters (e.g. `.`), rather than replacing with underscores.
|
||||
This is controlled by the `Content-Type` header, or can be reverted by setting `NameValidationScheme` to `LegacyValidation` in `github.com/prometheus/common/model`. (#6198)
|
||||
|
||||
### Fixes
|
||||
|
||||
- Eliminate goroutine leak for the processor returned by `NewSimpleSpanProcessor` in `go.opentelemetry.io/otel/sdk/trace` when `Shutdown` is called and the passed `ctx` is canceled and `SpanExporter.Shutdown` has not returned. (#6368)
|
||||
- Eliminate goroutine leak for the processor returned by `NewBatchSpanProcessor` in `go.opentelemetry.io/otel/sdk/trace` when `ForceFlush` is called and the passed `ctx` is canceled and `SpanExporter.Export` has not returned. (#6369)
|
||||
|
||||
## [1.34.0/0.56.0/0.10.0] 2025-01-17
|
||||
|
||||
### Changed
|
||||
|
@ -3197,7 +3237,8 @@ It contains api and sdk for trace and meter.
|
|||
- CircleCI build CI manifest files.
|
||||
- CODEOWNERS file to track owners of this project.
|
||||
|
||||
[Unreleased]: https://github.com/open-telemetry/opentelemetry-go/compare/v1.34.0...HEAD
|
||||
[Unreleased]: https://github.com/open-telemetry/opentelemetry-go/compare/v1.35.0...HEAD
|
||||
[1.35.0/0.57.0/0.11.0]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.35.0
|
||||
[1.34.0/0.56.0/0.10.0]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.34.0
|
||||
[1.33.0/0.55.0/0.9.0/0.0.12]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.33.0
|
||||
[1.32.0/0.54.0/0.8.0/0.0.11]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.32.0
|
||||
|
@ -3288,6 +3329,7 @@ It contains api and sdk for trace and meter.
|
|||
|
||||
<!-- Released section ended -->
|
||||
|
||||
[Go 1.24]: https://go.dev/doc/go1.24
|
||||
[Go 1.23]: https://go.dev/doc/go1.23
|
||||
[Go 1.22]: https://go.dev/doc/go1.22
|
||||
[Go 1.21]: https://go.dev/doc/go1.21
|
||||
|
|
|
@ -181,6 +181,18 @@ patterns in the spec.
|
|||
For a deeper discussion, see
|
||||
[this](https://github.com/open-telemetry/opentelemetry-specification/issues/165).
|
||||
|
||||
## Tests
|
||||
|
||||
Each functionality should be covered by tests.
|
||||
|
||||
Performance-critical functionality should also be covered by benchmarks.
|
||||
|
||||
- Pull requests adding a performance-critical functionality
|
||||
should have `go test -bench` output in their description.
|
||||
- Pull requests changing a performance-critical functionality
|
||||
should have [`benchstat`](https://pkg.go.dev/golang.org/x/perf/cmd/benchstat)
|
||||
output in their description.
|
||||
|
||||
## Documentation
|
||||
|
||||
Each (non-internal, non-test) package must be documented using
|
||||
|
|
|
@ -11,6 +11,10 @@ ALL_COVERAGE_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {}
|
|||
GO = go
|
||||
TIMEOUT = 60
|
||||
|
||||
# User to run as in docker images.
|
||||
DOCKER_USER=$(shell id -u):$(shell id -g)
|
||||
DEPENDENCIES_DOCKERFILE=./dependencies.Dockerfile
|
||||
|
||||
.DEFAULT_GOAL := precommit
|
||||
|
||||
.PHONY: precommit ci
|
||||
|
@ -81,20 +85,20 @@ PIP := $(PYTOOLS)/pip
|
|||
WORKDIR := /workdir
|
||||
|
||||
# The python image to use for the virtual environment.
|
||||
PYTHONIMAGE := python:3.11.3-slim-bullseye
|
||||
PYTHONIMAGE := $(shell awk '$$4=="python" {print $$2}' $(DEPENDENCIES_DOCKERFILE))
|
||||
|
||||
# Run the python image with the current directory mounted.
|
||||
DOCKERPY := docker run --rm -v "$(CURDIR):$(WORKDIR)" -w $(WORKDIR) $(PYTHONIMAGE)
|
||||
DOCKERPY := docker run --rm -u $(DOCKER_USER) -v "$(CURDIR):$(WORKDIR)" -w $(WORKDIR) $(PYTHONIMAGE)
|
||||
|
||||
# Create a virtual environment for Python tools.
|
||||
$(PYTOOLS):
|
||||
# The `--upgrade` flag is needed to ensure that the virtual environment is
|
||||
# created with the latest pip version.
|
||||
@$(DOCKERPY) bash -c "python3 -m venv $(VENVDIR) && $(PIP) install --upgrade pip"
|
||||
@$(DOCKERPY) bash -c "python3 -m venv $(VENVDIR) && $(PIP) install --upgrade --cache-dir=$(WORKDIR)/.cache/pip pip"
|
||||
|
||||
# Install python packages into the virtual environment.
|
||||
$(PYTOOLS)/%: $(PYTOOLS)
|
||||
@$(DOCKERPY) $(PIP) install -r requirements.txt
|
||||
@$(DOCKERPY) $(PIP) install --cache-dir=$(WORKDIR)/.cache/pip -r requirements.txt
|
||||
|
||||
CODESPELL = $(PYTOOLS)/codespell
|
||||
$(CODESPELL): PACKAGE=codespell
|
||||
|
@ -119,7 +123,7 @@ vanity-import-fix: $(PORTO)
|
|||
# Generate go.work file for local development.
|
||||
.PHONY: go-work
|
||||
go-work: $(CROSSLINK)
|
||||
$(CROSSLINK) work --root=$(shell pwd)
|
||||
$(CROSSLINK) work --root=$(shell pwd) --go=1.22.7
|
||||
|
||||
# Build
|
||||
|
||||
|
@ -265,13 +269,30 @@ check-clean-work-tree:
|
|||
exit 1; \
|
||||
fi
|
||||
|
||||
# The weaver docker image to use for semconv-generate.
|
||||
WEAVER_IMAGE := $(shell awk '$$4=="weaver" {print $$2}' $(DEPENDENCIES_DOCKERFILE))
|
||||
|
||||
SEMCONVPKG ?= "semconv/"
|
||||
.PHONY: semconv-generate
|
||||
semconv-generate: $(SEMCONVGEN) $(SEMCONVKIT)
|
||||
semconv-generate: $(SEMCONVKIT)
|
||||
[ "$(TAG)" ] || ( echo "TAG unset: missing opentelemetry semantic-conventions tag"; exit 1 )
|
||||
[ "$(OTEL_SEMCONV_REPO)" ] || ( echo "OTEL_SEMCONV_REPO unset: missing path to opentelemetry semantic-conventions repo"; exit 1 )
|
||||
$(SEMCONVGEN) -i "$(OTEL_SEMCONV_REPO)/model/." --only=attribute_group -p conventionType=trace -f attribute_group.go -z "$(SEMCONVPKG)/capitalizations.txt" -t "$(SEMCONVPKG)/template.j2" -s "$(TAG)"
|
||||
$(SEMCONVGEN) -i "$(OTEL_SEMCONV_REPO)/model/." --only=metric -f metric.go -t "$(SEMCONVPKG)/metric_template.j2" -s "$(TAG)"
|
||||
# Ensure the target directory for source code is available.
|
||||
mkdir -p $(PWD)/$(SEMCONVPKG)/${TAG}
|
||||
# Note: We mount a home directory for downloading/storing the semconv repository.
|
||||
# Weaver will automatically clean the cache when finished, but the directories will remain.
|
||||
mkdir -p ~/.weaver
|
||||
docker run --rm \
|
||||
-u $(DOCKER_USER) \
|
||||
--env HOME=/tmp/weaver \
|
||||
--mount 'type=bind,source=$(PWD)/semconv,target=/home/weaver/templates/registry/go,readonly' \
|
||||
--mount 'type=bind,source=$(PWD)/semconv/${TAG},target=/home/weaver/target' \
|
||||
--mount 'type=bind,source=$(HOME)/.weaver,target=/tmp/weaver/.weaver' \
|
||||
$(WEAVER_IMAGE) registry generate \
|
||||
--registry=https://github.com/open-telemetry/semantic-conventions/archive/refs/tags/$(TAG).zip[model] \
|
||||
--templates=/home/weaver/templates \
|
||||
--param tag=$(TAG) \
|
||||
go \
|
||||
/home/weaver/target
|
||||
$(SEMCONVKIT) -output "$(SEMCONVPKG)/$(TAG)" -tag "$(TAG)"
|
||||
|
||||
.PHONY: gorelease
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
[](https://app.codecov.io/gh/open-telemetry/opentelemetry-go?branch=main)
|
||||
[](https://pkg.go.dev/go.opentelemetry.io/otel)
|
||||
[](https://goreportcard.com/report/go.opentelemetry.io/otel)
|
||||
[](https://scorecard.dev/viewer/?uri=github.com/open-telemetry/opentelemetry-go)
|
||||
[](https://www.bestpractices.dev/projects/9996)
|
||||
[](https://cloud-native.slack.com/archives/C01NPAXACKT)
|
||||
|
||||
OpenTelemetry-Go is the [Go](https://golang.org/) implementation of [OpenTelemetry](https://opentelemetry.io/).
|
||||
|
@ -49,18 +51,25 @@ Currently, this project supports the following environments.
|
|||
|
||||
| OS | Go Version | Architecture |
|
||||
|----------|------------|--------------|
|
||||
| Ubuntu | 1.24 | amd64 |
|
||||
| Ubuntu | 1.23 | amd64 |
|
||||
| Ubuntu | 1.22 | amd64 |
|
||||
| Ubuntu | 1.24 | 386 |
|
||||
| Ubuntu | 1.23 | 386 |
|
||||
| Ubuntu | 1.22 | 386 |
|
||||
| Linux | 1.23 | arm64 |
|
||||
| Linux | 1.22 | arm64 |
|
||||
| Ubuntu | 1.24 | arm64 |
|
||||
| Ubuntu | 1.23 | arm64 |
|
||||
| Ubuntu | 1.22 | arm64 |
|
||||
| macOS 13 | 1.24 | amd64 |
|
||||
| macOS 13 | 1.23 | amd64 |
|
||||
| macOS 13 | 1.22 | amd64 |
|
||||
| macOS | 1.24 | arm64 |
|
||||
| macOS | 1.23 | arm64 |
|
||||
| macOS | 1.22 | arm64 |
|
||||
| Windows | 1.24 | amd64 |
|
||||
| Windows | 1.23 | amd64 |
|
||||
| Windows | 1.22 | amd64 |
|
||||
| Windows | 1.24 | 386 |
|
||||
| Windows | 1.23 | 386 |
|
||||
| Windows | 1.22 | 386 |
|
||||
|
||||
|
|
|
@ -5,17 +5,14 @@
|
|||
New versions of the [OpenTelemetry Semantic Conventions] mean new versions of the `semconv` package need to be generated.
|
||||
The `semconv-generate` make target is used for this.
|
||||
|
||||
1. Checkout a local copy of the [OpenTelemetry Semantic Conventions] to the desired release tag.
|
||||
2. Pull the latest `otel/semconvgen` image: `docker pull otel/semconvgen:latest`
|
||||
3. Run the `make semconv-generate ...` target from this repository.
|
||||
1. Set the `TAG` environment variable to the semantic convention tag you want to generate.
|
||||
2. Run the `make semconv-generate ...` target from this repository.
|
||||
|
||||
For example,
|
||||
|
||||
```sh
|
||||
export TAG="v1.21.0" # Change to the release version you are generating.
|
||||
export OTEL_SEMCONV_REPO="/absolute/path/to/opentelemetry/semantic-conventions"
|
||||
docker pull otel/semconvgen:latest
|
||||
make semconv-generate # Uses the exported TAG and OTEL_SEMCONV_REPO.
|
||||
export TAG="v1.30.0" # Change to the release version you are generating.
|
||||
make semconv-generate # Uses the exported TAG.
|
||||
```
|
||||
|
||||
This should create a new sub-package of [`semconv`](./semconv).
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
# This is a renovate-friendly source of Docker images.
|
||||
FROM python:3.13.2-slim-bullseye@sha256:31b581c8218e1f3c58672481b3b7dba8e898852866b408c6a984c22832523935 AS python
|
||||
FROM otel/weaver:v0.13.2@sha256:ae7346b992e477f629ea327e0979e8a416a97f7956ab1f7e95ac1f44edf1a893 AS weaver
|
|
@ -5,5 +5,5 @@ package otlptrace // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace"
|
|||
|
||||
// Version is the current release version of the OpenTelemetry OTLP trace exporter in use.
|
||||
func Version() string {
|
||||
return "1.34.0"
|
||||
return "1.35.0"
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:recommended"
|
||||
"config:best-practices"
|
||||
],
|
||||
"ignorePaths": [],
|
||||
"labels": ["Skip Changelog", "dependencies"],
|
||||
|
@ -14,6 +14,10 @@
|
|||
"matchDepTypes": ["indirect"],
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"matchPackageNames": ["go.opentelemetry.io/build-tools/**"],
|
||||
"groupName": "build-tools"
|
||||
},
|
||||
{
|
||||
"matchPackageNames": ["google.golang.org/genproto/googleapis/**"],
|
||||
"groupName": "googleapis"
|
||||
|
|
|
@ -1 +1 @@
|
|||
codespell==2.3.0
|
||||
codespell==2.4.1
|
||||
|
|
|
@ -5,6 +5,7 @@ package resource // import "go.opentelemetry.io/otel/sdk/resource"
|
|||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
@ -63,7 +64,7 @@ func parsePlistFile(file io.Reader) (map[string]string, error) {
|
|||
}
|
||||
|
||||
if len(v.Dict.Key) != len(v.Dict.String) {
|
||||
return nil, fmt.Errorf("the number of <key> and <string> elements doesn't match")
|
||||
return nil, errors.New("the number of <key> and <string> elements doesn't match")
|
||||
}
|
||||
|
||||
properties := make(map[string]string, len(v.Dict.Key))
|
||||
|
|
|
@ -21,11 +21,22 @@ import (
|
|||
// Resources should be passed and stored as pointers
|
||||
// (`*resource.Resource`). The `nil` value is equivalent to an empty
|
||||
// Resource.
|
||||
//
|
||||
// Note that the Go == operator compares not just the resource attributes but
|
||||
// also all other internals of the Resource type. Therefore, Resource values
|
||||
// should not be used as map or database keys. In general, the [Resource.Equal]
|
||||
// method should be used instead of direct comparison with ==, since that
|
||||
// method ensures the correct comparison of resource attributes, and the
|
||||
// [attribute.Distinct] returned from [Resource.Equivalent] should be used for
|
||||
// map and database keys instead.
|
||||
type Resource struct {
|
||||
attrs attribute.Set
|
||||
schemaURL string
|
||||
}
|
||||
|
||||
// Compile-time check that the Resource remains comparable.
|
||||
var _ map[Resource]struct{} = nil
|
||||
|
||||
var (
|
||||
defaultResource *Resource
|
||||
defaultResourceOnce sync.Once
|
||||
|
@ -137,15 +148,19 @@ func (r *Resource) Iter() attribute.Iterator {
|
|||
return r.attrs.Iter()
|
||||
}
|
||||
|
||||
// Equal returns true when a Resource is equivalent to this Resource.
|
||||
func (r *Resource) Equal(eq *Resource) bool {
|
||||
// Equal returns whether r and o represent the same resource. Two resources can
|
||||
// be equal even if they have different schema URLs.
|
||||
//
|
||||
// See the documentation on the [Resource] type for the pitfalls of using ==
|
||||
// with Resource values; most code should use Equal instead.
|
||||
func (r *Resource) Equal(o *Resource) bool {
|
||||
if r == nil {
|
||||
r = Empty()
|
||||
}
|
||||
if eq == nil {
|
||||
eq = Empty()
|
||||
if o == nil {
|
||||
o = Empty()
|
||||
}
|
||||
return r.Equivalent() == eq.Equivalent()
|
||||
return r.Equivalent() == o.Equivalent()
|
||||
}
|
||||
|
||||
// Merge creates a new [Resource] by merging a and b.
|
||||
|
|
|
@ -201,10 +201,9 @@ func (bsp *batchSpanProcessor) ForceFlush(ctx context.Context) error {
|
|||
}
|
||||
}
|
||||
|
||||
wait := make(chan error)
|
||||
wait := make(chan error, 1)
|
||||
go func() {
|
||||
wait <- bsp.exportSpans(ctx)
|
||||
close(wait)
|
||||
}()
|
||||
// Wait until the export is finished or the context is cancelled/timed out
|
||||
select {
|
||||
|
|
|
@ -47,12 +47,12 @@ const (
|
|||
// Drop will not record the span and all attributes/events will be dropped.
|
||||
Drop SamplingDecision = iota
|
||||
|
||||
// Record indicates the span's `IsRecording() == true`, but `Sampled` flag
|
||||
// *must not* be set.
|
||||
// RecordOnly indicates the span's IsRecording method returns true, but trace.FlagsSampled flag
|
||||
// must not be set.
|
||||
RecordOnly
|
||||
|
||||
// RecordAndSample has span's `IsRecording() == true` and `Sampled` flag
|
||||
// *must* be set.
|
||||
// RecordAndSample indicates the span's IsRecording method returns true and trace.FlagsSampled flag
|
||||
// must be set.
|
||||
RecordAndSample
|
||||
)
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ func (ssp *simpleSpanProcessor) Shutdown(ctx context.Context) error {
|
|||
var err error
|
||||
ssp.stopOnce.Do(func() {
|
||||
stopFunc := func(exp SpanExporter) (<-chan error, func()) {
|
||||
done := make(chan error)
|
||||
done := make(chan error, 1)
|
||||
return done, func() { done <- exp.Shutdown(ctx) }
|
||||
}
|
||||
|
||||
|
|
|
@ -5,5 +5,5 @@ package sdk // import "go.opentelemetry.io/otel/sdk"
|
|||
|
||||
// Version is the current release version of the OpenTelemetry SDK in use.
|
||||
func Version() string {
|
||||
return "1.34.0"
|
||||
return "1.35.0"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,661 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package trace // import "go.opentelemetry.io/otel/trace"
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math"
|
||||
"os"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
|
||||
"go.opentelemetry.io/otel/trace/embedded"
|
||||
"go.opentelemetry.io/otel/trace/internal/telemetry"
|
||||
)
|
||||
|
||||
// newAutoTracerProvider returns an auto-instrumentable [trace.TracerProvider].
|
||||
// If an [go.opentelemetry.io/auto.Instrumentation] is configured to instrument
|
||||
// the process using the returned TracerProvider, all of the telemetry it
|
||||
// produces will be processed and handled by that Instrumentation. By default,
|
||||
// if no Instrumentation instruments the TracerProvider it will not generate
|
||||
// any trace telemetry.
|
||||
func newAutoTracerProvider() TracerProvider { return tracerProviderInstance }
|
||||
|
||||
var tracerProviderInstance = new(autoTracerProvider)
|
||||
|
||||
type autoTracerProvider struct{ embedded.TracerProvider }
|
||||
|
||||
var _ TracerProvider = autoTracerProvider{}
|
||||
|
||||
func (p autoTracerProvider) Tracer(name string, opts ...TracerOption) Tracer {
|
||||
cfg := NewTracerConfig(opts...)
|
||||
return autoTracer{
|
||||
name: name,
|
||||
version: cfg.InstrumentationVersion(),
|
||||
schemaURL: cfg.SchemaURL(),
|
||||
}
|
||||
}
|
||||
|
||||
type autoTracer struct {
|
||||
embedded.Tracer
|
||||
|
||||
name, schemaURL, version string
|
||||
}
|
||||
|
||||
var _ Tracer = autoTracer{}
|
||||
|
||||
func (t autoTracer) Start(ctx context.Context, name string, opts ...SpanStartOption) (context.Context, Span) {
|
||||
var psc SpanContext
|
||||
sampled := true
|
||||
span := new(autoSpan)
|
||||
|
||||
// Ask eBPF for sampling decision and span context info.
|
||||
t.start(ctx, span, &psc, &sampled, &span.spanContext)
|
||||
|
||||
span.sampled.Store(sampled)
|
||||
|
||||
ctx = ContextWithSpan(ctx, span)
|
||||
|
||||
if sampled {
|
||||
// Only build traces if sampled.
|
||||
cfg := NewSpanStartConfig(opts...)
|
||||
span.traces, span.span = t.traces(name, cfg, span.spanContext, psc)
|
||||
}
|
||||
|
||||
return ctx, span
|
||||
}
|
||||
|
||||
// Expected to be implemented in eBPF.
|
||||
//
|
||||
//go:noinline
|
||||
func (t *autoTracer) start(
|
||||
ctx context.Context,
|
||||
spanPtr *autoSpan,
|
||||
psc *SpanContext,
|
||||
sampled *bool,
|
||||
sc *SpanContext,
|
||||
) {
|
||||
start(ctx, spanPtr, psc, sampled, sc)
|
||||
}
|
||||
|
||||
// start is used for testing.
|
||||
var start = func(context.Context, *autoSpan, *SpanContext, *bool, *SpanContext) {}
|
||||
|
||||
func (t autoTracer) traces(name string, cfg SpanConfig, sc, psc SpanContext) (*telemetry.Traces, *telemetry.Span) {
|
||||
span := &telemetry.Span{
|
||||
TraceID: telemetry.TraceID(sc.TraceID()),
|
||||
SpanID: telemetry.SpanID(sc.SpanID()),
|
||||
Flags: uint32(sc.TraceFlags()),
|
||||
TraceState: sc.TraceState().String(),
|
||||
ParentSpanID: telemetry.SpanID(psc.SpanID()),
|
||||
Name: name,
|
||||
Kind: spanKind(cfg.SpanKind()),
|
||||
}
|
||||
|
||||
span.Attrs, span.DroppedAttrs = convCappedAttrs(maxSpan.Attrs, cfg.Attributes())
|
||||
|
||||
links := cfg.Links()
|
||||
if limit := maxSpan.Links; limit == 0 {
|
||||
n := int64(len(links))
|
||||
if n > 0 {
|
||||
span.DroppedLinks = uint32(min(n, math.MaxUint32)) // nolint: gosec // Bounds checked.
|
||||
}
|
||||
} else {
|
||||
if limit > 0 {
|
||||
n := int64(max(len(links)-limit, 0))
|
||||
span.DroppedLinks = uint32(min(n, math.MaxUint32)) // nolint: gosec // Bounds checked.
|
||||
links = links[n:]
|
||||
}
|
||||
span.Links = convLinks(links)
|
||||
}
|
||||
|
||||
if t := cfg.Timestamp(); !t.IsZero() {
|
||||
span.StartTime = cfg.Timestamp()
|
||||
} else {
|
||||
span.StartTime = time.Now()
|
||||
}
|
||||
|
||||
return &telemetry.Traces{
|
||||
ResourceSpans: []*telemetry.ResourceSpans{
|
||||
{
|
||||
ScopeSpans: []*telemetry.ScopeSpans{
|
||||
{
|
||||
Scope: &telemetry.Scope{
|
||||
Name: t.name,
|
||||
Version: t.version,
|
||||
},
|
||||
Spans: []*telemetry.Span{span},
|
||||
SchemaURL: t.schemaURL,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}, span
|
||||
}
|
||||
|
||||
func spanKind(kind SpanKind) telemetry.SpanKind {
|
||||
switch kind {
|
||||
case SpanKindInternal:
|
||||
return telemetry.SpanKindInternal
|
||||
case SpanKindServer:
|
||||
return telemetry.SpanKindServer
|
||||
case SpanKindClient:
|
||||
return telemetry.SpanKindClient
|
||||
case SpanKindProducer:
|
||||
return telemetry.SpanKindProducer
|
||||
case SpanKindConsumer:
|
||||
return telemetry.SpanKindConsumer
|
||||
}
|
||||
return telemetry.SpanKind(0) // undefined.
|
||||
}
|
||||
|
||||
type autoSpan struct {
|
||||
embedded.Span
|
||||
|
||||
spanContext SpanContext
|
||||
sampled atomic.Bool
|
||||
|
||||
mu sync.Mutex
|
||||
traces *telemetry.Traces
|
||||
span *telemetry.Span
|
||||
}
|
||||
|
||||
func (s *autoSpan) SpanContext() SpanContext {
|
||||
if s == nil {
|
||||
return SpanContext{}
|
||||
}
|
||||
// s.spanContext is immutable, do not acquire lock s.mu.
|
||||
return s.spanContext
|
||||
}
|
||||
|
||||
func (s *autoSpan) IsRecording() bool {
|
||||
if s == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return s.sampled.Load()
|
||||
}
|
||||
|
||||
func (s *autoSpan) SetStatus(c codes.Code, msg string) {
|
||||
if s == nil || !s.sampled.Load() {
|
||||
return
|
||||
}
|
||||
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
if s.span.Status == nil {
|
||||
s.span.Status = new(telemetry.Status)
|
||||
}
|
||||
|
||||
s.span.Status.Message = msg
|
||||
|
||||
switch c {
|
||||
case codes.Unset:
|
||||
s.span.Status.Code = telemetry.StatusCodeUnset
|
||||
case codes.Error:
|
||||
s.span.Status.Code = telemetry.StatusCodeError
|
||||
case codes.Ok:
|
||||
s.span.Status.Code = telemetry.StatusCodeOK
|
||||
}
|
||||
}
|
||||
|
||||
func (s *autoSpan) SetAttributes(attrs ...attribute.KeyValue) {
|
||||
if s == nil || !s.sampled.Load() {
|
||||
return
|
||||
}
|
||||
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
limit := maxSpan.Attrs
|
||||
if limit == 0 {
|
||||
// No attributes allowed.
|
||||
n := int64(len(attrs))
|
||||
if n > 0 {
|
||||
s.span.DroppedAttrs += uint32(min(n, math.MaxUint32)) // nolint: gosec // Bounds checked.
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
m := make(map[string]int)
|
||||
for i, a := range s.span.Attrs {
|
||||
m[a.Key] = i
|
||||
}
|
||||
|
||||
for _, a := range attrs {
|
||||
val := convAttrValue(a.Value)
|
||||
if val.Empty() {
|
||||
s.span.DroppedAttrs++
|
||||
continue
|
||||
}
|
||||
|
||||
if idx, ok := m[string(a.Key)]; ok {
|
||||
s.span.Attrs[idx] = telemetry.Attr{
|
||||
Key: string(a.Key),
|
||||
Value: val,
|
||||
}
|
||||
} else if limit < 0 || len(s.span.Attrs) < limit {
|
||||
s.span.Attrs = append(s.span.Attrs, telemetry.Attr{
|
||||
Key: string(a.Key),
|
||||
Value: val,
|
||||
})
|
||||
m[string(a.Key)] = len(s.span.Attrs) - 1
|
||||
} else {
|
||||
s.span.DroppedAttrs++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// convCappedAttrs converts up to limit attrs into a []telemetry.Attr. The
|
||||
// number of dropped attributes is also returned.
|
||||
func convCappedAttrs(limit int, attrs []attribute.KeyValue) ([]telemetry.Attr, uint32) {
|
||||
n := len(attrs)
|
||||
if limit == 0 {
|
||||
var out uint32
|
||||
if n > 0 {
|
||||
out = uint32(min(int64(n), math.MaxUint32)) // nolint: gosec // Bounds checked.
|
||||
}
|
||||
return nil, out
|
||||
}
|
||||
|
||||
if limit < 0 {
|
||||
// Unlimited.
|
||||
return convAttrs(attrs), 0
|
||||
}
|
||||
|
||||
if n < 0 {
|
||||
n = 0
|
||||
}
|
||||
|
||||
limit = min(n, limit)
|
||||
return convAttrs(attrs[:limit]), uint32(n - limit) // nolint: gosec // Bounds checked.
|
||||
}
|
||||
|
||||
func convAttrs(attrs []attribute.KeyValue) []telemetry.Attr {
|
||||
if len(attrs) == 0 {
|
||||
// Avoid allocations if not necessary.
|
||||
return nil
|
||||
}
|
||||
|
||||
out := make([]telemetry.Attr, 0, len(attrs))
|
||||
for _, attr := range attrs {
|
||||
key := string(attr.Key)
|
||||
val := convAttrValue(attr.Value)
|
||||
if val.Empty() {
|
||||
continue
|
||||
}
|
||||
out = append(out, telemetry.Attr{Key: key, Value: val})
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func convAttrValue(value attribute.Value) telemetry.Value {
|
||||
switch value.Type() {
|
||||
case attribute.BOOL:
|
||||
return telemetry.BoolValue(value.AsBool())
|
||||
case attribute.INT64:
|
||||
return telemetry.Int64Value(value.AsInt64())
|
||||
case attribute.FLOAT64:
|
||||
return telemetry.Float64Value(value.AsFloat64())
|
||||
case attribute.STRING:
|
||||
v := truncate(maxSpan.AttrValueLen, value.AsString())
|
||||
return telemetry.StringValue(v)
|
||||
case attribute.BOOLSLICE:
|
||||
slice := value.AsBoolSlice()
|
||||
out := make([]telemetry.Value, 0, len(slice))
|
||||
for _, v := range slice {
|
||||
out = append(out, telemetry.BoolValue(v))
|
||||
}
|
||||
return telemetry.SliceValue(out...)
|
||||
case attribute.INT64SLICE:
|
||||
slice := value.AsInt64Slice()
|
||||
out := make([]telemetry.Value, 0, len(slice))
|
||||
for _, v := range slice {
|
||||
out = append(out, telemetry.Int64Value(v))
|
||||
}
|
||||
return telemetry.SliceValue(out...)
|
||||
case attribute.FLOAT64SLICE:
|
||||
slice := value.AsFloat64Slice()
|
||||
out := make([]telemetry.Value, 0, len(slice))
|
||||
for _, v := range slice {
|
||||
out = append(out, telemetry.Float64Value(v))
|
||||
}
|
||||
return telemetry.SliceValue(out...)
|
||||
case attribute.STRINGSLICE:
|
||||
slice := value.AsStringSlice()
|
||||
out := make([]telemetry.Value, 0, len(slice))
|
||||
for _, v := range slice {
|
||||
v = truncate(maxSpan.AttrValueLen, v)
|
||||
out = append(out, telemetry.StringValue(v))
|
||||
}
|
||||
return telemetry.SliceValue(out...)
|
||||
}
|
||||
return telemetry.Value{}
|
||||
}
|
||||
|
||||
// truncate returns a truncated version of s such that it contains less than
|
||||
// the limit number of characters. Truncation is applied by returning the limit
|
||||
// number of valid characters contained in s.
|
||||
//
|
||||
// If limit is negative, it returns the original string.
|
||||
//
|
||||
// UTF-8 is supported. When truncating, all invalid characters are dropped
|
||||
// before applying truncation.
|
||||
//
|
||||
// If s already contains less than the limit number of bytes, it is returned
|
||||
// unchanged. No invalid characters are removed.
|
||||
func truncate(limit int, s string) string {
|
||||
// This prioritize performance in the following order based on the most
|
||||
// common expected use-cases.
|
||||
//
|
||||
// - Short values less than the default limit (128).
|
||||
// - Strings with valid encodings that exceed the limit.
|
||||
// - No limit.
|
||||
// - Strings with invalid encodings that exceed the limit.
|
||||
if limit < 0 || len(s) <= limit {
|
||||
return s
|
||||
}
|
||||
|
||||
// Optimistically, assume all valid UTF-8.
|
||||
var b strings.Builder
|
||||
count := 0
|
||||
for i, c := range s {
|
||||
if c != utf8.RuneError {
|
||||
count++
|
||||
if count > limit {
|
||||
return s[:i]
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
_, size := utf8.DecodeRuneInString(s[i:])
|
||||
if size == 1 {
|
||||
// Invalid encoding.
|
||||
b.Grow(len(s) - 1)
|
||||
_, _ = b.WriteString(s[:i])
|
||||
s = s[i:]
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// Fast-path, no invalid input.
|
||||
if b.Cap() == 0 {
|
||||
return s
|
||||
}
|
||||
|
||||
// Truncate while validating UTF-8.
|
||||
for i := 0; i < len(s) && count < limit; {
|
||||
c := s[i]
|
||||
if c < utf8.RuneSelf {
|
||||
// Optimization for single byte runes (common case).
|
||||
_ = b.WriteByte(c)
|
||||
i++
|
||||
count++
|
||||
continue
|
||||
}
|
||||
|
||||
_, size := utf8.DecodeRuneInString(s[i:])
|
||||
if size == 1 {
|
||||
// We checked for all 1-byte runes above, this is a RuneError.
|
||||
i++
|
||||
continue
|
||||
}
|
||||
|
||||
_, _ = b.WriteString(s[i : i+size])
|
||||
i += size
|
||||
count++
|
||||
}
|
||||
|
||||
return b.String()
|
||||
}
|
||||
|
||||
func (s *autoSpan) End(opts ...SpanEndOption) {
|
||||
if s == nil || !s.sampled.Swap(false) {
|
||||
return
|
||||
}
|
||||
|
||||
// s.end exists so the lock (s.mu) is not held while s.ended is called.
|
||||
s.ended(s.end(opts))
|
||||
}
|
||||
|
||||
func (s *autoSpan) end(opts []SpanEndOption) []byte {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
cfg := NewSpanEndConfig(opts...)
|
||||
if t := cfg.Timestamp(); !t.IsZero() {
|
||||
s.span.EndTime = cfg.Timestamp()
|
||||
} else {
|
||||
s.span.EndTime = time.Now()
|
||||
}
|
||||
|
||||
b, _ := json.Marshal(s.traces) // TODO: do not ignore this error.
|
||||
return b
|
||||
}
|
||||
|
||||
// Expected to be implemented in eBPF.
|
||||
//
|
||||
//go:noinline
|
||||
func (*autoSpan) ended(buf []byte) { ended(buf) }
|
||||
|
||||
// ended is used for testing.
|
||||
var ended = func([]byte) {}
|
||||
|
||||
func (s *autoSpan) RecordError(err error, opts ...EventOption) {
|
||||
if s == nil || err == nil || !s.sampled.Load() {
|
||||
return
|
||||
}
|
||||
|
||||
cfg := NewEventConfig(opts...)
|
||||
|
||||
attrs := cfg.Attributes()
|
||||
attrs = append(attrs,
|
||||
semconv.ExceptionType(typeStr(err)),
|
||||
semconv.ExceptionMessage(err.Error()),
|
||||
)
|
||||
if cfg.StackTrace() {
|
||||
buf := make([]byte, 2048)
|
||||
n := runtime.Stack(buf, false)
|
||||
attrs = append(attrs, semconv.ExceptionStacktrace(string(buf[0:n])))
|
||||
}
|
||||
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
s.addEvent(semconv.ExceptionEventName, cfg.Timestamp(), attrs)
|
||||
}
|
||||
|
||||
func typeStr(i any) string {
|
||||
t := reflect.TypeOf(i)
|
||||
if t.PkgPath() == "" && t.Name() == "" {
|
||||
// Likely a builtin type.
|
||||
return t.String()
|
||||
}
|
||||
return fmt.Sprintf("%s.%s", t.PkgPath(), t.Name())
|
||||
}
|
||||
|
||||
func (s *autoSpan) AddEvent(name string, opts ...EventOption) {
|
||||
if s == nil || !s.sampled.Load() {
|
||||
return
|
||||
}
|
||||
|
||||
cfg := NewEventConfig(opts...)
|
||||
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
s.addEvent(name, cfg.Timestamp(), cfg.Attributes())
|
||||
}
|
||||
|
||||
// addEvent adds an event with name and attrs at tStamp to the span. The span
|
||||
// lock (s.mu) needs to be held by the caller.
|
||||
func (s *autoSpan) addEvent(name string, tStamp time.Time, attrs []attribute.KeyValue) {
|
||||
limit := maxSpan.Events
|
||||
|
||||
if limit == 0 {
|
||||
s.span.DroppedEvents++
|
||||
return
|
||||
}
|
||||
|
||||
if limit > 0 && len(s.span.Events) == limit {
|
||||
// Drop head while avoiding allocation of more capacity.
|
||||
copy(s.span.Events[:limit-1], s.span.Events[1:])
|
||||
s.span.Events = s.span.Events[:limit-1]
|
||||
s.span.DroppedEvents++
|
||||
}
|
||||
|
||||
e := &telemetry.SpanEvent{Time: tStamp, Name: name}
|
||||
e.Attrs, e.DroppedAttrs = convCappedAttrs(maxSpan.EventAttrs, attrs)
|
||||
|
||||
s.span.Events = append(s.span.Events, e)
|
||||
}
|
||||
|
||||
func (s *autoSpan) AddLink(link Link) {
|
||||
if s == nil || !s.sampled.Load() {
|
||||
return
|
||||
}
|
||||
|
||||
l := maxSpan.Links
|
||||
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
if l == 0 {
|
||||
s.span.DroppedLinks++
|
||||
return
|
||||
}
|
||||
|
||||
if l > 0 && len(s.span.Links) == l {
|
||||
// Drop head while avoiding allocation of more capacity.
|
||||
copy(s.span.Links[:l-1], s.span.Links[1:])
|
||||
s.span.Links = s.span.Links[:l-1]
|
||||
s.span.DroppedLinks++
|
||||
}
|
||||
|
||||
s.span.Links = append(s.span.Links, convLink(link))
|
||||
}
|
||||
|
||||
func convLinks(links []Link) []*telemetry.SpanLink {
|
||||
out := make([]*telemetry.SpanLink, 0, len(links))
|
||||
for _, link := range links {
|
||||
out = append(out, convLink(link))
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func convLink(link Link) *telemetry.SpanLink {
|
||||
l := &telemetry.SpanLink{
|
||||
TraceID: telemetry.TraceID(link.SpanContext.TraceID()),
|
||||
SpanID: telemetry.SpanID(link.SpanContext.SpanID()),
|
||||
TraceState: link.SpanContext.TraceState().String(),
|
||||
Flags: uint32(link.SpanContext.TraceFlags()),
|
||||
}
|
||||
l.Attrs, l.DroppedAttrs = convCappedAttrs(maxSpan.LinkAttrs, link.Attributes)
|
||||
|
||||
return l
|
||||
}
|
||||
|
||||
func (s *autoSpan) SetName(name string) {
|
||||
if s == nil || !s.sampled.Load() {
|
||||
return
|
||||
}
|
||||
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
s.span.Name = name
|
||||
}
|
||||
|
||||
func (*autoSpan) TracerProvider() TracerProvider { return newAutoTracerProvider() }
|
||||
|
||||
// maxSpan are the span limits resolved during startup.
|
||||
var maxSpan = newSpanLimits()
|
||||
|
||||
type spanLimits struct {
|
||||
// Attrs is the number of allowed attributes for a span.
|
||||
//
|
||||
// This is resolved from the environment variable value for the
|
||||
// OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT key if it exists. Otherwise, the
|
||||
// environment variable value for OTEL_ATTRIBUTE_COUNT_LIMIT, or 128 if
|
||||
// that is not set, is used.
|
||||
Attrs int
|
||||
// AttrValueLen is the maximum attribute value length allowed for a span.
|
||||
//
|
||||
// This is resolved from the environment variable value for the
|
||||
// OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT key if it exists. Otherwise, the
|
||||
// environment variable value for OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT, or -1
|
||||
// if that is not set, is used.
|
||||
AttrValueLen int
|
||||
// Events is the number of allowed events for a span.
|
||||
//
|
||||
// This is resolved from the environment variable value for the
|
||||
// OTEL_SPAN_EVENT_COUNT_LIMIT key, or 128 is used if that is not set.
|
||||
Events int
|
||||
// EventAttrs is the number of allowed attributes for a span event.
|
||||
//
|
||||
// The is resolved from the environment variable value for the
|
||||
// OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT key, or 128 is used if that is not set.
|
||||
EventAttrs int
|
||||
// Links is the number of allowed Links for a span.
|
||||
//
|
||||
// This is resolved from the environment variable value for the
|
||||
// OTEL_SPAN_LINK_COUNT_LIMIT, or 128 is used if that is not set.
|
||||
Links int
|
||||
// LinkAttrs is the number of allowed attributes for a span link.
|
||||
//
|
||||
// This is resolved from the environment variable value for the
|
||||
// OTEL_LINK_ATTRIBUTE_COUNT_LIMIT, or 128 is used if that is not set.
|
||||
LinkAttrs int
|
||||
}
|
||||
|
||||
func newSpanLimits() spanLimits {
|
||||
return spanLimits{
|
||||
Attrs: firstEnv(
|
||||
128,
|
||||
"OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT",
|
||||
"OTEL_ATTRIBUTE_COUNT_LIMIT",
|
||||
),
|
||||
AttrValueLen: firstEnv(
|
||||
-1, // Unlimited.
|
||||
"OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT",
|
||||
"OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT",
|
||||
),
|
||||
Events: firstEnv(128, "OTEL_SPAN_EVENT_COUNT_LIMIT"),
|
||||
EventAttrs: firstEnv(128, "OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT"),
|
||||
Links: firstEnv(128, "OTEL_SPAN_LINK_COUNT_LIMIT"),
|
||||
LinkAttrs: firstEnv(128, "OTEL_LINK_ATTRIBUTE_COUNT_LIMIT"),
|
||||
}
|
||||
}
|
||||
|
||||
// firstEnv returns the parsed integer value of the first matching environment
|
||||
// variable from keys. The defaultVal is returned if the value is not an
|
||||
// integer or no match is found.
|
||||
func firstEnv(defaultVal int, keys ...string) int {
|
||||
for _, key := range keys {
|
||||
strV := os.Getenv(key)
|
||||
if strV == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
v, err := strconv.Atoi(strV)
|
||||
if err == nil {
|
||||
return v
|
||||
}
|
||||
// Ignore invalid environment variable.
|
||||
}
|
||||
|
||||
return defaultVal
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package telemetry // import "go.opentelemetry.io/otel/trace/internal/telemetry"
|
||||
|
||||
// Attr is a key-value pair.
|
||||
type Attr struct {
|
||||
Key string `json:"key,omitempty"`
|
||||
Value Value `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// String returns an Attr for a string value.
|
||||
func String(key, value string) Attr {
|
||||
return Attr{key, StringValue(value)}
|
||||
}
|
||||
|
||||
// Int64 returns an Attr for an int64 value.
|
||||
func Int64(key string, value int64) Attr {
|
||||
return Attr{key, Int64Value(value)}
|
||||
}
|
||||
|
||||
// Int returns an Attr for an int value.
|
||||
func Int(key string, value int) Attr {
|
||||
return Int64(key, int64(value))
|
||||
}
|
||||
|
||||
// Float64 returns an Attr for a float64 value.
|
||||
func Float64(key string, value float64) Attr {
|
||||
return Attr{key, Float64Value(value)}
|
||||
}
|
||||
|
||||
// Bool returns an Attr for a bool value.
|
||||
func Bool(key string, value bool) Attr {
|
||||
return Attr{key, BoolValue(value)}
|
||||
}
|
||||
|
||||
// Bytes returns an Attr for a []byte value.
|
||||
// The passed slice must not be changed after it is passed.
|
||||
func Bytes(key string, value []byte) Attr {
|
||||
return Attr{key, BytesValue(value)}
|
||||
}
|
||||
|
||||
// Slice returns an Attr for a []Value value.
|
||||
// The passed slice must not be changed after it is passed.
|
||||
func Slice(key string, value ...Value) Attr {
|
||||
return Attr{key, SliceValue(value...)}
|
||||
}
|
||||
|
||||
// Map returns an Attr for a map value.
|
||||
// The passed slice must not be changed after it is passed.
|
||||
func Map(key string, value ...Attr) Attr {
|
||||
return Attr{key, MapValue(value...)}
|
||||
}
|
||||
|
||||
// Equal returns if a is equal to b.
|
||||
func (a Attr) Equal(b Attr) bool {
|
||||
return a.Key == b.Key && a.Value.Equal(b.Value)
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/*
|
||||
Package telemetry provides a lightweight representations of OpenTelemetry
|
||||
telemetry that is compatible with the OTLP JSON protobuf encoding.
|
||||
*/
|
||||
package telemetry // import "go.opentelemetry.io/otel/trace/internal/telemetry"
|
|
@ -0,0 +1,103 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package telemetry // import "go.opentelemetry.io/otel/trace/internal/telemetry"
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
const (
|
||||
traceIDSize = 16
|
||||
spanIDSize = 8
|
||||
)
|
||||
|
||||
// TraceID is a custom data type that is used for all trace IDs.
|
||||
type TraceID [traceIDSize]byte
|
||||
|
||||
// String returns the hex string representation form of a TraceID.
|
||||
func (tid TraceID) String() string {
|
||||
return hex.EncodeToString(tid[:])
|
||||
}
|
||||
|
||||
// IsEmpty returns false if id contains at least one non-zero byte.
|
||||
func (tid TraceID) IsEmpty() bool {
|
||||
return tid == [traceIDSize]byte{}
|
||||
}
|
||||
|
||||
// MarshalJSON converts the trace ID into a hex string enclosed in quotes.
|
||||
func (tid TraceID) MarshalJSON() ([]byte, error) {
|
||||
if tid.IsEmpty() {
|
||||
return []byte(`""`), nil
|
||||
}
|
||||
return marshalJSON(tid[:])
|
||||
}
|
||||
|
||||
// UnmarshalJSON inflates the trace ID from hex string, possibly enclosed in
|
||||
// quotes.
|
||||
func (tid *TraceID) UnmarshalJSON(data []byte) error {
|
||||
*tid = [traceIDSize]byte{}
|
||||
return unmarshalJSON(tid[:], data)
|
||||
}
|
||||
|
||||
// SpanID is a custom data type that is used for all span IDs.
|
||||
type SpanID [spanIDSize]byte
|
||||
|
||||
// String returns the hex string representation form of a SpanID.
|
||||
func (sid SpanID) String() string {
|
||||
return hex.EncodeToString(sid[:])
|
||||
}
|
||||
|
||||
// IsEmpty returns true if the span ID contains at least one non-zero byte.
|
||||
func (sid SpanID) IsEmpty() bool {
|
||||
return sid == [spanIDSize]byte{}
|
||||
}
|
||||
|
||||
// MarshalJSON converts span ID into a hex string enclosed in quotes.
|
||||
func (sid SpanID) MarshalJSON() ([]byte, error) {
|
||||
if sid.IsEmpty() {
|
||||
return []byte(`""`), nil
|
||||
}
|
||||
return marshalJSON(sid[:])
|
||||
}
|
||||
|
||||
// UnmarshalJSON decodes span ID from hex string, possibly enclosed in quotes.
|
||||
func (sid *SpanID) UnmarshalJSON(data []byte) error {
|
||||
*sid = [spanIDSize]byte{}
|
||||
return unmarshalJSON(sid[:], data)
|
||||
}
|
||||
|
||||
// marshalJSON converts id into a hex string enclosed in quotes.
|
||||
func marshalJSON(id []byte) ([]byte, error) {
|
||||
// Plus 2 quote chars at the start and end.
|
||||
hexLen := hex.EncodedLen(len(id)) + 2
|
||||
|
||||
b := make([]byte, hexLen)
|
||||
hex.Encode(b[1:hexLen-1], id)
|
||||
b[0], b[hexLen-1] = '"', '"'
|
||||
|
||||
return b, nil
|
||||
}
|
||||
|
||||
// unmarshalJSON inflates trace id from hex string, possibly enclosed in quotes.
|
||||
func unmarshalJSON(dst []byte, src []byte) error {
|
||||
if l := len(src); l >= 2 && src[0] == '"' && src[l-1] == '"' {
|
||||
src = src[1 : l-1]
|
||||
}
|
||||
nLen := len(src)
|
||||
if nLen == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(dst) != hex.DecodedLen(nLen) {
|
||||
return errors.New("invalid length for ID")
|
||||
}
|
||||
|
||||
_, err := hex.Decode(dst, src)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot unmarshal ID from string '%s': %w", string(src), err)
|
||||
}
|
||||
return nil
|
||||
}
|
67
vendor/go.opentelemetry.io/otel/trace/internal/telemetry/number.go
generated
vendored
Normal file
67
vendor/go.opentelemetry.io/otel/trace/internal/telemetry/number.go
generated
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package telemetry // import "go.opentelemetry.io/otel/trace/internal/telemetry"
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// protoInt64 represents the protobuf encoding of integers which can be either
|
||||
// strings or integers.
|
||||
type protoInt64 int64
|
||||
|
||||
// Int64 returns the protoInt64 as an int64.
|
||||
func (i *protoInt64) Int64() int64 { return int64(*i) }
|
||||
|
||||
// UnmarshalJSON decodes both strings and integers.
|
||||
func (i *protoInt64) UnmarshalJSON(data []byte) error {
|
||||
if data[0] == '"' {
|
||||
var str string
|
||||
if err := json.Unmarshal(data, &str); err != nil {
|
||||
return err
|
||||
}
|
||||
parsedInt, err := strconv.ParseInt(str, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*i = protoInt64(parsedInt)
|
||||
} else {
|
||||
var parsedInt int64
|
||||
if err := json.Unmarshal(data, &parsedInt); err != nil {
|
||||
return err
|
||||
}
|
||||
*i = protoInt64(parsedInt)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// protoUint64 represents the protobuf encoding of integers which can be either
|
||||
// strings or integers.
|
||||
type protoUint64 uint64
|
||||
|
||||
// Int64 returns the protoUint64 as a uint64.
|
||||
func (i *protoUint64) Uint64() uint64 { return uint64(*i) }
|
||||
|
||||
// UnmarshalJSON decodes both strings and integers.
|
||||
func (i *protoUint64) UnmarshalJSON(data []byte) error {
|
||||
if data[0] == '"' {
|
||||
var str string
|
||||
if err := json.Unmarshal(data, &str); err != nil {
|
||||
return err
|
||||
}
|
||||
parsedUint, err := strconv.ParseUint(str, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*i = protoUint64(parsedUint)
|
||||
} else {
|
||||
var parsedUint uint64
|
||||
if err := json.Unmarshal(data, &parsedUint); err != nil {
|
||||
return err
|
||||
}
|
||||
*i = protoUint64(parsedUint)
|
||||
}
|
||||
return nil
|
||||
}
|
66
vendor/go.opentelemetry.io/otel/trace/internal/telemetry/resource.go
generated
vendored
Normal file
66
vendor/go.opentelemetry.io/otel/trace/internal/telemetry/resource.go
generated
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package telemetry // import "go.opentelemetry.io/otel/trace/internal/telemetry"
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
// Resource information.
|
||||
type Resource struct {
|
||||
// Attrs are the set of attributes that describe the resource. Attribute
|
||||
// keys MUST be unique (it is not allowed to have more than one attribute
|
||||
// with the same key).
|
||||
Attrs []Attr `json:"attributes,omitempty"`
|
||||
// DroppedAttrs is the number of dropped attributes. If the value
|
||||
// is 0, then no attributes were dropped.
|
||||
DroppedAttrs uint32 `json:"droppedAttributesCount,omitempty"`
|
||||
}
|
||||
|
||||
// UnmarshalJSON decodes the OTLP formatted JSON contained in data into r.
|
||||
func (r *Resource) UnmarshalJSON(data []byte) error {
|
||||
decoder := json.NewDecoder(bytes.NewReader(data))
|
||||
|
||||
t, err := decoder.Token()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if t != json.Delim('{') {
|
||||
return errors.New("invalid Resource type")
|
||||
}
|
||||
|
||||
for decoder.More() {
|
||||
keyIface, err := decoder.Token()
|
||||
if err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
// Empty.
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
key, ok := keyIface.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid Resource field: %#v", keyIface)
|
||||
}
|
||||
|
||||
switch key {
|
||||
case "attributes":
|
||||
err = decoder.Decode(&r.Attrs)
|
||||
case "droppedAttributesCount", "dropped_attributes_count":
|
||||
err = decoder.Decode(&r.DroppedAttrs)
|
||||
default:
|
||||
// Skip unknown.
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package telemetry // import "go.opentelemetry.io/otel/trace/internal/telemetry"
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
// Scope is the identifying values of the instrumentation scope.
|
||||
type Scope struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
Attrs []Attr `json:"attributes,omitempty"`
|
||||
DroppedAttrs uint32 `json:"droppedAttributesCount,omitempty"`
|
||||
}
|
||||
|
||||
// UnmarshalJSON decodes the OTLP formatted JSON contained in data into r.
|
||||
func (s *Scope) UnmarshalJSON(data []byte) error {
|
||||
decoder := json.NewDecoder(bytes.NewReader(data))
|
||||
|
||||
t, err := decoder.Token()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if t != json.Delim('{') {
|
||||
return errors.New("invalid Scope type")
|
||||
}
|
||||
|
||||
for decoder.More() {
|
||||
keyIface, err := decoder.Token()
|
||||
if err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
// Empty.
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
key, ok := keyIface.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid Scope field: %#v", keyIface)
|
||||
}
|
||||
|
||||
switch key {
|
||||
case "name":
|
||||
err = decoder.Decode(&s.Name)
|
||||
case "version":
|
||||
err = decoder.Decode(&s.Version)
|
||||
case "attributes":
|
||||
err = decoder.Decode(&s.Attrs)
|
||||
case "droppedAttributesCount", "dropped_attributes_count":
|
||||
err = decoder.Decode(&s.DroppedAttrs)
|
||||
default:
|
||||
// Skip unknown.
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,460 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package telemetry // import "go.opentelemetry.io/otel/trace/internal/telemetry"
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"time"
|
||||
)
|
||||
|
||||
// A Span represents a single operation performed by a single component of the
|
||||
// system.
|
||||
type Span struct {
|
||||
// A unique identifier for a trace. All spans from the same trace share
|
||||
// the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes OR
|
||||
// of length other than 16 bytes is considered invalid (empty string in OTLP/JSON
|
||||
// is zero-length and thus is also invalid).
|
||||
//
|
||||
// This field is required.
|
||||
TraceID TraceID `json:"traceId,omitempty"`
|
||||
// A unique identifier for a span within a trace, assigned when the span
|
||||
// is created. The ID is an 8-byte array. An ID with all zeroes OR of length
|
||||
// other than 8 bytes is considered invalid (empty string in OTLP/JSON
|
||||
// is zero-length and thus is also invalid).
|
||||
//
|
||||
// This field is required.
|
||||
SpanID SpanID `json:"spanId,omitempty"`
|
||||
// trace_state conveys information about request position in multiple distributed tracing graphs.
|
||||
// It is a trace_state in w3c-trace-context format: https://www.w3.org/TR/trace-context/#tracestate-header
|
||||
// See also https://github.com/w3c/distributed-tracing for more details about this field.
|
||||
TraceState string `json:"traceState,omitempty"`
|
||||
// The `span_id` of this span's parent span. If this is a root span, then this
|
||||
// field must be empty. The ID is an 8-byte array.
|
||||
ParentSpanID SpanID `json:"parentSpanId,omitempty"`
|
||||
// Flags, a bit field.
|
||||
//
|
||||
// Bits 0-7 (8 least significant bits) are the trace flags as defined in W3C Trace
|
||||
// Context specification. To read the 8-bit W3C trace flag, use
|
||||
// `flags & SPAN_FLAGS_TRACE_FLAGS_MASK`.
|
||||
//
|
||||
// See https://www.w3.org/TR/trace-context-2/#trace-flags for the flag definitions.
|
||||
//
|
||||
// Bits 8 and 9 represent the 3 states of whether a span's parent
|
||||
// is remote. The states are (unknown, is not remote, is remote).
|
||||
// To read whether the value is known, use `(flags & SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK) != 0`.
|
||||
// To read whether the span is remote, use `(flags & SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK) != 0`.
|
||||
//
|
||||
// When creating span messages, if the message is logically forwarded from another source
|
||||
// with an equivalent flags fields (i.e., usually another OTLP span message), the field SHOULD
|
||||
// be copied as-is. If creating from a source that does not have an equivalent flags field
|
||||
// (such as a runtime representation of an OpenTelemetry span), the high 22 bits MUST
|
||||
// be set to zero.
|
||||
// Readers MUST NOT assume that bits 10-31 (22 most significant bits) will be zero.
|
||||
//
|
||||
// [Optional].
|
||||
Flags uint32 `json:"flags,omitempty"`
|
||||
// A description of the span's operation.
|
||||
//
|
||||
// For example, the name can be a qualified method name or a file name
|
||||
// and a line number where the operation is called. A best practice is to use
|
||||
// the same display name at the same call point in an application.
|
||||
// This makes it easier to correlate spans in different traces.
|
||||
//
|
||||
// This field is semantically required to be set to non-empty string.
|
||||
// Empty value is equivalent to an unknown span name.
|
||||
//
|
||||
// This field is required.
|
||||
Name string `json:"name"`
|
||||
// Distinguishes between spans generated in a particular context. For example,
|
||||
// two spans with the same name may be distinguished using `CLIENT` (caller)
|
||||
// and `SERVER` (callee) to identify queueing latency associated with the span.
|
||||
Kind SpanKind `json:"kind,omitempty"`
|
||||
// start_time_unix_nano is the start time of the span. On the client side, this is the time
|
||||
// kept by the local machine where the span execution starts. On the server side, this
|
||||
// is the time when the server's application handler starts running.
|
||||
// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
|
||||
//
|
||||
// This field is semantically required and it is expected that end_time >= start_time.
|
||||
StartTime time.Time `json:"startTimeUnixNano,omitempty"`
|
||||
// end_time_unix_nano is the end time of the span. On the client side, this is the time
|
||||
// kept by the local machine where the span execution ends. On the server side, this
|
||||
// is the time when the server application handler stops running.
|
||||
// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
|
||||
//
|
||||
// This field is semantically required and it is expected that end_time >= start_time.
|
||||
EndTime time.Time `json:"endTimeUnixNano,omitempty"`
|
||||
// attributes is a collection of key/value pairs. Note, global attributes
|
||||
// like server name can be set using the resource API. Examples of attributes:
|
||||
//
|
||||
// "/http/user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
|
||||
// "/http/server_latency": 300
|
||||
// "example.com/myattribute": true
|
||||
// "example.com/score": 10.239
|
||||
//
|
||||
// The OpenTelemetry API specification further restricts the allowed value types:
|
||||
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/README.md#attribute
|
||||
// Attribute keys MUST be unique (it is not allowed to have more than one
|
||||
// attribute with the same key).
|
||||
Attrs []Attr `json:"attributes,omitempty"`
|
||||
// dropped_attributes_count is the number of attributes that were discarded. Attributes
|
||||
// can be discarded because their keys are too long or because there are too many
|
||||
// attributes. If this value is 0, then no attributes were dropped.
|
||||
DroppedAttrs uint32 `json:"droppedAttributesCount,omitempty"`
|
||||
// events is a collection of Event items.
|
||||
Events []*SpanEvent `json:"events,omitempty"`
|
||||
// dropped_events_count is the number of dropped events. If the value is 0, then no
|
||||
// events were dropped.
|
||||
DroppedEvents uint32 `json:"droppedEventsCount,omitempty"`
|
||||
// links is a collection of Links, which are references from this span to a span
|
||||
// in the same or different trace.
|
||||
Links []*SpanLink `json:"links,omitempty"`
|
||||
// dropped_links_count is the number of dropped links after the maximum size was
|
||||
// enforced. If this value is 0, then no links were dropped.
|
||||
DroppedLinks uint32 `json:"droppedLinksCount,omitempty"`
|
||||
// An optional final status for this span. Semantically when Status isn't set, it means
|
||||
// span's status code is unset, i.e. assume STATUS_CODE_UNSET (code = 0).
|
||||
Status *Status `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// MarshalJSON encodes s into OTLP formatted JSON.
|
||||
func (s Span) MarshalJSON() ([]byte, error) {
|
||||
startT := s.StartTime.UnixNano()
|
||||
if s.StartTime.IsZero() || startT < 0 {
|
||||
startT = 0
|
||||
}
|
||||
|
||||
endT := s.EndTime.UnixNano()
|
||||
if s.EndTime.IsZero() || endT < 0 {
|
||||
endT = 0
|
||||
}
|
||||
|
||||
// Override non-empty default SpanID marshal and omitempty.
|
||||
var parentSpanId string
|
||||
if !s.ParentSpanID.IsEmpty() {
|
||||
b := make([]byte, hex.EncodedLen(spanIDSize))
|
||||
hex.Encode(b, s.ParentSpanID[:])
|
||||
parentSpanId = string(b)
|
||||
}
|
||||
|
||||
type Alias Span
|
||||
return json.Marshal(struct {
|
||||
Alias
|
||||
ParentSpanID string `json:"parentSpanId,omitempty"`
|
||||
StartTime uint64 `json:"startTimeUnixNano,omitempty"`
|
||||
EndTime uint64 `json:"endTimeUnixNano,omitempty"`
|
||||
}{
|
||||
Alias: Alias(s),
|
||||
ParentSpanID: parentSpanId,
|
||||
StartTime: uint64(startT), // nolint:gosec // >0 checked above.
|
||||
EndTime: uint64(endT), // nolint:gosec // >0 checked above.
|
||||
})
|
||||
}
|
||||
|
||||
// UnmarshalJSON decodes the OTLP formatted JSON contained in data into s.
|
||||
func (s *Span) UnmarshalJSON(data []byte) error {
|
||||
decoder := json.NewDecoder(bytes.NewReader(data))
|
||||
|
||||
t, err := decoder.Token()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if t != json.Delim('{') {
|
||||
return errors.New("invalid Span type")
|
||||
}
|
||||
|
||||
for decoder.More() {
|
||||
keyIface, err := decoder.Token()
|
||||
if err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
// Empty.
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
key, ok := keyIface.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid Span field: %#v", keyIface)
|
||||
}
|
||||
|
||||
switch key {
|
||||
case "traceId", "trace_id":
|
||||
err = decoder.Decode(&s.TraceID)
|
||||
case "spanId", "span_id":
|
||||
err = decoder.Decode(&s.SpanID)
|
||||
case "traceState", "trace_state":
|
||||
err = decoder.Decode(&s.TraceState)
|
||||
case "parentSpanId", "parent_span_id":
|
||||
err = decoder.Decode(&s.ParentSpanID)
|
||||
case "flags":
|
||||
err = decoder.Decode(&s.Flags)
|
||||
case "name":
|
||||
err = decoder.Decode(&s.Name)
|
||||
case "kind":
|
||||
err = decoder.Decode(&s.Kind)
|
||||
case "startTimeUnixNano", "start_time_unix_nano":
|
||||
var val protoUint64
|
||||
err = decoder.Decode(&val)
|
||||
v := int64(min(val.Uint64(), math.MaxInt64)) // nolint: gosec // Overflow checked.
|
||||
s.StartTime = time.Unix(0, v)
|
||||
case "endTimeUnixNano", "end_time_unix_nano":
|
||||
var val protoUint64
|
||||
err = decoder.Decode(&val)
|
||||
v := int64(min(val.Uint64(), math.MaxInt64)) // nolint: gosec // Overflow checked.
|
||||
s.EndTime = time.Unix(0, v)
|
||||
case "attributes":
|
||||
err = decoder.Decode(&s.Attrs)
|
||||
case "droppedAttributesCount", "dropped_attributes_count":
|
||||
err = decoder.Decode(&s.DroppedAttrs)
|
||||
case "events":
|
||||
err = decoder.Decode(&s.Events)
|
||||
case "droppedEventsCount", "dropped_events_count":
|
||||
err = decoder.Decode(&s.DroppedEvents)
|
||||
case "links":
|
||||
err = decoder.Decode(&s.Links)
|
||||
case "droppedLinksCount", "dropped_links_count":
|
||||
err = decoder.Decode(&s.DroppedLinks)
|
||||
case "status":
|
||||
err = decoder.Decode(&s.Status)
|
||||
default:
|
||||
// Skip unknown.
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SpanFlags represents constants used to interpret the
|
||||
// Span.flags field, which is protobuf 'fixed32' type and is to
|
||||
// be used as bit-fields. Each non-zero value defined in this enum is
|
||||
// a bit-mask. To extract the bit-field, for example, use an
|
||||
// expression like:
|
||||
//
|
||||
// (span.flags & SPAN_FLAGS_TRACE_FLAGS_MASK)
|
||||
//
|
||||
// See https://www.w3.org/TR/trace-context-2/#trace-flags for the flag definitions.
|
||||
//
|
||||
// Note that Span flags were introduced in version 1.1 of the
|
||||
// OpenTelemetry protocol. Older Span producers do not set this
|
||||
// field, consequently consumers should not rely on the absence of a
|
||||
// particular flag bit to indicate the presence of a particular feature.
|
||||
type SpanFlags int32
|
||||
|
||||
const (
|
||||
// Bits 0-7 are used for trace flags.
|
||||
SpanFlagsTraceFlagsMask SpanFlags = 255
|
||||
// Bits 8 and 9 are used to indicate that the parent span or link span is remote.
|
||||
// Bit 8 (`HAS_IS_REMOTE`) indicates whether the value is known.
|
||||
// Bit 9 (`IS_REMOTE`) indicates whether the span or link is remote.
|
||||
SpanFlagsContextHasIsRemoteMask SpanFlags = 256
|
||||
// SpanFlagsContextHasIsRemoteMask indicates the Span is remote.
|
||||
SpanFlagsContextIsRemoteMask SpanFlags = 512
|
||||
)
|
||||
|
||||
// SpanKind is the type of span. Can be used to specify additional relationships between spans
|
||||
// in addition to a parent/child relationship.
|
||||
type SpanKind int32
|
||||
|
||||
const (
|
||||
// Indicates that the span represents an internal operation within an application,
|
||||
// as opposed to an operation happening at the boundaries. Default value.
|
||||
SpanKindInternal SpanKind = 1
|
||||
// Indicates that the span covers server-side handling of an RPC or other
|
||||
// remote network request.
|
||||
SpanKindServer SpanKind = 2
|
||||
// Indicates that the span describes a request to some remote service.
|
||||
SpanKindClient SpanKind = 3
|
||||
// Indicates that the span describes a producer sending a message to a broker.
|
||||
// Unlike CLIENT and SERVER, there is often no direct critical path latency relationship
|
||||
// between producer and consumer spans. A PRODUCER span ends when the message was accepted
|
||||
// by the broker while the logical processing of the message might span a much longer time.
|
||||
SpanKindProducer SpanKind = 4
|
||||
// Indicates that the span describes consumer receiving a message from a broker.
|
||||
// Like the PRODUCER kind, there is often no direct critical path latency relationship
|
||||
// between producer and consumer spans.
|
||||
SpanKindConsumer SpanKind = 5
|
||||
)
|
||||
|
||||
// Event is a time-stamped annotation of the span, consisting of user-supplied
|
||||
// text description and key-value pairs.
|
||||
type SpanEvent struct {
|
||||
// time_unix_nano is the time the event occurred.
|
||||
Time time.Time `json:"timeUnixNano,omitempty"`
|
||||
// name of the event.
|
||||
// This field is semantically required to be set to non-empty string.
|
||||
Name string `json:"name,omitempty"`
|
||||
// attributes is a collection of attribute key/value pairs on the event.
|
||||
// Attribute keys MUST be unique (it is not allowed to have more than one
|
||||
// attribute with the same key).
|
||||
Attrs []Attr `json:"attributes,omitempty"`
|
||||
// dropped_attributes_count is the number of dropped attributes. If the value is 0,
|
||||
// then no attributes were dropped.
|
||||
DroppedAttrs uint32 `json:"droppedAttributesCount,omitempty"`
|
||||
}
|
||||
|
||||
// MarshalJSON encodes e into OTLP formatted JSON.
|
||||
func (e SpanEvent) MarshalJSON() ([]byte, error) {
|
||||
t := e.Time.UnixNano()
|
||||
if e.Time.IsZero() || t < 0 {
|
||||
t = 0
|
||||
}
|
||||
|
||||
type Alias SpanEvent
|
||||
return json.Marshal(struct {
|
||||
Alias
|
||||
Time uint64 `json:"timeUnixNano,omitempty"`
|
||||
}{
|
||||
Alias: Alias(e),
|
||||
Time: uint64(t), // nolint: gosec // >0 checked above
|
||||
})
|
||||
}
|
||||
|
||||
// UnmarshalJSON decodes the OTLP formatted JSON contained in data into se.
|
||||
func (se *SpanEvent) UnmarshalJSON(data []byte) error {
|
||||
decoder := json.NewDecoder(bytes.NewReader(data))
|
||||
|
||||
t, err := decoder.Token()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if t != json.Delim('{') {
|
||||
return errors.New("invalid SpanEvent type")
|
||||
}
|
||||
|
||||
for decoder.More() {
|
||||
keyIface, err := decoder.Token()
|
||||
if err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
// Empty.
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
key, ok := keyIface.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid SpanEvent field: %#v", keyIface)
|
||||
}
|
||||
|
||||
switch key {
|
||||
case "timeUnixNano", "time_unix_nano":
|
||||
var val protoUint64
|
||||
err = decoder.Decode(&val)
|
||||
v := int64(min(val.Uint64(), math.MaxInt64)) // nolint: gosec // Overflow checked.
|
||||
se.Time = time.Unix(0, v)
|
||||
case "name":
|
||||
err = decoder.Decode(&se.Name)
|
||||
case "attributes":
|
||||
err = decoder.Decode(&se.Attrs)
|
||||
case "droppedAttributesCount", "dropped_attributes_count":
|
||||
err = decoder.Decode(&se.DroppedAttrs)
|
||||
default:
|
||||
// Skip unknown.
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// A pointer from the current span to another span in the same trace or in a
|
||||
// different trace. For example, this can be used in batching operations,
|
||||
// where a single batch handler processes multiple requests from different
|
||||
// traces or when the handler receives a request from a different project.
|
||||
type SpanLink struct {
|
||||
// A unique identifier of a trace that this linked span is part of. The ID is a
|
||||
// 16-byte array.
|
||||
TraceID TraceID `json:"traceId,omitempty"`
|
||||
// A unique identifier for the linked span. The ID is an 8-byte array.
|
||||
SpanID SpanID `json:"spanId,omitempty"`
|
||||
// The trace_state associated with the link.
|
||||
TraceState string `json:"traceState,omitempty"`
|
||||
// attributes is a collection of attribute key/value pairs on the link.
|
||||
// Attribute keys MUST be unique (it is not allowed to have more than one
|
||||
// attribute with the same key).
|
||||
Attrs []Attr `json:"attributes,omitempty"`
|
||||
// dropped_attributes_count is the number of dropped attributes. If the value is 0,
|
||||
// then no attributes were dropped.
|
||||
DroppedAttrs uint32 `json:"droppedAttributesCount,omitempty"`
|
||||
// Flags, a bit field.
|
||||
//
|
||||
// Bits 0-7 (8 least significant bits) are the trace flags as defined in W3C Trace
|
||||
// Context specification. To read the 8-bit W3C trace flag, use
|
||||
// `flags & SPAN_FLAGS_TRACE_FLAGS_MASK`.
|
||||
//
|
||||
// See https://www.w3.org/TR/trace-context-2/#trace-flags for the flag definitions.
|
||||
//
|
||||
// Bits 8 and 9 represent the 3 states of whether the link is remote.
|
||||
// The states are (unknown, is not remote, is remote).
|
||||
// To read whether the value is known, use `(flags & SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK) != 0`.
|
||||
// To read whether the link is remote, use `(flags & SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK) != 0`.
|
||||
//
|
||||
// Readers MUST NOT assume that bits 10-31 (22 most significant bits) will be zero.
|
||||
// When creating new spans, bits 10-31 (most-significant 22-bits) MUST be zero.
|
||||
//
|
||||
// [Optional].
|
||||
Flags uint32 `json:"flags,omitempty"`
|
||||
}
|
||||
|
||||
// UnmarshalJSON decodes the OTLP formatted JSON contained in data into sl.
|
||||
func (sl *SpanLink) UnmarshalJSON(data []byte) error {
|
||||
decoder := json.NewDecoder(bytes.NewReader(data))
|
||||
|
||||
t, err := decoder.Token()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if t != json.Delim('{') {
|
||||
return errors.New("invalid SpanLink type")
|
||||
}
|
||||
|
||||
for decoder.More() {
|
||||
keyIface, err := decoder.Token()
|
||||
if err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
// Empty.
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
key, ok := keyIface.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid SpanLink field: %#v", keyIface)
|
||||
}
|
||||
|
||||
switch key {
|
||||
case "traceId", "trace_id":
|
||||
err = decoder.Decode(&sl.TraceID)
|
||||
case "spanId", "span_id":
|
||||
err = decoder.Decode(&sl.SpanID)
|
||||
case "traceState", "trace_state":
|
||||
err = decoder.Decode(&sl.TraceState)
|
||||
case "attributes":
|
||||
err = decoder.Decode(&sl.Attrs)
|
||||
case "droppedAttributesCount", "dropped_attributes_count":
|
||||
err = decoder.Decode(&sl.DroppedAttrs)
|
||||
case "flags":
|
||||
err = decoder.Decode(&sl.Flags)
|
||||
default:
|
||||
// Skip unknown.
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
40
vendor/go.opentelemetry.io/otel/trace/internal/telemetry/status.go
generated
vendored
Normal file
40
vendor/go.opentelemetry.io/otel/trace/internal/telemetry/status.go
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package telemetry // import "go.opentelemetry.io/otel/trace/internal/telemetry"
|
||||
|
||||
// For the semantics of status codes see
|
||||
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#set-status
|
||||
type StatusCode int32
|
||||
|
||||
const (
|
||||
// The default status.
|
||||
StatusCodeUnset StatusCode = 0
|
||||
// The Span has been validated by an Application developer or Operator to
|
||||
// have completed successfully.
|
||||
StatusCodeOK StatusCode = 1
|
||||
// The Span contains an error.
|
||||
StatusCodeError StatusCode = 2
|
||||
)
|
||||
|
||||
var statusCodeStrings = []string{
|
||||
"Unset",
|
||||
"OK",
|
||||
"Error",
|
||||
}
|
||||
|
||||
func (s StatusCode) String() string {
|
||||
if s >= 0 && int(s) < len(statusCodeStrings) {
|
||||
return statusCodeStrings[s]
|
||||
}
|
||||
return "<unknown telemetry.StatusCode>"
|
||||
}
|
||||
|
||||
// The Status type defines a logical error model that is suitable for different
|
||||
// programming environments, including REST APIs and RPC APIs.
|
||||
type Status struct {
|
||||
// A developer-facing human readable error message.
|
||||
Message string `json:"message,omitempty"`
|
||||
// The status code.
|
||||
Code StatusCode `json:"code,omitempty"`
|
||||
}
|
189
vendor/go.opentelemetry.io/otel/trace/internal/telemetry/traces.go
generated
vendored
Normal file
189
vendor/go.opentelemetry.io/otel/trace/internal/telemetry/traces.go
generated
vendored
Normal file
|
@ -0,0 +1,189 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package telemetry // import "go.opentelemetry.io/otel/trace/internal/telemetry"
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
// Traces represents the traces data that can be stored in a persistent storage,
|
||||
// OR can be embedded by other protocols that transfer OTLP traces data but do
|
||||
// not implement the OTLP protocol.
|
||||
//
|
||||
// The main difference between this message and collector protocol is that
|
||||
// in this message there will not be any "control" or "metadata" specific to
|
||||
// OTLP protocol.
|
||||
//
|
||||
// When new fields are added into this message, the OTLP request MUST be updated
|
||||
// as well.
|
||||
type Traces struct {
|
||||
// An array of ResourceSpans.
|
||||
// For data coming from a single resource this array will typically contain
|
||||
// one element. Intermediary nodes that receive data from multiple origins
|
||||
// typically batch the data before forwarding further and in that case this
|
||||
// array will contain multiple elements.
|
||||
ResourceSpans []*ResourceSpans `json:"resourceSpans,omitempty"`
|
||||
}
|
||||
|
||||
// UnmarshalJSON decodes the OTLP formatted JSON contained in data into td.
|
||||
func (td *Traces) UnmarshalJSON(data []byte) error {
|
||||
decoder := json.NewDecoder(bytes.NewReader(data))
|
||||
|
||||
t, err := decoder.Token()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if t != json.Delim('{') {
|
||||
return errors.New("invalid TracesData type")
|
||||
}
|
||||
|
||||
for decoder.More() {
|
||||
keyIface, err := decoder.Token()
|
||||
if err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
// Empty.
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
key, ok := keyIface.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid TracesData field: %#v", keyIface)
|
||||
}
|
||||
|
||||
switch key {
|
||||
case "resourceSpans", "resource_spans":
|
||||
err = decoder.Decode(&td.ResourceSpans)
|
||||
default:
|
||||
// Skip unknown.
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// A collection of ScopeSpans from a Resource.
|
||||
type ResourceSpans struct {
|
||||
// The resource for the spans in this message.
|
||||
// If this field is not set then no resource info is known.
|
||||
Resource Resource `json:"resource"`
|
||||
// A list of ScopeSpans that originate from a resource.
|
||||
ScopeSpans []*ScopeSpans `json:"scopeSpans,omitempty"`
|
||||
// This schema_url applies to the data in the "resource" field. It does not apply
|
||||
// to the data in the "scope_spans" field which have their own schema_url field.
|
||||
SchemaURL string `json:"schemaUrl,omitempty"`
|
||||
}
|
||||
|
||||
// UnmarshalJSON decodes the OTLP formatted JSON contained in data into rs.
|
||||
func (rs *ResourceSpans) UnmarshalJSON(data []byte) error {
|
||||
decoder := json.NewDecoder(bytes.NewReader(data))
|
||||
|
||||
t, err := decoder.Token()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if t != json.Delim('{') {
|
||||
return errors.New("invalid ResourceSpans type")
|
||||
}
|
||||
|
||||
for decoder.More() {
|
||||
keyIface, err := decoder.Token()
|
||||
if err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
// Empty.
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
key, ok := keyIface.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid ResourceSpans field: %#v", keyIface)
|
||||
}
|
||||
|
||||
switch key {
|
||||
case "resource":
|
||||
err = decoder.Decode(&rs.Resource)
|
||||
case "scopeSpans", "scope_spans":
|
||||
err = decoder.Decode(&rs.ScopeSpans)
|
||||
case "schemaUrl", "schema_url":
|
||||
err = decoder.Decode(&rs.SchemaURL)
|
||||
default:
|
||||
// Skip unknown.
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// A collection of Spans produced by an InstrumentationScope.
|
||||
type ScopeSpans struct {
|
||||
// The instrumentation scope information for the spans in this message.
|
||||
// Semantically when InstrumentationScope isn't set, it is equivalent with
|
||||
// an empty instrumentation scope name (unknown).
|
||||
Scope *Scope `json:"scope"`
|
||||
// A list of Spans that originate from an instrumentation scope.
|
||||
Spans []*Span `json:"spans,omitempty"`
|
||||
// The Schema URL, if known. This is the identifier of the Schema that the span data
|
||||
// is recorded in. To learn more about Schema URL see
|
||||
// https://opentelemetry.io/docs/specs/otel/schemas/#schema-url
|
||||
// This schema_url applies to all spans and span events in the "spans" field.
|
||||
SchemaURL string `json:"schemaUrl,omitempty"`
|
||||
}
|
||||
|
||||
// UnmarshalJSON decodes the OTLP formatted JSON contained in data into ss.
|
||||
func (ss *ScopeSpans) UnmarshalJSON(data []byte) error {
|
||||
decoder := json.NewDecoder(bytes.NewReader(data))
|
||||
|
||||
t, err := decoder.Token()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if t != json.Delim('{') {
|
||||
return errors.New("invalid ScopeSpans type")
|
||||
}
|
||||
|
||||
for decoder.More() {
|
||||
keyIface, err := decoder.Token()
|
||||
if err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
// Empty.
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
key, ok := keyIface.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid ScopeSpans field: %#v", keyIface)
|
||||
}
|
||||
|
||||
switch key {
|
||||
case "scope":
|
||||
err = decoder.Decode(&ss.Scope)
|
||||
case "spans":
|
||||
err = decoder.Decode(&ss.Spans)
|
||||
case "schemaUrl", "schema_url":
|
||||
err = decoder.Decode(&ss.SchemaURL)
|
||||
default:
|
||||
// Skip unknown.
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
453
vendor/go.opentelemetry.io/otel/trace/internal/telemetry/value.go
generated
vendored
Normal file
453
vendor/go.opentelemetry.io/otel/trace/internal/telemetry/value.go
generated
vendored
Normal file
|
@ -0,0 +1,453 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package telemetry // import "go.opentelemetry.io/otel/trace/internal/telemetry"
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"cmp"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"slices"
|
||||
"strconv"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// A Value represents a structured value.
|
||||
// A zero value is valid and represents an empty value.
|
||||
type Value struct {
|
||||
// Ensure forward compatibility by explicitly making this not comparable.
|
||||
noCmp [0]func() //nolint: unused // This is indeed used.
|
||||
|
||||
// num holds the value for Int64, Float64, and Bool. It holds the length
|
||||
// for String, Bytes, Slice, Map.
|
||||
num uint64
|
||||
// any holds either the KindBool, KindInt64, KindFloat64, stringptr,
|
||||
// bytesptr, sliceptr, or mapptr. If KindBool, KindInt64, or KindFloat64
|
||||
// then the value of Value is in num as described above. Otherwise, it
|
||||
// contains the value wrapped in the appropriate type.
|
||||
any any
|
||||
}
|
||||
|
||||
type (
|
||||
// sliceptr represents a value in Value.any for KindString Values.
|
||||
stringptr *byte
|
||||
// bytesptr represents a value in Value.any for KindBytes Values.
|
||||
bytesptr *byte
|
||||
// sliceptr represents a value in Value.any for KindSlice Values.
|
||||
sliceptr *Value
|
||||
// mapptr represents a value in Value.any for KindMap Values.
|
||||
mapptr *Attr
|
||||
)
|
||||
|
||||
// ValueKind is the kind of a [Value].
|
||||
type ValueKind int
|
||||
|
||||
// ValueKind values.
|
||||
const (
|
||||
ValueKindEmpty ValueKind = iota
|
||||
ValueKindBool
|
||||
ValueKindFloat64
|
||||
ValueKindInt64
|
||||
ValueKindString
|
||||
ValueKindBytes
|
||||
ValueKindSlice
|
||||
ValueKindMap
|
||||
)
|
||||
|
||||
var valueKindStrings = []string{
|
||||
"Empty",
|
||||
"Bool",
|
||||
"Float64",
|
||||
"Int64",
|
||||
"String",
|
||||
"Bytes",
|
||||
"Slice",
|
||||
"Map",
|
||||
}
|
||||
|
||||
func (k ValueKind) String() string {
|
||||
if k >= 0 && int(k) < len(valueKindStrings) {
|
||||
return valueKindStrings[k]
|
||||
}
|
||||
return "<unknown telemetry.ValueKind>"
|
||||
}
|
||||
|
||||
// StringValue returns a new [Value] for a string.
|
||||
func StringValue(v string) Value {
|
||||
return Value{
|
||||
num: uint64(len(v)),
|
||||
any: stringptr(unsafe.StringData(v)),
|
||||
}
|
||||
}
|
||||
|
||||
// IntValue returns a [Value] for an int.
|
||||
func IntValue(v int) Value { return Int64Value(int64(v)) }
|
||||
|
||||
// Int64Value returns a [Value] for an int64.
|
||||
func Int64Value(v int64) Value {
|
||||
return Value{
|
||||
num: uint64(v), // nolint: gosec // Store raw bytes.
|
||||
any: ValueKindInt64,
|
||||
}
|
||||
}
|
||||
|
||||
// Float64Value returns a [Value] for a float64.
|
||||
func Float64Value(v float64) Value {
|
||||
return Value{num: math.Float64bits(v), any: ValueKindFloat64}
|
||||
}
|
||||
|
||||
// BoolValue returns a [Value] for a bool.
|
||||
func BoolValue(v bool) Value { //nolint:revive // Not a control flag.
|
||||
var n uint64
|
||||
if v {
|
||||
n = 1
|
||||
}
|
||||
return Value{num: n, any: ValueKindBool}
|
||||
}
|
||||
|
||||
// BytesValue returns a [Value] for a byte slice. The passed slice must not be
|
||||
// changed after it is passed.
|
||||
func BytesValue(v []byte) Value {
|
||||
return Value{
|
||||
num: uint64(len(v)),
|
||||
any: bytesptr(unsafe.SliceData(v)),
|
||||
}
|
||||
}
|
||||
|
||||
// SliceValue returns a [Value] for a slice of [Value]. The passed slice must
|
||||
// not be changed after it is passed.
|
||||
func SliceValue(vs ...Value) Value {
|
||||
return Value{
|
||||
num: uint64(len(vs)),
|
||||
any: sliceptr(unsafe.SliceData(vs)),
|
||||
}
|
||||
}
|
||||
|
||||
// MapValue returns a new [Value] for a slice of key-value pairs. The passed
|
||||
// slice must not be changed after it is passed.
|
||||
func MapValue(kvs ...Attr) Value {
|
||||
return Value{
|
||||
num: uint64(len(kvs)),
|
||||
any: mapptr(unsafe.SliceData(kvs)),
|
||||
}
|
||||
}
|
||||
|
||||
// AsString returns the value held by v as a string.
|
||||
func (v Value) AsString() string {
|
||||
if sp, ok := v.any.(stringptr); ok {
|
||||
return unsafe.String(sp, v.num)
|
||||
}
|
||||
// TODO: error handle
|
||||
return ""
|
||||
}
|
||||
|
||||
// asString returns the value held by v as a string. It will panic if the Value
|
||||
// is not KindString.
|
||||
func (v Value) asString() string {
|
||||
return unsafe.String(v.any.(stringptr), v.num)
|
||||
}
|
||||
|
||||
// AsInt64 returns the value held by v as an int64.
|
||||
func (v Value) AsInt64() int64 {
|
||||
if v.Kind() != ValueKindInt64 {
|
||||
// TODO: error handle
|
||||
return 0
|
||||
}
|
||||
return v.asInt64()
|
||||
}
|
||||
|
||||
// asInt64 returns the value held by v as an int64. If v is not of KindInt64,
|
||||
// this will return garbage.
|
||||
func (v Value) asInt64() int64 {
|
||||
// Assumes v.num was a valid int64 (overflow not checked).
|
||||
return int64(v.num) // nolint: gosec
|
||||
}
|
||||
|
||||
// AsBool returns the value held by v as a bool.
|
||||
func (v Value) AsBool() bool {
|
||||
if v.Kind() != ValueKindBool {
|
||||
// TODO: error handle
|
||||
return false
|
||||
}
|
||||
return v.asBool()
|
||||
}
|
||||
|
||||
// asBool returns the value held by v as a bool. If v is not of KindBool, this
|
||||
// will return garbage.
|
||||
func (v Value) asBool() bool { return v.num == 1 }
|
||||
|
||||
// AsFloat64 returns the value held by v as a float64.
|
||||
func (v Value) AsFloat64() float64 {
|
||||
if v.Kind() != ValueKindFloat64 {
|
||||
// TODO: error handle
|
||||
return 0
|
||||
}
|
||||
return v.asFloat64()
|
||||
}
|
||||
|
||||
// asFloat64 returns the value held by v as a float64. If v is not of
|
||||
// KindFloat64, this will return garbage.
|
||||
func (v Value) asFloat64() float64 { return math.Float64frombits(v.num) }
|
||||
|
||||
// AsBytes returns the value held by v as a []byte.
|
||||
func (v Value) AsBytes() []byte {
|
||||
if sp, ok := v.any.(bytesptr); ok {
|
||||
return unsafe.Slice((*byte)(sp), v.num)
|
||||
}
|
||||
// TODO: error handle
|
||||
return nil
|
||||
}
|
||||
|
||||
// asBytes returns the value held by v as a []byte. It will panic if the Value
|
||||
// is not KindBytes.
|
||||
func (v Value) asBytes() []byte {
|
||||
return unsafe.Slice((*byte)(v.any.(bytesptr)), v.num)
|
||||
}
|
||||
|
||||
// AsSlice returns the value held by v as a []Value.
|
||||
func (v Value) AsSlice() []Value {
|
||||
if sp, ok := v.any.(sliceptr); ok {
|
||||
return unsafe.Slice((*Value)(sp), v.num)
|
||||
}
|
||||
// TODO: error handle
|
||||
return nil
|
||||
}
|
||||
|
||||
// asSlice returns the value held by v as a []Value. It will panic if the Value
|
||||
// is not KindSlice.
|
||||
func (v Value) asSlice() []Value {
|
||||
return unsafe.Slice((*Value)(v.any.(sliceptr)), v.num)
|
||||
}
|
||||
|
||||
// AsMap returns the value held by v as a []Attr.
|
||||
func (v Value) AsMap() []Attr {
|
||||
if sp, ok := v.any.(mapptr); ok {
|
||||
return unsafe.Slice((*Attr)(sp), v.num)
|
||||
}
|
||||
// TODO: error handle
|
||||
return nil
|
||||
}
|
||||
|
||||
// asMap returns the value held by v as a []Attr. It will panic if the
|
||||
// Value is not KindMap.
|
||||
func (v Value) asMap() []Attr {
|
||||
return unsafe.Slice((*Attr)(v.any.(mapptr)), v.num)
|
||||
}
|
||||
|
||||
// Kind returns the Kind of v.
|
||||
func (v Value) Kind() ValueKind {
|
||||
switch x := v.any.(type) {
|
||||
case ValueKind:
|
||||
return x
|
||||
case stringptr:
|
||||
return ValueKindString
|
||||
case bytesptr:
|
||||
return ValueKindBytes
|
||||
case sliceptr:
|
||||
return ValueKindSlice
|
||||
case mapptr:
|
||||
return ValueKindMap
|
||||
default:
|
||||
return ValueKindEmpty
|
||||
}
|
||||
}
|
||||
|
||||
// Empty returns if v does not hold any value.
|
||||
func (v Value) Empty() bool { return v.Kind() == ValueKindEmpty }
|
||||
|
||||
// Equal returns if v is equal to w.
|
||||
func (v Value) Equal(w Value) bool {
|
||||
k1 := v.Kind()
|
||||
k2 := w.Kind()
|
||||
if k1 != k2 {
|
||||
return false
|
||||
}
|
||||
switch k1 {
|
||||
case ValueKindInt64, ValueKindBool:
|
||||
return v.num == w.num
|
||||
case ValueKindString:
|
||||
return v.asString() == w.asString()
|
||||
case ValueKindFloat64:
|
||||
return v.asFloat64() == w.asFloat64()
|
||||
case ValueKindSlice:
|
||||
return slices.EqualFunc(v.asSlice(), w.asSlice(), Value.Equal)
|
||||
case ValueKindMap:
|
||||
sv := sortMap(v.asMap())
|
||||
sw := sortMap(w.asMap())
|
||||
return slices.EqualFunc(sv, sw, Attr.Equal)
|
||||
case ValueKindBytes:
|
||||
return bytes.Equal(v.asBytes(), w.asBytes())
|
||||
case ValueKindEmpty:
|
||||
return true
|
||||
default:
|
||||
// TODO: error handle
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func sortMap(m []Attr) []Attr {
|
||||
sm := make([]Attr, len(m))
|
||||
copy(sm, m)
|
||||
slices.SortFunc(sm, func(a, b Attr) int {
|
||||
return cmp.Compare(a.Key, b.Key)
|
||||
})
|
||||
|
||||
return sm
|
||||
}
|
||||
|
||||
// String returns Value's value as a string, formatted like [fmt.Sprint].
|
||||
//
|
||||
// The returned string is meant for debugging;
|
||||
// the string representation is not stable.
|
||||
func (v Value) String() string {
|
||||
switch v.Kind() {
|
||||
case ValueKindString:
|
||||
return v.asString()
|
||||
case ValueKindInt64:
|
||||
// Assumes v.num was a valid int64 (overflow not checked).
|
||||
return strconv.FormatInt(int64(v.num), 10) // nolint: gosec
|
||||
case ValueKindFloat64:
|
||||
return strconv.FormatFloat(v.asFloat64(), 'g', -1, 64)
|
||||
case ValueKindBool:
|
||||
return strconv.FormatBool(v.asBool())
|
||||
case ValueKindBytes:
|
||||
return fmt.Sprint(v.asBytes())
|
||||
case ValueKindMap:
|
||||
return fmt.Sprint(v.asMap())
|
||||
case ValueKindSlice:
|
||||
return fmt.Sprint(v.asSlice())
|
||||
case ValueKindEmpty:
|
||||
return "<nil>"
|
||||
default:
|
||||
// Try to handle this as gracefully as possible.
|
||||
//
|
||||
// Don't panic here. The goal here is to have developers find this
|
||||
// first if a slog.Kind is is not handled. It is
|
||||
// preferable to have user's open issue asking why their attributes
|
||||
// have a "unhandled: " prefix than say that their code is panicking.
|
||||
return fmt.Sprintf("<unhandled telemetry.ValueKind: %s>", v.Kind())
|
||||
}
|
||||
}
|
||||
|
||||
// MarshalJSON encodes v into OTLP formatted JSON.
|
||||
func (v *Value) MarshalJSON() ([]byte, error) {
|
||||
switch v.Kind() {
|
||||
case ValueKindString:
|
||||
return json.Marshal(struct {
|
||||
Value string `json:"stringValue"`
|
||||
}{v.asString()})
|
||||
case ValueKindInt64:
|
||||
return json.Marshal(struct {
|
||||
Value string `json:"intValue"`
|
||||
}{strconv.FormatInt(int64(v.num), 10)}) // nolint: gosec // From raw bytes.
|
||||
case ValueKindFloat64:
|
||||
return json.Marshal(struct {
|
||||
Value float64 `json:"doubleValue"`
|
||||
}{v.asFloat64()})
|
||||
case ValueKindBool:
|
||||
return json.Marshal(struct {
|
||||
Value bool `json:"boolValue"`
|
||||
}{v.asBool()})
|
||||
case ValueKindBytes:
|
||||
return json.Marshal(struct {
|
||||
Value []byte `json:"bytesValue"`
|
||||
}{v.asBytes()})
|
||||
case ValueKindMap:
|
||||
return json.Marshal(struct {
|
||||
Value struct {
|
||||
Values []Attr `json:"values"`
|
||||
} `json:"kvlistValue"`
|
||||
}{struct {
|
||||
Values []Attr `json:"values"`
|
||||
}{v.asMap()}})
|
||||
case ValueKindSlice:
|
||||
return json.Marshal(struct {
|
||||
Value struct {
|
||||
Values []Value `json:"values"`
|
||||
} `json:"arrayValue"`
|
||||
}{struct {
|
||||
Values []Value `json:"values"`
|
||||
}{v.asSlice()}})
|
||||
case ValueKindEmpty:
|
||||
return nil, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown Value kind: %s", v.Kind().String())
|
||||
}
|
||||
}
|
||||
|
||||
// UnmarshalJSON decodes the OTLP formatted JSON contained in data into v.
|
||||
func (v *Value) UnmarshalJSON(data []byte) error {
|
||||
decoder := json.NewDecoder(bytes.NewReader(data))
|
||||
|
||||
t, err := decoder.Token()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if t != json.Delim('{') {
|
||||
return errors.New("invalid Value type")
|
||||
}
|
||||
|
||||
for decoder.More() {
|
||||
keyIface, err := decoder.Token()
|
||||
if err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
// Empty.
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
key, ok := keyIface.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid Value key: %#v", keyIface)
|
||||
}
|
||||
|
||||
switch key {
|
||||
case "stringValue", "string_value":
|
||||
var val string
|
||||
err = decoder.Decode(&val)
|
||||
*v = StringValue(val)
|
||||
case "boolValue", "bool_value":
|
||||
var val bool
|
||||
err = decoder.Decode(&val)
|
||||
*v = BoolValue(val)
|
||||
case "intValue", "int_value":
|
||||
var val protoInt64
|
||||
err = decoder.Decode(&val)
|
||||
*v = Int64Value(val.Int64())
|
||||
case "doubleValue", "double_value":
|
||||
var val float64
|
||||
err = decoder.Decode(&val)
|
||||
*v = Float64Value(val)
|
||||
case "bytesValue", "bytes_value":
|
||||
var val64 string
|
||||
if err := decoder.Decode(&val64); err != nil {
|
||||
return err
|
||||
}
|
||||
var val []byte
|
||||
val, err = base64.StdEncoding.DecodeString(val64)
|
||||
*v = BytesValue(val)
|
||||
case "arrayValue", "array_value":
|
||||
var val struct{ Values []Value }
|
||||
err = decoder.Decode(&val)
|
||||
*v = SliceValue(val.Values...)
|
||||
case "kvlistValue", "kvlist_value":
|
||||
var val struct{ Values []Attr }
|
||||
err = decoder.Decode(&val)
|
||||
*v = MapValue(val.Values...)
|
||||
default:
|
||||
// Skip unknown.
|
||||
continue
|
||||
}
|
||||
// Use first valid. Ignore the rest.
|
||||
return err
|
||||
}
|
||||
|
||||
// Only unknown fields. Return nil without unmarshaling any value.
|
||||
return nil
|
||||
}
|
|
@ -82,4 +82,22 @@ func (noopSpan) AddLink(Link) {}
|
|||
func (noopSpan) SetName(string) {}
|
||||
|
||||
// TracerProvider returns a no-op TracerProvider.
|
||||
func (noopSpan) TracerProvider() TracerProvider { return noopTracerProvider{} }
|
||||
func (s noopSpan) TracerProvider() TracerProvider {
|
||||
return s.tracerProvider(autoInstEnabled)
|
||||
}
|
||||
|
||||
// autoInstEnabled defines if the auto-instrumentation SDK is enabled.
|
||||
//
|
||||
// The auto-instrumentation is expected to overwrite this value to true when it
|
||||
// attaches to the process.
|
||||
var autoInstEnabled = new(bool)
|
||||
|
||||
// tracerProvider return a noopTracerProvider if autoEnabled is false,
|
||||
// otherwise it will return a TracerProvider from the sdk package used in
|
||||
// auto-instrumentation.
|
||||
func (noopSpan) tracerProvider(autoEnabled *bool) TracerProvider {
|
||||
if *autoEnabled {
|
||||
return newAutoTracerProvider()
|
||||
}
|
||||
return noopTracerProvider{}
|
||||
}
|
||||
|
|
|
@ -5,5 +5,5 @@ package otel // import "go.opentelemetry.io/otel"
|
|||
|
||||
// Version is the current release version of OpenTelemetry in use.
|
||||
func Version() string {
|
||||
return "1.34.0"
|
||||
return "1.35.0"
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
module-sets:
|
||||
stable-v1:
|
||||
version: v1.34.0
|
||||
version: v1.35.0
|
||||
modules:
|
||||
- go.opentelemetry.io/otel
|
||||
- go.opentelemetry.io/otel/bridge/opencensus
|
||||
|
@ -23,11 +23,11 @@ module-sets:
|
|||
- go.opentelemetry.io/otel/sdk/metric
|
||||
- go.opentelemetry.io/otel/trace
|
||||
experimental-metrics:
|
||||
version: v0.56.0
|
||||
version: v0.57.0
|
||||
modules:
|
||||
- go.opentelemetry.io/otel/exporters/prometheus
|
||||
experimental-logs:
|
||||
version: v0.10.0
|
||||
version: v0.11.0
|
||||
modules:
|
||||
- go.opentelemetry.io/otel/log
|
||||
- go.opentelemetry.io/otel/sdk/log
|
||||
|
@ -40,3 +40,4 @@ module-sets:
|
|||
- go.opentelemetry.io/otel/schema
|
||||
excluded-modules:
|
||||
- go.opentelemetry.io/otel/internal/tools
|
||||
- go.opentelemetry.io/otel/trace/internal/telemetry/test
|
||||
|
|
|
@ -129,6 +129,13 @@ type State struct {
|
|||
// brand new implementation of this interface. For the situations like
|
||||
// testing, the new implementation should embed this interface. This allows
|
||||
// gRPC to add new methods to this interface.
|
||||
//
|
||||
// NOTICE: This interface is intended to be implemented by gRPC, or intercepted
|
||||
// by custom load balancing polices. Users should not need their own complete
|
||||
// implementation of this interface -- they should always delegate to a
|
||||
// ClientConn passed to Builder.Build() by embedding it in their
|
||||
// implementations. An embedded ClientConn must never be nil, or runtime panics
|
||||
// will occur.
|
||||
type ClientConn interface {
|
||||
// NewSubConn is called by balancer to create a new SubConn.
|
||||
// It doesn't block and wait for the connections to be established.
|
||||
|
@ -167,6 +174,17 @@ type ClientConn interface {
|
|||
//
|
||||
// Deprecated: Use the Target field in the BuildOptions instead.
|
||||
Target() string
|
||||
|
||||
// MetricsRecorder provides the metrics recorder that balancers can use to
|
||||
// record metrics. Balancer implementations which do not register metrics on
|
||||
// metrics registry and record on them can ignore this method. The returned
|
||||
// MetricsRecorder is guaranteed to never be nil.
|
||||
MetricsRecorder() estats.MetricsRecorder
|
||||
|
||||
// EnforceClientConnEmbedding is included to force implementers to embed
|
||||
// another implementation of this interface, allowing gRPC to add methods
|
||||
// without breaking users.
|
||||
internal.EnforceClientConnEmbedding
|
||||
}
|
||||
|
||||
// BuildOptions contains additional information for Build.
|
||||
|
@ -198,10 +216,6 @@ type BuildOptions struct {
|
|||
// same resolver.Target as passed to the resolver. See the documentation for
|
||||
// the resolver.Target type for details about what it contains.
|
||||
Target resolver.Target
|
||||
// MetricsRecorder is the metrics recorder that balancers can use to record
|
||||
// metrics. Balancer implementations which do not register metrics on
|
||||
// metrics registry and record on them can ignore this field.
|
||||
MetricsRecorder estats.MetricsRecorder
|
||||
}
|
||||
|
||||
// Builder creates a balancer.
|
||||
|
|
358
vendor/google.golang.org/grpc/balancer/endpointsharding/endpointsharding.go
generated
vendored
Normal file
358
vendor/google.golang.org/grpc/balancer/endpointsharding/endpointsharding.go
generated
vendored
Normal file
|
@ -0,0 +1,358 @@
|
|||
/*
|
||||
*
|
||||
* Copyright 2024 gRPC authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
// Package endpointsharding implements a load balancing policy that manages
|
||||
// homogeneous child policies each owning a single endpoint.
|
||||
//
|
||||
// # Experimental
|
||||
//
|
||||
// Notice: This package is EXPERIMENTAL and may be changed or removed in a
|
||||
// later release.
|
||||
package endpointsharding
|
||||
|
||||
import (
|
||||
"errors"
|
||||
rand "math/rand/v2"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"google.golang.org/grpc/balancer"
|
||||
"google.golang.org/grpc/balancer/base"
|
||||
"google.golang.org/grpc/connectivity"
|
||||
"google.golang.org/grpc/resolver"
|
||||
)
|
||||
|
||||
// ChildState is the balancer state of a child along with the endpoint which
|
||||
// identifies the child balancer.
|
||||
type ChildState struct {
|
||||
Endpoint resolver.Endpoint
|
||||
State balancer.State
|
||||
|
||||
// Balancer exposes only the ExitIdler interface of the child LB policy.
|
||||
// Other methods of the child policy are called only by endpointsharding.
|
||||
Balancer balancer.ExitIdler
|
||||
}
|
||||
|
||||
// Options are the options to configure the behaviour of the
|
||||
// endpointsharding balancer.
|
||||
type Options struct {
|
||||
// DisableAutoReconnect allows the balancer to keep child balancer in the
|
||||
// IDLE state until they are explicitly triggered to exit using the
|
||||
// ChildState obtained from the endpointsharding picker. When set to false,
|
||||
// the endpointsharding balancer will automatically call ExitIdle on child
|
||||
// connections that report IDLE.
|
||||
DisableAutoReconnect bool
|
||||
}
|
||||
|
||||
// ChildBuilderFunc creates a new balancer with the ClientConn. It has the same
|
||||
// type as the balancer.Builder.Build method.
|
||||
type ChildBuilderFunc func(cc balancer.ClientConn, opts balancer.BuildOptions) balancer.Balancer
|
||||
|
||||
// NewBalancer returns a load balancing policy that manages homogeneous child
|
||||
// policies each owning a single endpoint. The endpointsharding balancer
|
||||
// forwards the LoadBalancingConfig in ClientConn state updates to its children.
|
||||
func NewBalancer(cc balancer.ClientConn, opts balancer.BuildOptions, childBuilder ChildBuilderFunc, esOpts Options) balancer.Balancer {
|
||||
es := &endpointSharding{
|
||||
cc: cc,
|
||||
bOpts: opts,
|
||||
esOpts: esOpts,
|
||||
childBuilder: childBuilder,
|
||||
}
|
||||
es.children.Store(resolver.NewEndpointMap())
|
||||
return es
|
||||
}
|
||||
|
||||
// endpointSharding is a balancer that wraps child balancers. It creates a child
|
||||
// balancer with child config for every unique Endpoint received. It updates the
|
||||
// child states on any update from parent or child.
|
||||
type endpointSharding struct {
|
||||
cc balancer.ClientConn
|
||||
bOpts balancer.BuildOptions
|
||||
esOpts Options
|
||||
childBuilder ChildBuilderFunc
|
||||
|
||||
// childMu synchronizes calls to any single child. It must be held for all
|
||||
// calls into a child. To avoid deadlocks, do not acquire childMu while
|
||||
// holding mu.
|
||||
childMu sync.Mutex
|
||||
children atomic.Pointer[resolver.EndpointMap] // endpoint -> *balancerWrapper
|
||||
|
||||
// inhibitChildUpdates is set during UpdateClientConnState/ResolverError
|
||||
// calls (calls to children will each produce an update, only want one
|
||||
// update).
|
||||
inhibitChildUpdates atomic.Bool
|
||||
|
||||
// mu synchronizes access to the state stored in balancerWrappers in the
|
||||
// children field. mu must not be held during calls into a child since
|
||||
// synchronous calls back from the child may require taking mu, causing a
|
||||
// deadlock. To avoid deadlocks, do not acquire childMu while holding mu.
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
// UpdateClientConnState creates a child for new endpoints and deletes children
|
||||
// for endpoints that are no longer present. It also updates all the children,
|
||||
// and sends a single synchronous update of the childrens' aggregated state at
|
||||
// the end of the UpdateClientConnState operation. If any endpoint has no
|
||||
// addresses it will ignore that endpoint. Otherwise, returns first error found
|
||||
// from a child, but fully processes the new update.
|
||||
func (es *endpointSharding) UpdateClientConnState(state balancer.ClientConnState) error {
|
||||
es.childMu.Lock()
|
||||
defer es.childMu.Unlock()
|
||||
|
||||
es.inhibitChildUpdates.Store(true)
|
||||
defer func() {
|
||||
es.inhibitChildUpdates.Store(false)
|
||||
es.updateState()
|
||||
}()
|
||||
var ret error
|
||||
|
||||
children := es.children.Load()
|
||||
newChildren := resolver.NewEndpointMap()
|
||||
|
||||
// Update/Create new children.
|
||||
for _, endpoint := range state.ResolverState.Endpoints {
|
||||
if _, ok := newChildren.Get(endpoint); ok {
|
||||
// Endpoint child was already created, continue to avoid duplicate
|
||||
// update.
|
||||
continue
|
||||
}
|
||||
var childBalancer *balancerWrapper
|
||||
if val, ok := children.Get(endpoint); ok {
|
||||
childBalancer = val.(*balancerWrapper)
|
||||
// Endpoint attributes may have changed, update the stored endpoint.
|
||||
es.mu.Lock()
|
||||
childBalancer.childState.Endpoint = endpoint
|
||||
es.mu.Unlock()
|
||||
} else {
|
||||
childBalancer = &balancerWrapper{
|
||||
childState: ChildState{Endpoint: endpoint},
|
||||
ClientConn: es.cc,
|
||||
es: es,
|
||||
}
|
||||
childBalancer.childState.Balancer = childBalancer
|
||||
childBalancer.child = es.childBuilder(childBalancer, es.bOpts)
|
||||
}
|
||||
newChildren.Set(endpoint, childBalancer)
|
||||
if err := childBalancer.updateClientConnStateLocked(balancer.ClientConnState{
|
||||
BalancerConfig: state.BalancerConfig,
|
||||
ResolverState: resolver.State{
|
||||
Endpoints: []resolver.Endpoint{endpoint},
|
||||
Attributes: state.ResolverState.Attributes,
|
||||
},
|
||||
}); err != nil && ret == nil {
|
||||
// Return first error found, and always commit full processing of
|
||||
// updating children. If desired to process more specific errors
|
||||
// across all endpoints, caller should make these specific
|
||||
// validations, this is a current limitation for simplicity sake.
|
||||
ret = err
|
||||
}
|
||||
}
|
||||
// Delete old children that are no longer present.
|
||||
for _, e := range children.Keys() {
|
||||
child, _ := children.Get(e)
|
||||
if _, ok := newChildren.Get(e); !ok {
|
||||
child.(*balancerWrapper).closeLocked()
|
||||
}
|
||||
}
|
||||
es.children.Store(newChildren)
|
||||
if newChildren.Len() == 0 {
|
||||
return balancer.ErrBadResolverState
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
// ResolverError forwards the resolver error to all of the endpointSharding's
|
||||
// children and sends a single synchronous update of the childStates at the end
|
||||
// of the ResolverError operation.
|
||||
func (es *endpointSharding) ResolverError(err error) {
|
||||
es.childMu.Lock()
|
||||
defer es.childMu.Unlock()
|
||||
es.inhibitChildUpdates.Store(true)
|
||||
defer func() {
|
||||
es.inhibitChildUpdates.Store(false)
|
||||
es.updateState()
|
||||
}()
|
||||
children := es.children.Load()
|
||||
for _, child := range children.Values() {
|
||||
child.(*balancerWrapper).resolverErrorLocked(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (es *endpointSharding) UpdateSubConnState(balancer.SubConn, balancer.SubConnState) {
|
||||
// UpdateSubConnState is deprecated.
|
||||
}
|
||||
|
||||
func (es *endpointSharding) Close() {
|
||||
es.childMu.Lock()
|
||||
defer es.childMu.Unlock()
|
||||
children := es.children.Load()
|
||||
for _, child := range children.Values() {
|
||||
child.(*balancerWrapper).closeLocked()
|
||||
}
|
||||
}
|
||||
|
||||
// updateState updates this component's state. It sends the aggregated state,
|
||||
// and a picker with round robin behavior with all the child states present if
|
||||
// needed.
|
||||
func (es *endpointSharding) updateState() {
|
||||
if es.inhibitChildUpdates.Load() {
|
||||
return
|
||||
}
|
||||
var readyPickers, connectingPickers, idlePickers, transientFailurePickers []balancer.Picker
|
||||
|
||||
es.mu.Lock()
|
||||
defer es.mu.Unlock()
|
||||
|
||||
children := es.children.Load()
|
||||
childStates := make([]ChildState, 0, children.Len())
|
||||
|
||||
for _, child := range children.Values() {
|
||||
bw := child.(*balancerWrapper)
|
||||
childState := bw.childState
|
||||
childStates = append(childStates, childState)
|
||||
childPicker := childState.State.Picker
|
||||
switch childState.State.ConnectivityState {
|
||||
case connectivity.Ready:
|
||||
readyPickers = append(readyPickers, childPicker)
|
||||
case connectivity.Connecting:
|
||||
connectingPickers = append(connectingPickers, childPicker)
|
||||
case connectivity.Idle:
|
||||
idlePickers = append(idlePickers, childPicker)
|
||||
case connectivity.TransientFailure:
|
||||
transientFailurePickers = append(transientFailurePickers, childPicker)
|
||||
// connectivity.Shutdown shouldn't appear.
|
||||
}
|
||||
}
|
||||
|
||||
// Construct the round robin picker based off the aggregated state. Whatever
|
||||
// the aggregated state, use the pickers present that are currently in that
|
||||
// state only.
|
||||
var aggState connectivity.State
|
||||
var pickers []balancer.Picker
|
||||
if len(readyPickers) >= 1 {
|
||||
aggState = connectivity.Ready
|
||||
pickers = readyPickers
|
||||
} else if len(connectingPickers) >= 1 {
|
||||
aggState = connectivity.Connecting
|
||||
pickers = connectingPickers
|
||||
} else if len(idlePickers) >= 1 {
|
||||
aggState = connectivity.Idle
|
||||
pickers = idlePickers
|
||||
} else if len(transientFailurePickers) >= 1 {
|
||||
aggState = connectivity.TransientFailure
|
||||
pickers = transientFailurePickers
|
||||
} else {
|
||||
aggState = connectivity.TransientFailure
|
||||
pickers = []balancer.Picker{base.NewErrPicker(errors.New("no children to pick from"))}
|
||||
} // No children (resolver error before valid update).
|
||||
p := &pickerWithChildStates{
|
||||
pickers: pickers,
|
||||
childStates: childStates,
|
||||
next: uint32(rand.IntN(len(pickers))),
|
||||
}
|
||||
es.cc.UpdateState(balancer.State{
|
||||
ConnectivityState: aggState,
|
||||
Picker: p,
|
||||
})
|
||||
}
|
||||
|
||||
// pickerWithChildStates delegates to the pickers it holds in a round robin
|
||||
// fashion. It also contains the childStates of all the endpointSharding's
|
||||
// children.
|
||||
type pickerWithChildStates struct {
|
||||
pickers []balancer.Picker
|
||||
childStates []ChildState
|
||||
next uint32
|
||||
}
|
||||
|
||||
func (p *pickerWithChildStates) Pick(info balancer.PickInfo) (balancer.PickResult, error) {
|
||||
nextIndex := atomic.AddUint32(&p.next, 1)
|
||||
picker := p.pickers[nextIndex%uint32(len(p.pickers))]
|
||||
return picker.Pick(info)
|
||||
}
|
||||
|
||||
// ChildStatesFromPicker returns the state of all the children managed by the
|
||||
// endpoint sharding balancer that created this picker.
|
||||
func ChildStatesFromPicker(picker balancer.Picker) []ChildState {
|
||||
p, ok := picker.(*pickerWithChildStates)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return p.childStates
|
||||
}
|
||||
|
||||
// balancerWrapper is a wrapper of a balancer. It ID's a child balancer by
|
||||
// endpoint, and persists recent child balancer state.
|
||||
type balancerWrapper struct {
|
||||
// The following fields are initialized at build time and read-only after
|
||||
// that and therefore do not need to be guarded by a mutex.
|
||||
|
||||
// child contains the wrapped balancer. Access its methods only through
|
||||
// methods on balancerWrapper to ensure proper synchronization
|
||||
child balancer.Balancer
|
||||
balancer.ClientConn // embed to intercept UpdateState, doesn't deal with SubConns
|
||||
|
||||
es *endpointSharding
|
||||
|
||||
// Access to the following fields is guarded by es.mu.
|
||||
|
||||
childState ChildState
|
||||
isClosed bool
|
||||
}
|
||||
|
||||
func (bw *balancerWrapper) UpdateState(state balancer.State) {
|
||||
bw.es.mu.Lock()
|
||||
bw.childState.State = state
|
||||
bw.es.mu.Unlock()
|
||||
if state.ConnectivityState == connectivity.Idle && !bw.es.esOpts.DisableAutoReconnect {
|
||||
bw.ExitIdle()
|
||||
}
|
||||
bw.es.updateState()
|
||||
}
|
||||
|
||||
// ExitIdle pings an IDLE child balancer to exit idle in a new goroutine to
|
||||
// avoid deadlocks due to synchronous balancer state updates.
|
||||
func (bw *balancerWrapper) ExitIdle() {
|
||||
if ei, ok := bw.child.(balancer.ExitIdler); ok {
|
||||
go func() {
|
||||
bw.es.childMu.Lock()
|
||||
if !bw.isClosed {
|
||||
ei.ExitIdle()
|
||||
}
|
||||
bw.es.childMu.Unlock()
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
// updateClientConnStateLocked delivers the ClientConnState to the child
|
||||
// balancer. Callers must hold the child mutex of the parent endpointsharding
|
||||
// balancer.
|
||||
func (bw *balancerWrapper) updateClientConnStateLocked(ccs balancer.ClientConnState) error {
|
||||
return bw.child.UpdateClientConnState(ccs)
|
||||
}
|
||||
|
||||
// closeLocked closes the child balancer. Callers must hold the child mutext of
|
||||
// the parent endpointsharding balancer.
|
||||
func (bw *balancerWrapper) closeLocked() {
|
||||
bw.child.Close()
|
||||
bw.isClosed = true
|
||||
}
|
||||
|
||||
func (bw *balancerWrapper) resolverErrorLocked(err error) {
|
||||
bw.child.ResolverError(err)
|
||||
}
|
29
vendor/google.golang.org/grpc/balancer/pickfirst/pickfirstleaf/pickfirstleaf.go
generated
vendored
29
vendor/google.golang.org/grpc/balancer/pickfirst/pickfirstleaf/pickfirstleaf.go
generated
vendored
|
@ -54,9 +54,18 @@ func init() {
|
|||
balancer.Register(pickfirstBuilder{})
|
||||
}
|
||||
|
||||
// enableHealthListenerKeyType is a unique key type used in resolver attributes
|
||||
// to indicate whether the health listener usage is enabled.
|
||||
type enableHealthListenerKeyType struct{}
|
||||
type (
|
||||
// enableHealthListenerKeyType is a unique key type used in resolver
|
||||
// attributes to indicate whether the health listener usage is enabled.
|
||||
enableHealthListenerKeyType struct{}
|
||||
// managedByPickfirstKeyType is an attribute key type to inform Outlier
|
||||
// Detection that the generic health listener is being used.
|
||||
// TODO: https://github.com/grpc/grpc-go/issues/7915 - Remove this when
|
||||
// implementing the dualstack design. This is a hack. Once Dualstack is
|
||||
// completed, outlier detection will stop sending ejection updates through
|
||||
// the connectivity listener.
|
||||
managedByPickfirstKeyType struct{}
|
||||
)
|
||||
|
||||
var (
|
||||
logger = grpclog.Component("pick-first-leaf-lb")
|
||||
|
@ -111,7 +120,7 @@ func (pickfirstBuilder) Build(cc balancer.ClientConn, bo balancer.BuildOptions)
|
|||
b := &pickfirstBalancer{
|
||||
cc: cc,
|
||||
target: bo.Target.String(),
|
||||
metricsRecorder: bo.MetricsRecorder, // ClientConn will always create a Metrics Recorder.
|
||||
metricsRecorder: cc.MetricsRecorder(),
|
||||
|
||||
subConns: resolver.NewAddressMap(),
|
||||
state: connectivity.Connecting,
|
||||
|
@ -140,6 +149,17 @@ func EnableHealthListener(state resolver.State) resolver.State {
|
|||
return state
|
||||
}
|
||||
|
||||
// IsManagedByPickfirst returns whether an address belongs to a SubConn
|
||||
// managed by the pickfirst LB policy.
|
||||
// TODO: https://github.com/grpc/grpc-go/issues/7915 - This is a hack to disable
|
||||
// outlier_detection via the with connectivity listener when using pick_first.
|
||||
// Once Dualstack changes are complete, all SubConns will be created by
|
||||
// pick_first and outlier detection will only use the health listener for
|
||||
// ejection. This hack can then be removed.
|
||||
func IsManagedByPickfirst(addr resolver.Address) bool {
|
||||
return addr.BalancerAttributes.Value(managedByPickfirstKeyType{}) != nil
|
||||
}
|
||||
|
||||
type pfConfig struct {
|
||||
serviceconfig.LoadBalancingConfig `json:"-"`
|
||||
|
||||
|
@ -166,6 +186,7 @@ type scData struct {
|
|||
}
|
||||
|
||||
func (b *pickfirstBalancer) newSCData(addr resolver.Address) (*scData, error) {
|
||||
addr.BalancerAttributes = addr.BalancerAttributes.WithValue(managedByPickfirstKeyType{}, true)
|
||||
sd := &scData{
|
||||
rawConnectivityState: connectivity.Idle,
|
||||
effectiveState: connectivity.Idle,
|
||||
|
|
|
@ -22,12 +22,13 @@
|
|||
package roundrobin
|
||||
|
||||
import (
|
||||
rand "math/rand/v2"
|
||||
"sync/atomic"
|
||||
"fmt"
|
||||
|
||||
"google.golang.org/grpc/balancer"
|
||||
"google.golang.org/grpc/balancer/base"
|
||||
"google.golang.org/grpc/balancer/endpointsharding"
|
||||
"google.golang.org/grpc/balancer/pickfirst/pickfirstleaf"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
internalgrpclog "google.golang.org/grpc/internal/grpclog"
|
||||
)
|
||||
|
||||
// Name is the name of round_robin balancer.
|
||||
|
@ -35,47 +36,44 @@ const Name = "round_robin"
|
|||
|
||||
var logger = grpclog.Component("roundrobin")
|
||||
|
||||
// newBuilder creates a new roundrobin balancer builder.
|
||||
func newBuilder() balancer.Builder {
|
||||
return base.NewBalancerBuilder(Name, &rrPickerBuilder{}, base.Config{HealthCheck: true})
|
||||
}
|
||||
|
||||
func init() {
|
||||
balancer.Register(newBuilder())
|
||||
balancer.Register(builder{})
|
||||
}
|
||||
|
||||
type rrPickerBuilder struct{}
|
||||
type builder struct{}
|
||||
|
||||
func (*rrPickerBuilder) Build(info base.PickerBuildInfo) balancer.Picker {
|
||||
logger.Infof("roundrobinPicker: Build called with info: %v", info)
|
||||
if len(info.ReadySCs) == 0 {
|
||||
return base.NewErrPicker(balancer.ErrNoSubConnAvailable)
|
||||
func (bb builder) Name() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (bb builder) Build(cc balancer.ClientConn, opts balancer.BuildOptions) balancer.Balancer {
|
||||
childBuilder := balancer.Get(pickfirstleaf.Name).Build
|
||||
bal := &rrBalancer{
|
||||
cc: cc,
|
||||
Balancer: endpointsharding.NewBalancer(cc, opts, childBuilder, endpointsharding.Options{}),
|
||||
}
|
||||
scs := make([]balancer.SubConn, 0, len(info.ReadySCs))
|
||||
for sc := range info.ReadySCs {
|
||||
scs = append(scs, sc)
|
||||
}
|
||||
return &rrPicker{
|
||||
subConns: scs,
|
||||
// Start at a random index, as the same RR balancer rebuilds a new
|
||||
// picker when SubConn states change, and we don't want to apply excess
|
||||
// load to the first server in the list.
|
||||
next: uint32(rand.IntN(len(scs))),
|
||||
bal.logger = internalgrpclog.NewPrefixLogger(logger, fmt.Sprintf("[%p] ", bal))
|
||||
bal.logger.Infof("Created")
|
||||
return bal
|
||||
}
|
||||
|
||||
type rrBalancer struct {
|
||||
balancer.Balancer
|
||||
cc balancer.ClientConn
|
||||
logger *internalgrpclog.PrefixLogger
|
||||
}
|
||||
|
||||
func (b *rrBalancer) UpdateClientConnState(ccs balancer.ClientConnState) error {
|
||||
return b.Balancer.UpdateClientConnState(balancer.ClientConnState{
|
||||
// Enable the health listener in pickfirst children for client side health
|
||||
// checks and outlier detection, if configured.
|
||||
ResolverState: pickfirstleaf.EnableHealthListener(ccs.ResolverState),
|
||||
})
|
||||
}
|
||||
|
||||
func (b *rrBalancer) ExitIdle() {
|
||||
// Should always be ok, as child is endpoint sharding.
|
||||
if ei, ok := b.Balancer.(balancer.ExitIdler); ok {
|
||||
ei.ExitIdle()
|
||||
}
|
||||
}
|
||||
|
||||
type rrPicker struct {
|
||||
// subConns is the snapshot of the roundrobin balancer when this picker was
|
||||
// created. The slice is immutable. Each Get() will do a round robin
|
||||
// selection from it and return the selected SubConn.
|
||||
subConns []balancer.SubConn
|
||||
next uint32
|
||||
}
|
||||
|
||||
func (p *rrPicker) Pick(balancer.PickInfo) (balancer.PickResult, error) {
|
||||
subConnsLen := uint32(len(p.subConns))
|
||||
nextIndex := atomic.AddUint32(&p.next, 1)
|
||||
|
||||
sc := p.subConns[nextIndex%subConnsLen]
|
||||
return balancer.PickResult{SubConn: sc}, nil
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ import (
|
|||
// should only use a single address.
|
||||
//
|
||||
// NOTICE: This interface is intended to be implemented by gRPC, or intercepted
|
||||
// by custom load balancing poilices. Users should not need their own complete
|
||||
// by custom load balancing polices. Users should not need their own complete
|
||||
// implementation of this interface -- they should always delegate to a SubConn
|
||||
// returned by ClientConn.NewSubConn() by embedding it in their implementations.
|
||||
// An embedded SubConn must never be nil, or runtime panics will occur.
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
"google.golang.org/grpc/balancer"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/connectivity"
|
||||
"google.golang.org/grpc/experimental/stats"
|
||||
"google.golang.org/grpc/internal"
|
||||
"google.golang.org/grpc/internal/balancer/gracefulswitch"
|
||||
"google.golang.org/grpc/internal/channelz"
|
||||
|
@ -34,7 +35,15 @@ import (
|
|||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
var setConnectedAddress = internal.SetConnectedAddress.(func(*balancer.SubConnState, resolver.Address))
|
||||
var (
|
||||
setConnectedAddress = internal.SetConnectedAddress.(func(*balancer.SubConnState, resolver.Address))
|
||||
// noOpRegisterHealthListenerFn is used when client side health checking is
|
||||
// disabled. It sends a single READY update on the registered listener.
|
||||
noOpRegisterHealthListenerFn = func(_ context.Context, listener func(balancer.SubConnState)) func() {
|
||||
listener(balancer.SubConnState{ConnectivityState: connectivity.Ready})
|
||||
return func() {}
|
||||
}
|
||||
)
|
||||
|
||||
// ccBalancerWrapper sits between the ClientConn and the Balancer.
|
||||
//
|
||||
|
@ -51,6 +60,7 @@ var setConnectedAddress = internal.SetConnectedAddress.(func(*balancer.SubConnSt
|
|||
// It uses the gracefulswitch.Balancer internally to ensure that balancer
|
||||
// switches happen in a graceful manner.
|
||||
type ccBalancerWrapper struct {
|
||||
internal.EnforceClientConnEmbedding
|
||||
// The following fields are initialized when the wrapper is created and are
|
||||
// read-only afterwards, and therefore can be accessed without a mutex.
|
||||
cc *ClientConn
|
||||
|
@ -84,7 +94,6 @@ func newCCBalancerWrapper(cc *ClientConn) *ccBalancerWrapper {
|
|||
CustomUserAgent: cc.dopts.copts.UserAgent,
|
||||
ChannelzParent: cc.channelz,
|
||||
Target: cc.parsedTarget,
|
||||
MetricsRecorder: cc.metricsRecorderList,
|
||||
},
|
||||
serializer: grpcsync.NewCallbackSerializer(ctx),
|
||||
serializerCancel: cancel,
|
||||
|
@ -93,6 +102,10 @@ func newCCBalancerWrapper(cc *ClientConn) *ccBalancerWrapper {
|
|||
return ccb
|
||||
}
|
||||
|
||||
func (ccb *ccBalancerWrapper) MetricsRecorder() stats.MetricsRecorder {
|
||||
return ccb.cc.metricsRecorderList
|
||||
}
|
||||
|
||||
// updateClientConnState is invoked by grpc to push a ClientConnState update to
|
||||
// the underlying balancer. This is always executed from the serializer, so
|
||||
// it is safe to call into the balancer here.
|
||||
|
@ -277,10 +290,17 @@ type healthData struct {
|
|||
// to the LB policy. This is stored to avoid sending updates when the
|
||||
// SubConn has already exited connectivity state READY.
|
||||
connectivityState connectivity.State
|
||||
// closeHealthProducer stores function to close the ref counted health
|
||||
// producer. The health producer is automatically closed when the SubConn
|
||||
// state changes.
|
||||
closeHealthProducer func()
|
||||
}
|
||||
|
||||
func newHealthData(s connectivity.State) *healthData {
|
||||
return &healthData{connectivityState: s}
|
||||
return &healthData{
|
||||
connectivityState: s,
|
||||
closeHealthProducer: func() {},
|
||||
}
|
||||
}
|
||||
|
||||
// updateState is invoked by grpc to push a subConn state update to the
|
||||
|
@ -400,7 +420,7 @@ func (acbw *acBalancerWrapper) GetOrBuildProducer(pb balancer.ProducerBuilder) (
|
|||
}
|
||||
acbw.producersMu.Unlock()
|
||||
}
|
||||
return pData.producer, grpcsync.OnceFunc(unref)
|
||||
return pData.producer, sync.OnceFunc(unref)
|
||||
}
|
||||
|
||||
func (acbw *acBalancerWrapper) closeProducers() {
|
||||
|
@ -413,6 +433,37 @@ func (acbw *acBalancerWrapper) closeProducers() {
|
|||
}
|
||||
}
|
||||
|
||||
// healthProducerRegisterFn is a type alias for the health producer's function
|
||||
// for registering listeners.
|
||||
type healthProducerRegisterFn = func(context.Context, balancer.SubConn, string, func(balancer.SubConnState)) func()
|
||||
|
||||
// healthListenerRegFn returns a function to register a listener for health
|
||||
// updates. If client side health checks are disabled, the registered listener
|
||||
// will get a single READY (raw connectivity state) update.
|
||||
//
|
||||
// Client side health checking is enabled when all the following
|
||||
// conditions are satisfied:
|
||||
// 1. Health checking is not disabled using the dial option.
|
||||
// 2. The health package is imported.
|
||||
// 3. The health check config is present in the service config.
|
||||
func (acbw *acBalancerWrapper) healthListenerRegFn() func(context.Context, func(balancer.SubConnState)) func() {
|
||||
if acbw.ccb.cc.dopts.disableHealthCheck {
|
||||
return noOpRegisterHealthListenerFn
|
||||
}
|
||||
regHealthLisFn := internal.RegisterClientHealthCheckListener
|
||||
if regHealthLisFn == nil {
|
||||
// The health package is not imported.
|
||||
return noOpRegisterHealthListenerFn
|
||||
}
|
||||
cfg := acbw.ac.cc.healthCheckConfig()
|
||||
if cfg == nil {
|
||||
return noOpRegisterHealthListenerFn
|
||||
}
|
||||
return func(ctx context.Context, listener func(balancer.SubConnState)) func() {
|
||||
return regHealthLisFn.(healthProducerRegisterFn)(ctx, acbw, cfg.ServiceName, listener)
|
||||
}
|
||||
}
|
||||
|
||||
// RegisterHealthListener accepts a health listener from the LB policy. It sends
|
||||
// updates to the health listener as long as the SubConn's connectivity state
|
||||
// doesn't change and a new health listener is not registered. To invalidate
|
||||
|
@ -421,6 +472,7 @@ func (acbw *acBalancerWrapper) closeProducers() {
|
|||
func (acbw *acBalancerWrapper) RegisterHealthListener(listener func(balancer.SubConnState)) {
|
||||
acbw.healthMu.Lock()
|
||||
defer acbw.healthMu.Unlock()
|
||||
acbw.healthData.closeHealthProducer()
|
||||
// listeners should not be registered when the connectivity state
|
||||
// isn't Ready. This may happen when the balancer registers a listener
|
||||
// after the connectivityState is updated, but before it is notified
|
||||
|
@ -436,6 +488,7 @@ func (acbw *acBalancerWrapper) RegisterHealthListener(listener func(balancer.Sub
|
|||
return
|
||||
}
|
||||
|
||||
registerFn := acbw.healthListenerRegFn()
|
||||
acbw.ccb.serializer.TrySchedule(func(ctx context.Context) {
|
||||
if ctx.Err() != nil || acbw.ccb.balancer == nil {
|
||||
return
|
||||
|
@ -443,10 +496,25 @@ func (acbw *acBalancerWrapper) RegisterHealthListener(listener func(balancer.Sub
|
|||
// Don't send updates if a new listener is registered.
|
||||
acbw.healthMu.Lock()
|
||||
defer acbw.healthMu.Unlock()
|
||||
curHD := acbw.healthData
|
||||
if curHD != hd {
|
||||
if acbw.healthData != hd {
|
||||
return
|
||||
}
|
||||
listener(balancer.SubConnState{ConnectivityState: connectivity.Ready})
|
||||
// Serialize the health updates from the health producer with
|
||||
// other calls into the LB policy.
|
||||
listenerWrapper := func(scs balancer.SubConnState) {
|
||||
acbw.ccb.serializer.TrySchedule(func(ctx context.Context) {
|
||||
if ctx.Err() != nil || acbw.ccb.balancer == nil {
|
||||
return
|
||||
}
|
||||
acbw.healthMu.Lock()
|
||||
defer acbw.healthMu.Unlock()
|
||||
if acbw.healthData != hd {
|
||||
return
|
||||
}
|
||||
listener(scs)
|
||||
})
|
||||
}
|
||||
|
||||
hd.closeHealthProducer = registerFn(ctx, listenerWrapper)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.35.1
|
||||
// protoc-gen-go v1.36.4
|
||||
// protoc v5.27.1
|
||||
// source: grpc/binlog/v1/binarylog.proto
|
||||
|
||||
|
@ -31,6 +31,7 @@ import (
|
|||
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -233,10 +234,7 @@ func (Address_Type) EnumDescriptor() ([]byte, []int) {
|
|||
|
||||
// Log entry we store in binary logs
|
||||
type GrpcLogEntry struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// The timestamp of the binary log message
|
||||
Timestamp *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
|
||||
// Uniquely identifies a call. The value must not be 0 in order to disambiguate
|
||||
|
@ -255,7 +253,7 @@ type GrpcLogEntry struct {
|
|||
// The logger uses one of the following fields to record the payload,
|
||||
// according to the type of the log entry.
|
||||
//
|
||||
// Types that are assignable to Payload:
|
||||
// Types that are valid to be assigned to Payload:
|
||||
//
|
||||
// *GrpcLogEntry_ClientHeader
|
||||
// *GrpcLogEntry_ServerHeader
|
||||
|
@ -269,7 +267,9 @@ type GrpcLogEntry struct {
|
|||
// EVENT_TYPE_SERVER_HEADER normally or EVENT_TYPE_SERVER_TRAILER in
|
||||
// the case of trailers-only. On server side, peer is always
|
||||
// logged on EVENT_TYPE_CLIENT_HEADER.
|
||||
Peer *Address `protobuf:"bytes,11,opt,name=peer,proto3" json:"peer,omitempty"`
|
||||
Peer *Address `protobuf:"bytes,11,opt,name=peer,proto3" json:"peer,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GrpcLogEntry) Reset() {
|
||||
|
@ -337,37 +337,45 @@ func (x *GrpcLogEntry) GetLogger() GrpcLogEntry_Logger {
|
|||
return GrpcLogEntry_LOGGER_UNKNOWN
|
||||
}
|
||||
|
||||
func (m *GrpcLogEntry) GetPayload() isGrpcLogEntry_Payload {
|
||||
if m != nil {
|
||||
return m.Payload
|
||||
func (x *GrpcLogEntry) GetPayload() isGrpcLogEntry_Payload {
|
||||
if x != nil {
|
||||
return x.Payload
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *GrpcLogEntry) GetClientHeader() *ClientHeader {
|
||||
if x, ok := x.GetPayload().(*GrpcLogEntry_ClientHeader); ok {
|
||||
return x.ClientHeader
|
||||
if x != nil {
|
||||
if x, ok := x.Payload.(*GrpcLogEntry_ClientHeader); ok {
|
||||
return x.ClientHeader
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *GrpcLogEntry) GetServerHeader() *ServerHeader {
|
||||
if x, ok := x.GetPayload().(*GrpcLogEntry_ServerHeader); ok {
|
||||
return x.ServerHeader
|
||||
if x != nil {
|
||||
if x, ok := x.Payload.(*GrpcLogEntry_ServerHeader); ok {
|
||||
return x.ServerHeader
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *GrpcLogEntry) GetMessage() *Message {
|
||||
if x, ok := x.GetPayload().(*GrpcLogEntry_Message); ok {
|
||||
return x.Message
|
||||
if x != nil {
|
||||
if x, ok := x.Payload.(*GrpcLogEntry_Message); ok {
|
||||
return x.Message
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *GrpcLogEntry) GetTrailer() *Trailer {
|
||||
if x, ok := x.GetPayload().(*GrpcLogEntry_Trailer); ok {
|
||||
return x.Trailer
|
||||
if x != nil {
|
||||
if x, ok := x.Payload.(*GrpcLogEntry_Trailer); ok {
|
||||
return x.Trailer
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -416,10 +424,7 @@ func (*GrpcLogEntry_Message) isGrpcLogEntry_Payload() {}
|
|||
func (*GrpcLogEntry_Trailer) isGrpcLogEntry_Payload() {}
|
||||
|
||||
type ClientHeader struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// This contains only the metadata from the application.
|
||||
Metadata *Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
|
||||
// The name of the RPC method, which looks something like:
|
||||
|
@ -433,7 +438,9 @@ type ClientHeader struct {
|
|||
// <host> or <host>:<port> .
|
||||
Authority string `protobuf:"bytes,3,opt,name=authority,proto3" json:"authority,omitempty"`
|
||||
// the RPC timeout
|
||||
Timeout *durationpb.Duration `protobuf:"bytes,4,opt,name=timeout,proto3" json:"timeout,omitempty"`
|
||||
Timeout *durationpb.Duration `protobuf:"bytes,4,opt,name=timeout,proto3" json:"timeout,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ClientHeader) Reset() {
|
||||
|
@ -495,12 +502,11 @@ func (x *ClientHeader) GetTimeout() *durationpb.Duration {
|
|||
}
|
||||
|
||||
type ServerHeader struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// This contains only the metadata from the application.
|
||||
Metadata *Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
|
||||
Metadata *Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ServerHeader) Reset() {
|
||||
|
@ -541,10 +547,7 @@ func (x *ServerHeader) GetMetadata() *Metadata {
|
|||
}
|
||||
|
||||
type Trailer struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// This contains only the metadata from the application.
|
||||
Metadata *Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
|
||||
// The gRPC status code.
|
||||
|
@ -555,6 +558,8 @@ type Trailer struct {
|
|||
// The value of the 'grpc-status-details-bin' metadata key. If
|
||||
// present, this is always an encoded 'google.rpc.Status' message.
|
||||
StatusDetails []byte `protobuf:"bytes,4,opt,name=status_details,json=statusDetails,proto3" json:"status_details,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Trailer) Reset() {
|
||||
|
@ -617,15 +622,14 @@ func (x *Trailer) GetStatusDetails() []byte {
|
|||
|
||||
// Message payload, used by CLIENT_MESSAGE and SERVER_MESSAGE
|
||||
type Message struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Length of the message. It may not be the same as the length of the
|
||||
// data field, as the logging payload can be truncated or omitted.
|
||||
Length uint32 `protobuf:"varint,1,opt,name=length,proto3" json:"length,omitempty"`
|
||||
// May be truncated or omitted.
|
||||
Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
|
||||
Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Message) Reset() {
|
||||
|
@ -694,11 +698,10 @@ func (x *Message) GetData() []byte {
|
|||
// header is just a normal metadata key.
|
||||
// The pair will not count towards the size limit.
|
||||
type Metadata struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Entry []*MetadataEntry `protobuf:"bytes,1,rep,name=entry,proto3" json:"entry,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Entry []*MetadataEntry `protobuf:"bytes,1,rep,name=entry,proto3" json:"entry,omitempty"`
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Metadata) Reset() {
|
||||
|
@ -740,12 +743,11 @@ func (x *Metadata) GetEntry() []*MetadataEntry {
|
|||
|
||||
// A metadata key value pair
|
||||
type MetadataEntry struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
|
||||
Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
|
||||
Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *MetadataEntry) Reset() {
|
||||
|
@ -794,14 +796,13 @@ func (x *MetadataEntry) GetValue() []byte {
|
|||
|
||||
// Address information
|
||||
type Address struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Type Address_Type `protobuf:"varint,1,opt,name=type,proto3,enum=grpc.binarylog.v1.Address_Type" json:"type,omitempty"`
|
||||
Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"`
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Type Address_Type `protobuf:"varint,1,opt,name=type,proto3,enum=grpc.binarylog.v1.Address_Type" json:"type,omitempty"`
|
||||
Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"`
|
||||
// only for TYPE_IPV4 and TYPE_IPV6
|
||||
IpPort uint32 `protobuf:"varint,3,opt,name=ip_port,json=ipPort,proto3" json:"ip_port,omitempty"`
|
||||
IpPort uint32 `protobuf:"varint,3,opt,name=ip_port,json=ipPort,proto3" json:"ip_port,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Address) Reset() {
|
||||
|
@ -857,7 +858,7 @@ func (x *Address) GetIpPort() uint32 {
|
|||
|
||||
var File_grpc_binlog_v1_binarylog_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_grpc_binlog_v1_binarylog_proto_rawDesc = []byte{
|
||||
var file_grpc_binlog_v1_binarylog_proto_rawDesc = string([]byte{
|
||||
0x0a, 0x1e, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x62, 0x69, 0x6e, 0x6c, 0x6f, 0x67, 0x2f, 0x76, 0x31,
|
||||
0x2f, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x12, 0x11, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67,
|
||||
|
@ -983,16 +984,16 @@ var file_grpc_binlog_v1_binarylog_proto_rawDesc = []byte{
|
|||
0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x62, 0x69,
|
||||
0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, 0x5f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x33,
|
||||
}
|
||||
})
|
||||
|
||||
var (
|
||||
file_grpc_binlog_v1_binarylog_proto_rawDescOnce sync.Once
|
||||
file_grpc_binlog_v1_binarylog_proto_rawDescData = file_grpc_binlog_v1_binarylog_proto_rawDesc
|
||||
file_grpc_binlog_v1_binarylog_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_grpc_binlog_v1_binarylog_proto_rawDescGZIP() []byte {
|
||||
file_grpc_binlog_v1_binarylog_proto_rawDescOnce.Do(func() {
|
||||
file_grpc_binlog_v1_binarylog_proto_rawDescData = protoimpl.X.CompressGZIP(file_grpc_binlog_v1_binarylog_proto_rawDescData)
|
||||
file_grpc_binlog_v1_binarylog_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_grpc_binlog_v1_binarylog_proto_rawDesc), len(file_grpc_binlog_v1_binarylog_proto_rawDesc)))
|
||||
})
|
||||
return file_grpc_binlog_v1_binarylog_proto_rawDescData
|
||||
}
|
||||
|
@ -1051,7 +1052,7 @@ func file_grpc_binlog_v1_binarylog_proto_init() {
|
|||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_grpc_binlog_v1_binarylog_proto_rawDesc,
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_grpc_binlog_v1_binarylog_proto_rawDesc), len(file_grpc_binlog_v1_binarylog_proto_rawDesc)),
|
||||
NumEnums: 3,
|
||||
NumMessages: 8,
|
||||
NumExtensions: 0,
|
||||
|
@ -1063,7 +1064,6 @@ func file_grpc_binlog_v1_binarylog_proto_init() {
|
|||
MessageInfos: file_grpc_binlog_v1_binarylog_proto_msgTypes,
|
||||
}.Build()
|
||||
File_grpc_binlog_v1_binarylog_proto = out.File
|
||||
file_grpc_binlog_v1_binarylog_proto_rawDesc = nil
|
||||
file_grpc_binlog_v1_binarylog_proto_goTypes = nil
|
||||
file_grpc_binlog_v1_binarylog_proto_depIdxs = nil
|
||||
}
|
||||
|
|
|
@ -118,12 +118,26 @@ func (dcs *defaultConfigSelector) SelectConfig(rpcInfo iresolver.RPCInfo) (*ires
|
|||
|
||||
// NewClient creates a new gRPC "channel" for the target URI provided. No I/O
|
||||
// is performed. Use of the ClientConn for RPCs will automatically cause it to
|
||||
// connect. Connect may be used to manually create a connection, but for most
|
||||
// users this is unnecessary.
|
||||
// connect. The Connect method may be called to manually create a connection,
|
||||
// but for most users this should be unnecessary.
|
||||
//
|
||||
// The target name syntax is defined in
|
||||
// https://github.com/grpc/grpc/blob/master/doc/naming.md. e.g. to use dns
|
||||
// resolver, a "dns:///" prefix should be applied to the target.
|
||||
// https://github.com/grpc/grpc/blob/master/doc/naming.md. E.g. to use the dns
|
||||
// name resolver, a "dns:///" prefix may be applied to the target. The default
|
||||
// name resolver will be used if no scheme is detected, or if the parsed scheme
|
||||
// is not a registered name resolver. The default resolver is "dns" but can be
|
||||
// overridden using the resolver package's SetDefaultScheme.
|
||||
//
|
||||
// Examples:
|
||||
//
|
||||
// - "foo.googleapis.com:8080"
|
||||
// - "dns:///foo.googleapis.com:8080"
|
||||
// - "dns:///foo.googleapis.com"
|
||||
// - "dns:///10.0.0.213:8080"
|
||||
// - "dns:///%5B2001:db8:85a3:8d3:1319:8a2e:370:7348%5D:443"
|
||||
// - "dns://8.8.8.8/foo.googleapis.com:8080"
|
||||
// - "dns://8.8.8.8/foo.googleapis.com"
|
||||
// - "zookeeper://zk.example.com:9900/example_service"
|
||||
//
|
||||
// The DialOptions returned by WithBlock, WithTimeout,
|
||||
// WithReturnConnectionError, and FailOnNonTempDialError are ignored by this
|
||||
|
@ -181,7 +195,7 @@ func NewClient(target string, opts ...DialOption) (conn *ClientConn, err error)
|
|||
}
|
||||
cc.dopts.defaultServiceConfig, _ = scpr.Config.(*ServiceConfig)
|
||||
}
|
||||
cc.mkp = cc.dopts.copts.KeepaliveParams
|
||||
cc.keepaliveParams = cc.dopts.copts.KeepaliveParams
|
||||
|
||||
if err = cc.initAuthority(); err != nil {
|
||||
return nil, err
|
||||
|
@ -225,7 +239,12 @@ func Dial(target string, opts ...DialOption) (*ClientConn, error) {
|
|||
func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *ClientConn, err error) {
|
||||
// At the end of this method, we kick the channel out of idle, rather than
|
||||
// waiting for the first rpc.
|
||||
opts = append([]DialOption{withDefaultScheme("passthrough")}, opts...)
|
||||
//
|
||||
// WithLocalDNSResolution dial option in `grpc.Dial` ensures that it
|
||||
// preserves behavior: when default scheme passthrough is used, skip
|
||||
// hostname resolution, when "dns" is used for resolution, perform
|
||||
// resolution on the client.
|
||||
opts = append([]DialOption{withDefaultScheme("passthrough"), WithLocalDNSResolution()}, opts...)
|
||||
cc, err := NewClient(target, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -618,7 +637,7 @@ type ClientConn struct {
|
|||
balancerWrapper *ccBalancerWrapper // Always recreated whenever entering idle to simplify Close.
|
||||
sc *ServiceConfig // Latest service config received from the resolver.
|
||||
conns map[*addrConn]struct{} // Set to nil on close.
|
||||
mkp keepalive.ClientParameters // May be updated upon receipt of a GoAway.
|
||||
keepaliveParams keepalive.ClientParameters // May be updated upon receipt of a GoAway.
|
||||
// firstResolveEvent is used to track whether the name resolver sent us at
|
||||
// least one update. RPCs block on this event. May be accessed without mu
|
||||
// if we know we cannot be asked to enter idle mode while accessing it (e.g.
|
||||
|
@ -867,7 +886,13 @@ func (cc *ClientConn) Target() string {
|
|||
return cc.target
|
||||
}
|
||||
|
||||
// CanonicalTarget returns the canonical target string of the ClientConn.
|
||||
// CanonicalTarget returns the canonical target string used when creating cc.
|
||||
//
|
||||
// This always has the form "<scheme>://[authority]/<endpoint>". For example:
|
||||
//
|
||||
// - "dns:///example.com:42"
|
||||
// - "dns://8.8.8.8/example.com:42"
|
||||
// - "unix:///path/to/socket"
|
||||
func (cc *ClientConn) CanonicalTarget() string {
|
||||
return cc.parsedTarget.String()
|
||||
}
|
||||
|
@ -1210,8 +1235,8 @@ func (ac *addrConn) adjustParams(r transport.GoAwayReason) {
|
|||
case transport.GoAwayTooManyPings:
|
||||
v := 2 * ac.dopts.copts.KeepaliveParams.Time
|
||||
ac.cc.mu.Lock()
|
||||
if v > ac.cc.mkp.Time {
|
||||
ac.cc.mkp.Time = v
|
||||
if v > ac.cc.keepaliveParams.Time {
|
||||
ac.cc.keepaliveParams.Time = v
|
||||
}
|
||||
ac.cc.mu.Unlock()
|
||||
}
|
||||
|
@ -1307,7 +1332,7 @@ func (ac *addrConn) tryAllAddrs(ctx context.Context, addrs []resolver.Address, c
|
|||
ac.mu.Lock()
|
||||
|
||||
ac.cc.mu.RLock()
|
||||
ac.dopts.copts.KeepaliveParams = ac.cc.mkp
|
||||
ac.dopts.copts.KeepaliveParams = ac.cc.keepaliveParams
|
||||
ac.cc.mu.RUnlock()
|
||||
|
||||
copts := ac.dopts.copts
|
||||
|
|
|
@ -32,6 +32,8 @@ import (
|
|||
"google.golang.org/grpc/internal/envconfig"
|
||||
)
|
||||
|
||||
const alpnFailureHelpMessage = "If you upgraded from a grpc-go version earlier than 1.67, your TLS connections may have stopped working due to ALPN enforcement. For more details, see: https://github.com/grpc/grpc-go/issues/434"
|
||||
|
||||
var logger = grpclog.Component("credentials")
|
||||
|
||||
// TLSInfo contains the auth information for a TLS authenticated connection.
|
||||
|
@ -128,7 +130,7 @@ func (c *tlsCreds) ClientHandshake(ctx context.Context, authority string, rawCon
|
|||
if np == "" {
|
||||
if envconfig.EnforceALPNEnabled {
|
||||
conn.Close()
|
||||
return nil, nil, fmt.Errorf("credentials: cannot check peer: missing selected ALPN property")
|
||||
return nil, nil, fmt.Errorf("credentials: cannot check peer: missing selected ALPN property. %s", alpnFailureHelpMessage)
|
||||
}
|
||||
logger.Warningf("Allowing TLS connection to server %q with ALPN disabled. TLS connections to servers with ALPN disabled will be disallowed in future grpc-go releases", cfg.ServerName)
|
||||
}
|
||||
|
@ -158,7 +160,7 @@ func (c *tlsCreds) ServerHandshake(rawConn net.Conn) (net.Conn, AuthInfo, error)
|
|||
if cs.NegotiatedProtocol == "" {
|
||||
if envconfig.EnforceALPNEnabled {
|
||||
conn.Close()
|
||||
return nil, nil, fmt.Errorf("credentials: cannot check peer: missing selected ALPN property")
|
||||
return nil, nil, fmt.Errorf("credentials: cannot check peer: missing selected ALPN property. %s", alpnFailureHelpMessage)
|
||||
} else if logger.V(2) {
|
||||
logger.Info("Allowing TLS connection from client with ALPN disabled. TLS connections with ALPN disabled will be disallowed in future grpc-go releases")
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ type dialOptions struct {
|
|||
chainUnaryInts []UnaryClientInterceptor
|
||||
chainStreamInts []StreamClientInterceptor
|
||||
|
||||
cp Compressor
|
||||
compressorV0 Compressor
|
||||
dc Decompressor
|
||||
bs internalbackoff.Strategy
|
||||
block bool
|
||||
|
@ -94,6 +94,8 @@ type dialOptions struct {
|
|||
idleTimeout time.Duration
|
||||
defaultScheme string
|
||||
maxCallAttempts int
|
||||
enableLocalDNSResolution bool // Specifies if target hostnames should be resolved when proxying is enabled.
|
||||
useProxy bool // Specifies if a server should be connected via proxy.
|
||||
}
|
||||
|
||||
// DialOption configures how we set up the connection.
|
||||
|
@ -256,7 +258,7 @@ func WithCodec(c Codec) DialOption {
|
|||
// Deprecated: use UseCompressor instead. Will be supported throughout 1.x.
|
||||
func WithCompressor(cp Compressor) DialOption {
|
||||
return newFuncDialOption(func(o *dialOptions) {
|
||||
o.cp = cp
|
||||
o.compressorV0 = cp
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -377,7 +379,22 @@ func WithInsecure() DialOption {
|
|||
// later release.
|
||||
func WithNoProxy() DialOption {
|
||||
return newFuncDialOption(func(o *dialOptions) {
|
||||
o.copts.UseProxy = false
|
||||
o.useProxy = false
|
||||
})
|
||||
}
|
||||
|
||||
// WithLocalDNSResolution forces local DNS name resolution even when a proxy is
|
||||
// specified in the environment. By default, the server name is provided
|
||||
// directly to the proxy as part of the CONNECT handshake. This is ignored if
|
||||
// WithNoProxy is used.
|
||||
//
|
||||
// # Experimental
|
||||
//
|
||||
// Notice: This API is EXPERIMENTAL and may be changed or removed in a
|
||||
// later release.
|
||||
func WithLocalDNSResolution() DialOption {
|
||||
return newFuncDialOption(func(o *dialOptions) {
|
||||
o.enableLocalDNSResolution = true
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -428,6 +445,11 @@ func WithTimeout(d time.Duration) DialOption {
|
|||
// returned by f, gRPC checks the error's Temporary() method to decide if it
|
||||
// should try to reconnect to the network address.
|
||||
//
|
||||
// Note that gRPC by default performs name resolution on the target passed to
|
||||
// NewClient. To bypass name resolution and cause the target string to be
|
||||
// passed directly to the dialer here instead, use the "passthrough" resolver
|
||||
// by specifying it in the target string, e.g. "passthrough:target".
|
||||
//
|
||||
// Note: All supported releases of Go (as of December 2023) override the OS
|
||||
// defaults for TCP keepalive time and interval to 15s. To enable TCP keepalive
|
||||
// with OS defaults for keepalive time and interval, use a net.Dialer that sets
|
||||
|
@ -662,14 +684,15 @@ func defaultDialOptions() dialOptions {
|
|||
copts: transport.ConnectOptions{
|
||||
ReadBufferSize: defaultReadBufSize,
|
||||
WriteBufferSize: defaultWriteBufSize,
|
||||
UseProxy: true,
|
||||
UserAgent: grpcUA,
|
||||
BufferPool: mem.DefaultBufferPool(),
|
||||
},
|
||||
bs: internalbackoff.DefaultExponential,
|
||||
idleTimeout: 30 * time.Minute,
|
||||
defaultScheme: "dns",
|
||||
maxCallAttempts: defaultMaxCallAttempts,
|
||||
bs: internalbackoff.DefaultExponential,
|
||||
idleTimeout: 30 * time.Minute,
|
||||
defaultScheme: "dns",
|
||||
maxCallAttempts: defaultMaxCallAttempts,
|
||||
useProxy: true,
|
||||
enableLocalDNSResolution: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.35.1
|
||||
// protoc-gen-go v1.36.4
|
||||
// protoc v5.27.1
|
||||
// source: grpc/health/v1/health.proto
|
||||
|
||||
|
@ -28,6 +28,7 @@ import (
|
|||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -90,11 +91,10 @@ func (HealthCheckResponse_ServingStatus) EnumDescriptor() ([]byte, []int) {
|
|||
}
|
||||
|
||||
type HealthCheckRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"`
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *HealthCheckRequest) Reset() {
|
||||
|
@ -135,11 +135,10 @@ func (x *HealthCheckRequest) GetService() string {
|
|||
}
|
||||
|
||||
type HealthCheckResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Status HealthCheckResponse_ServingStatus `protobuf:"varint,1,opt,name=status,proto3,enum=grpc.health.v1.HealthCheckResponse_ServingStatus" json:"status,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Status HealthCheckResponse_ServingStatus `protobuf:"varint,1,opt,name=status,proto3,enum=grpc.health.v1.HealthCheckResponse_ServingStatus" json:"status,omitempty"`
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *HealthCheckResponse) Reset() {
|
||||
|
@ -181,7 +180,7 @@ func (x *HealthCheckResponse) GetStatus() HealthCheckResponse_ServingStatus {
|
|||
|
||||
var File_grpc_health_v1_health_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_grpc_health_v1_health_proto_rawDesc = []byte{
|
||||
var file_grpc_health_v1_health_proto_rawDesc = string([]byte{
|
||||
0x0a, 0x1b, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x2f, 0x76, 0x31,
|
||||
0x2f, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x67,
|
||||
0x72, 0x70, 0x63, 0x2e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x22, 0x2e, 0x0a,
|
||||
|
@ -210,23 +209,24 @@ var file_grpc_health_v1_health_proto_rawDesc = []byte{
|
|||
0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x67, 0x72,
|
||||
0x70, 0x63, 0x2e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x65, 0x61,
|
||||
0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
|
||||
0x30, 0x01, 0x42, 0x61, 0x0a, 0x11, 0x69, 0x6f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x68, 0x65,
|
||||
0x30, 0x01, 0x42, 0x70, 0x0a, 0x11, 0x69, 0x6f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x68, 0x65,
|
||||
0x61, 0x6c, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x50,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67,
|
||||
0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x68,
|
||||
0x65, 0x61, 0x6c, 0x74, 0x68, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x68, 0x65, 0x61, 0x6c, 0x74,
|
||||
0x68, 0x5f, 0x76, 0x31, 0xaa, 0x02, 0x0e, 0x47, 0x72, 0x70, 0x63, 0x2e, 0x48, 0x65, 0x61, 0x6c,
|
||||
0x74, 0x68, 0x2e, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
0x68, 0x5f, 0x76, 0x31, 0xa2, 0x02, 0x0c, 0x47, 0x72, 0x70, 0x63, 0x48, 0x65, 0x61, 0x6c, 0x74,
|
||||
0x68, 0x56, 0x31, 0xaa, 0x02, 0x0e, 0x47, 0x72, 0x70, 0x63, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74,
|
||||
0x68, 0x2e, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
})
|
||||
|
||||
var (
|
||||
file_grpc_health_v1_health_proto_rawDescOnce sync.Once
|
||||
file_grpc_health_v1_health_proto_rawDescData = file_grpc_health_v1_health_proto_rawDesc
|
||||
file_grpc_health_v1_health_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_grpc_health_v1_health_proto_rawDescGZIP() []byte {
|
||||
file_grpc_health_v1_health_proto_rawDescOnce.Do(func() {
|
||||
file_grpc_health_v1_health_proto_rawDescData = protoimpl.X.CompressGZIP(file_grpc_health_v1_health_proto_rawDescData)
|
||||
file_grpc_health_v1_health_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_grpc_health_v1_health_proto_rawDesc), len(file_grpc_health_v1_health_proto_rawDesc)))
|
||||
})
|
||||
return file_grpc_health_v1_health_proto_rawDescData
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ func file_grpc_health_v1_health_proto_init() {
|
|||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_grpc_health_v1_health_proto_rawDesc,
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_grpc_health_v1_health_proto_rawDesc), len(file_grpc_health_v1_health_proto_rawDesc)),
|
||||
NumEnums: 1,
|
||||
NumMessages: 2,
|
||||
NumExtensions: 0,
|
||||
|
@ -272,7 +272,6 @@ func file_grpc_health_v1_health_proto_init() {
|
|||
MessageInfos: file_grpc_health_v1_health_proto_msgTypes,
|
||||
}.Build()
|
||||
File_grpc_health_v1_health_proto = out.File
|
||||
file_grpc_health_v1_health_proto_rawDesc = nil
|
||||
file_grpc_health_v1_health_proto_goTypes = nil
|
||||
file_grpc_health_v1_health_proto_depIdxs = nil
|
||||
}
|
||||
|
|
10
vendor/google.golang.org/grpc/internal/balancer/gracefulswitch/gracefulswitch.go
generated
vendored
10
vendor/google.golang.org/grpc/internal/balancer/gracefulswitch/gracefulswitch.go
generated
vendored
|
@ -109,8 +109,9 @@ func (gsb *Balancer) switchTo(builder balancer.Builder) (*balancerWrapper, error
|
|||
return nil, errBalancerClosed
|
||||
}
|
||||
bw := &balancerWrapper{
|
||||
builder: builder,
|
||||
gsb: gsb,
|
||||
ClientConn: gsb.cc,
|
||||
builder: builder,
|
||||
gsb: gsb,
|
||||
lastState: balancer.State{
|
||||
ConnectivityState: connectivity.Connecting,
|
||||
Picker: base.NewErrPicker(balancer.ErrNoSubConnAvailable),
|
||||
|
@ -293,6 +294,7 @@ func (gsb *Balancer) Close() {
|
|||
// State updates from the wrapped balancer can result in invocation of the
|
||||
// graceful switch logic.
|
||||
type balancerWrapper struct {
|
||||
balancer.ClientConn
|
||||
balancer.Balancer
|
||||
gsb *Balancer
|
||||
builder balancer.Builder
|
||||
|
@ -413,7 +415,3 @@ func (bw *balancerWrapper) UpdateAddresses(sc balancer.SubConn, addrs []resolver
|
|||
bw.gsb.mu.Unlock()
|
||||
bw.gsb.cc.UpdateAddresses(sc, addrs)
|
||||
}
|
||||
|
||||
func (bw *balancerWrapper) Target() string {
|
||||
return bw.gsb.cc.Target()
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ var (
|
|||
// XDSFallbackSupport is the env variable that controls whether support for
|
||||
// xDS fallback is turned on. If this is unset or is false, only the first
|
||||
// xDS server in the list of server configs will be used.
|
||||
XDSFallbackSupport = boolFromEnv("GRPC_EXPERIMENTAL_XDS_FALLBACK", false)
|
||||
XDSFallbackSupport = boolFromEnv("GRPC_EXPERIMENTAL_XDS_FALLBACK", true)
|
||||
// NewPickFirstEnabled is set if the new pickfirst leaf policy is to be used
|
||||
// instead of the exiting pickfirst implementation. This can be enabled by
|
||||
// setting the environment variable "GRPC_EXPERIMENTAL_ENABLE_NEW_PICK_FIRST"
|
||||
|
|
|
@ -53,4 +53,14 @@ var (
|
|||
|
||||
// C2PResolverTestOnlyTrafficDirectorURI is the TD URI for testing.
|
||||
C2PResolverTestOnlyTrafficDirectorURI = os.Getenv("GRPC_TEST_ONLY_GOOGLE_C2P_RESOLVER_TRAFFIC_DIRECTOR_URI")
|
||||
|
||||
// XDSDualstackEndpointsEnabled is true if gRPC should read the
|
||||
// "additional addresses" in the xDS endpoint resource.
|
||||
XDSDualstackEndpointsEnabled = boolFromEnv("GRPC_EXPERIMENTAL_XDS_DUALSTACK_ENDPOINTS", true)
|
||||
|
||||
// XDSSystemRootCertsEnabled is true when xDS enabled gRPC clients can use
|
||||
// the system's default root certificates for TLS certificate validation.
|
||||
// For more details, see:
|
||||
// https://github.com/grpc/proposal/blob/master/A82-xds-system-root-certs.md.
|
||||
XDSSystemRootCertsEnabled = boolFromEnv("GRPC_EXPERIMENTAL_XDS_SYSTEM_ROOT_CERTS", false)
|
||||
)
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
*
|
||||
* Copyright 2022 gRPC authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package grpcsync
|
||||
|
||||
import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
// OnceFunc returns a function wrapping f which ensures f is only executed
|
||||
// once even if the returned function is executed multiple times.
|
||||
func OnceFunc(f func()) func() {
|
||||
var once sync.Once
|
||||
return func() {
|
||||
once.Do(f)
|
||||
}
|
||||
}
|
|
@ -31,6 +31,10 @@ import (
|
|||
var (
|
||||
// HealthCheckFunc is used to provide client-side LB channel health checking
|
||||
HealthCheckFunc HealthChecker
|
||||
// RegisterClientHealthCheckListener is used to provide a listener for
|
||||
// updates from the client-side health checking service. It returns a
|
||||
// function that can be called to stop the health producer.
|
||||
RegisterClientHealthCheckListener any // func(ctx context.Context, sc balancer.SubConn, serviceName string, listener func(balancer.SubConnState)) func()
|
||||
// BalancerUnregister is exported by package balancer to unregister a balancer.
|
||||
BalancerUnregister func(name string)
|
||||
// KeepaliveMinPingTime is the minimum ping interval. This must be 10s by
|
||||
|
@ -60,6 +64,9 @@ var (
|
|||
// gRPC server. An xDS-enabled server needs to know what type of credentials
|
||||
// is configured on the underlying gRPC server. This is set by server.go.
|
||||
GetServerCredentials any // func (*grpc.Server) credentials.TransportCredentials
|
||||
// MetricsRecorderForServer returns the MetricsRecorderList derived from a
|
||||
// server's stats handlers.
|
||||
MetricsRecorderForServer any // func (*grpc.Server) estats.MetricsRecorder
|
||||
// CanonicalString returns the canonical string of the code defined here:
|
||||
// https://github.com/grpc/grpc/blob/master/doc/statuscodes.md.
|
||||
//
|
||||
|
@ -147,6 +154,20 @@ var (
|
|||
// other features, including the CSDS service.
|
||||
NewXDSResolverWithConfigForTesting any // func([]byte) (resolver.Builder, error)
|
||||
|
||||
// NewXDSResolverWithPoolForTesting creates a new xDS resolver builder
|
||||
// using the provided xDS pool instead of creating a new one using the
|
||||
// bootstrap configuration specified by the supported environment variables.
|
||||
// The resolver.Builder is meant to be used in conjunction with the
|
||||
// grpc.WithResolvers DialOption. The resolver.Builder does not take
|
||||
// ownership of the provided xDS client and it is the responsibility of the
|
||||
// caller to close the client when no longer required.
|
||||
//
|
||||
// Testing Only
|
||||
//
|
||||
// This function should ONLY be used for testing and may not work with some
|
||||
// other features, including the CSDS service.
|
||||
NewXDSResolverWithPoolForTesting any // func(*xdsclient.Pool) (resolver.Builder, error)
|
||||
|
||||
// NewXDSResolverWithClientForTesting creates a new xDS resolver builder
|
||||
// using the provided xDS client instead of creating a new one using the
|
||||
// bootstrap configuration specified by the supported environment variables.
|
||||
|
@ -273,3 +294,9 @@ const RLSLoadBalancingPolicyName = "rls_experimental"
|
|||
type EnforceSubConnEmbedding interface {
|
||||
enforceSubConnEmbedding()
|
||||
}
|
||||
|
||||
// EnforceClientConnEmbedding is used to enforce proper ClientConn implementation
|
||||
// embedding.
|
||||
type EnforceClientConnEmbedding interface {
|
||||
enforceClientConnEmbedding()
|
||||
}
|
||||
|
|
54
vendor/google.golang.org/grpc/internal/proxyattributes/proxyattributes.go
generated
vendored
Normal file
54
vendor/google.golang.org/grpc/internal/proxyattributes/proxyattributes.go
generated
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
*
|
||||
* Copyright 2024 gRPC authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
// Package proxyattributes contains functions for getting and setting proxy
|
||||
// attributes like the CONNECT address and user info.
|
||||
package proxyattributes
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
|
||||
"google.golang.org/grpc/resolver"
|
||||
)
|
||||
|
||||
type keyType string
|
||||
|
||||
const proxyOptionsKey = keyType("grpc.resolver.delegatingresolver.proxyOptions")
|
||||
|
||||
// Options holds the proxy connection details needed during the CONNECT
|
||||
// handshake.
|
||||
type Options struct {
|
||||
User *url.Userinfo
|
||||
ConnectAddr string
|
||||
}
|
||||
|
||||
// Set returns a copy of addr with opts set in its attributes.
|
||||
func Set(addr resolver.Address, opts Options) resolver.Address {
|
||||
addr.Attributes = addr.Attributes.WithValue(proxyOptionsKey, opts)
|
||||
return addr
|
||||
}
|
||||
|
||||
// Get returns the Options for the proxy [resolver.Address] and a boolean
|
||||
// value representing if the attribute is present or not. The returned data
|
||||
// should not be mutated.
|
||||
func Get(addr resolver.Address) (Options, bool) {
|
||||
if a := addr.Attributes.Value(proxyOptionsKey); a != nil {
|
||||
return a.(Options), true
|
||||
}
|
||||
return Options{}, false
|
||||
}
|
329
vendor/google.golang.org/grpc/internal/resolver/delegatingresolver/delegatingresolver.go
generated
vendored
Normal file
329
vendor/google.golang.org/grpc/internal/resolver/delegatingresolver/delegatingresolver.go
generated
vendored
Normal file
|
@ -0,0 +1,329 @@
|
|||
/*
|
||||
*
|
||||
* Copyright 2024 gRPC authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
// Package delegatingresolver implements a resolver capable of resolving both
|
||||
// target URIs and proxy addresses.
|
||||
package delegatingresolver
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"sync"
|
||||
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"google.golang.org/grpc/internal/proxyattributes"
|
||||
"google.golang.org/grpc/resolver"
|
||||
"google.golang.org/grpc/serviceconfig"
|
||||
)
|
||||
|
||||
var (
|
||||
logger = grpclog.Component("delegating-resolver")
|
||||
// HTTPSProxyFromEnvironment will be overwritten in the tests
|
||||
HTTPSProxyFromEnvironment = http.ProxyFromEnvironment
|
||||
)
|
||||
|
||||
// delegatingResolver manages both target URI and proxy address resolution by
|
||||
// delegating these tasks to separate child resolvers. Essentially, it acts as
|
||||
// a intermediary between the gRPC ClientConn and the child resolvers.
|
||||
//
|
||||
// It implements the [resolver.Resolver] interface.
|
||||
type delegatingResolver struct {
|
||||
target resolver.Target // parsed target URI to be resolved
|
||||
cc resolver.ClientConn // gRPC ClientConn
|
||||
targetResolver resolver.Resolver // resolver for the target URI, based on its scheme
|
||||
proxyResolver resolver.Resolver // resolver for the proxy URI; nil if no proxy is configured
|
||||
proxyURL *url.URL // proxy URL, derived from proxy environment and target
|
||||
|
||||
mu sync.Mutex // protects all the fields below
|
||||
targetResolverState *resolver.State // state of the target resolver
|
||||
proxyAddrs []resolver.Address // resolved proxy addresses; empty if no proxy is configured
|
||||
}
|
||||
|
||||
// nopResolver is a resolver that does nothing.
|
||||
type nopResolver struct{}
|
||||
|
||||
func (nopResolver) ResolveNow(resolver.ResolveNowOptions) {}
|
||||
|
||||
func (nopResolver) Close() {}
|
||||
|
||||
// proxyURLForTarget determines the proxy URL for the given address based on
|
||||
// the environment. It can return the following:
|
||||
// - nil URL, nil error: No proxy is configured or the address is excluded
|
||||
// using the `NO_PROXY` environment variable or if req.URL.Host is
|
||||
// "localhost" (with or without // a port number)
|
||||
// - nil URL, non-nil error: An error occurred while retrieving the proxy URL.
|
||||
// - non-nil URL, nil error: A proxy is configured, and the proxy URL was
|
||||
// retrieved successfully without any errors.
|
||||
func proxyURLForTarget(address string) (*url.URL, error) {
|
||||
req := &http.Request{URL: &url.URL{
|
||||
Scheme: "https",
|
||||
Host: address,
|
||||
}}
|
||||
return HTTPSProxyFromEnvironment(req)
|
||||
}
|
||||
|
||||
// New creates a new delegating resolver that can create up to two child
|
||||
// resolvers:
|
||||
// - one to resolve the proxy address specified using the supported
|
||||
// environment variables. This uses the registered resolver for the "dns"
|
||||
// scheme.
|
||||
// - one to resolve the target URI using the resolver specified by the scheme
|
||||
// in the target URI or specified by the user using the WithResolvers dial
|
||||
// option. As a special case, if the target URI's scheme is "dns" and a
|
||||
// proxy is specified using the supported environment variables, the target
|
||||
// URI's path portion is used as the resolved address unless target
|
||||
// resolution is enabled using the dial option.
|
||||
func New(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions, targetResolverBuilder resolver.Builder, targetResolutionEnabled bool) (resolver.Resolver, error) {
|
||||
r := &delegatingResolver{
|
||||
target: target,
|
||||
cc: cc,
|
||||
}
|
||||
|
||||
var err error
|
||||
r.proxyURL, err = proxyURLForTarget(target.Endpoint())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("delegating_resolver: failed to determine proxy URL for target %s: %v", target, err)
|
||||
}
|
||||
|
||||
// proxy is not configured or proxy address excluded using `NO_PROXY` env
|
||||
// var, so only target resolver is used.
|
||||
if r.proxyURL == nil {
|
||||
return targetResolverBuilder.Build(target, cc, opts)
|
||||
}
|
||||
|
||||
if logger.V(2) {
|
||||
logger.Infof("Proxy URL detected : %s", r.proxyURL)
|
||||
}
|
||||
|
||||
// When the scheme is 'dns' and target resolution on client is not enabled,
|
||||
// resolution should be handled by the proxy, not the client. Therefore, we
|
||||
// bypass the target resolver and store the unresolved target address.
|
||||
if target.URL.Scheme == "dns" && !targetResolutionEnabled {
|
||||
state := resolver.State{
|
||||
Addresses: []resolver.Address{{Addr: target.Endpoint()}},
|
||||
Endpoints: []resolver.Endpoint{{Addresses: []resolver.Address{{Addr: target.Endpoint()}}}},
|
||||
}
|
||||
r.targetResolverState = &state
|
||||
} else {
|
||||
wcc := &wrappingClientConn{
|
||||
stateListener: r.updateTargetResolverState,
|
||||
parent: r,
|
||||
}
|
||||
if r.targetResolver, err = targetResolverBuilder.Build(target, wcc, opts); err != nil {
|
||||
return nil, fmt.Errorf("delegating_resolver: unable to build the resolver for target %s: %v", target, err)
|
||||
}
|
||||
}
|
||||
|
||||
if r.proxyResolver, err = r.proxyURIResolver(opts); err != nil {
|
||||
return nil, fmt.Errorf("delegating_resolver: failed to build resolver for proxy URL %q: %v", r.proxyURL, err)
|
||||
}
|
||||
|
||||
if r.targetResolver == nil {
|
||||
r.targetResolver = nopResolver{}
|
||||
}
|
||||
if r.proxyResolver == nil {
|
||||
r.proxyResolver = nopResolver{}
|
||||
}
|
||||
return r, nil
|
||||
}
|
||||
|
||||
// proxyURIResolver creates a resolver for resolving proxy URIs using the
|
||||
// "dns" scheme. It adjusts the proxyURL to conform to the "dns:///" format and
|
||||
// builds a resolver with a wrappingClientConn to capture resolved addresses.
|
||||
func (r *delegatingResolver) proxyURIResolver(opts resolver.BuildOptions) (resolver.Resolver, error) {
|
||||
proxyBuilder := resolver.Get("dns")
|
||||
if proxyBuilder == nil {
|
||||
panic("delegating_resolver: resolver for proxy not found for scheme dns")
|
||||
}
|
||||
url := *r.proxyURL
|
||||
url.Scheme = "dns"
|
||||
url.Path = "/" + r.proxyURL.Host
|
||||
url.Host = "" // Clear the Host field to conform to the "dns:///" format
|
||||
|
||||
proxyTarget := resolver.Target{URL: url}
|
||||
wcc := &wrappingClientConn{
|
||||
stateListener: r.updateProxyResolverState,
|
||||
parent: r,
|
||||
}
|
||||
return proxyBuilder.Build(proxyTarget, wcc, opts)
|
||||
}
|
||||
|
||||
func (r *delegatingResolver) ResolveNow(o resolver.ResolveNowOptions) {
|
||||
r.targetResolver.ResolveNow(o)
|
||||
r.proxyResolver.ResolveNow(o)
|
||||
}
|
||||
|
||||
func (r *delegatingResolver) Close() {
|
||||
r.targetResolver.Close()
|
||||
r.targetResolver = nil
|
||||
|
||||
r.proxyResolver.Close()
|
||||
r.proxyResolver = nil
|
||||
}
|
||||
|
||||
// updateClientConnStateLocked creates a list of combined addresses by
|
||||
// pairing each proxy address with every target address. For each pair, it
|
||||
// generates a new [resolver.Address] using the proxy address, and adding the
|
||||
// target address as the attribute along with user info. It returns nil if
|
||||
// either resolver has not sent update even once and returns the error from
|
||||
// ClientConn update once both resolvers have sent update atleast once.
|
||||
func (r *delegatingResolver) updateClientConnStateLocked() error {
|
||||
if r.targetResolverState == nil || r.proxyAddrs == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
curState := *r.targetResolverState
|
||||
// If multiple resolved proxy addresses are present, we send only the
|
||||
// unresolved proxy host and let net.Dial handle the proxy host name
|
||||
// resolution when creating the transport. Sending all resolved addresses
|
||||
// would increase the number of addresses passed to the ClientConn and
|
||||
// subsequently to load balancing (LB) policies like Round Robin, leading
|
||||
// to additional TCP connections. However, if there's only one resolved
|
||||
// proxy address, we send it directly, as it doesn't affect the address
|
||||
// count returned by the target resolver and the address count sent to the
|
||||
// ClientConn.
|
||||
var proxyAddr resolver.Address
|
||||
if len(r.proxyAddrs) == 1 {
|
||||
proxyAddr = r.proxyAddrs[0]
|
||||
} else {
|
||||
proxyAddr = resolver.Address{Addr: r.proxyURL.Host}
|
||||
}
|
||||
var addresses []resolver.Address
|
||||
for _, targetAddr := range (*r.targetResolverState).Addresses {
|
||||
addresses = append(addresses, proxyattributes.Set(proxyAddr, proxyattributes.Options{
|
||||
User: r.proxyURL.User,
|
||||
ConnectAddr: targetAddr.Addr,
|
||||
}))
|
||||
}
|
||||
|
||||
// Create a list of combined endpoints by pairing all proxy endpoints
|
||||
// with every target endpoint. Each time, it constructs a new
|
||||
// [resolver.Endpoint] using the all addresses from all the proxy endpoint
|
||||
// and the target addresses from one endpoint. The target address and user
|
||||
// information from the proxy URL are added as attributes to the proxy
|
||||
// address.The resulting list of addresses is then grouped into endpoints,
|
||||
// covering all combinations of proxy and target endpoints.
|
||||
var endpoints []resolver.Endpoint
|
||||
for _, endpt := range (*r.targetResolverState).Endpoints {
|
||||
var addrs []resolver.Address
|
||||
for _, proxyAddr := range r.proxyAddrs {
|
||||
for _, targetAddr := range endpt.Addresses {
|
||||
addrs = append(addrs, proxyattributes.Set(proxyAddr, proxyattributes.Options{
|
||||
User: r.proxyURL.User,
|
||||
ConnectAddr: targetAddr.Addr,
|
||||
}))
|
||||
}
|
||||
}
|
||||
endpoints = append(endpoints, resolver.Endpoint{Addresses: addrs})
|
||||
}
|
||||
// Use the targetResolverState for its service config and attributes
|
||||
// contents. The state update is only sent after both the target and proxy
|
||||
// resolvers have sent their updates, and curState has been updated with
|
||||
// the combined addresses.
|
||||
curState.Addresses = addresses
|
||||
curState.Endpoints = endpoints
|
||||
return r.cc.UpdateState(curState)
|
||||
}
|
||||
|
||||
// updateProxyResolverState updates the proxy resolver state by storing proxy
|
||||
// addresses and endpoints, marking the resolver as ready, and triggering a
|
||||
// state update if both proxy and target resolvers are ready. If the ClientConn
|
||||
// returns a non-nil error, it calls `ResolveNow()` on the target resolver. It
|
||||
// is a StateListener function of wrappingClientConn passed to the proxy resolver.
|
||||
func (r *delegatingResolver) updateProxyResolverState(state resolver.State) error {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
if logger.V(2) {
|
||||
logger.Infof("Addresses received from proxy resolver: %s", state.Addresses)
|
||||
}
|
||||
if len(state.Endpoints) > 0 {
|
||||
// We expect exactly one address per endpoint because the proxy
|
||||
// resolver uses "dns" resolution.
|
||||
r.proxyAddrs = make([]resolver.Address, 0, len(state.Endpoints))
|
||||
for _, endpoint := range state.Endpoints {
|
||||
r.proxyAddrs = append(r.proxyAddrs, endpoint.Addresses...)
|
||||
}
|
||||
} else if state.Addresses != nil {
|
||||
r.proxyAddrs = state.Addresses
|
||||
} else {
|
||||
r.proxyAddrs = []resolver.Address{} // ensure proxyAddrs is non-nil to indicate an update has been received
|
||||
}
|
||||
err := r.updateClientConnStateLocked()
|
||||
// Another possible approach was to block until updates are received from
|
||||
// both resolvers. But this is not used because calling `New()` triggers
|
||||
// `Build()` for the first resolver, which calls `UpdateState()`. And the
|
||||
// second resolver hasn't sent an update yet, so it would cause `New()` to
|
||||
// block indefinitely.
|
||||
if err != nil {
|
||||
r.targetResolver.ResolveNow(resolver.ResolveNowOptions{})
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// updateTargetResolverState updates the target resolver state by storing target
|
||||
// addresses, endpoints, and service config, marking the resolver as ready, and
|
||||
// triggering a state update if both resolvers are ready. If the ClientConn
|
||||
// returns a non-nil error, it calls `ResolveNow()` on the proxy resolver. It
|
||||
// is a StateListener function of wrappingClientConn passed to the target resolver.
|
||||
func (r *delegatingResolver) updateTargetResolverState(state resolver.State) error {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
if logger.V(2) {
|
||||
logger.Infof("Addresses received from target resolver: %v", state.Addresses)
|
||||
}
|
||||
r.targetResolverState = &state
|
||||
err := r.updateClientConnStateLocked()
|
||||
if err != nil {
|
||||
r.proxyResolver.ResolveNow(resolver.ResolveNowOptions{})
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// wrappingClientConn serves as an intermediary between the parent ClientConn
|
||||
// and the child resolvers created here. It implements the resolver.ClientConn
|
||||
// interface and is passed in that capacity to the child resolvers.
|
||||
type wrappingClientConn struct {
|
||||
// Callback to deliver resolver state updates
|
||||
stateListener func(state resolver.State) error
|
||||
parent *delegatingResolver
|
||||
}
|
||||
|
||||
// UpdateState receives resolver state updates and forwards them to the
|
||||
// appropriate listener function (either for the proxy or target resolver).
|
||||
func (wcc *wrappingClientConn) UpdateState(state resolver.State) error {
|
||||
return wcc.stateListener(state)
|
||||
}
|
||||
|
||||
// ReportError intercepts errors from the child resolvers and passes them to ClientConn.
|
||||
func (wcc *wrappingClientConn) ReportError(err error) {
|
||||
wcc.parent.cc.ReportError(err)
|
||||
}
|
||||
|
||||
// NewAddress intercepts the new resolved address from the child resolvers and
|
||||
// passes them to ClientConn.
|
||||
func (wcc *wrappingClientConn) NewAddress(addrs []resolver.Address) {
|
||||
wcc.UpdateState(resolver.State{Addresses: addrs})
|
||||
}
|
||||
|
||||
// ParseServiceConfig parses the provided service config and returns an
|
||||
// object that provides the parsed config.
|
||||
func (wcc *wrappingClientConn) ParseServiceConfig(serviceConfigJSON string) *serviceconfig.ParseResult {
|
||||
return wcc.parent.cc.ParseServiceConfig(serviceConfigJSON)
|
||||
}
|
|
@ -498,5 +498,5 @@ func mapRecvMsgError(err error) error {
|
|||
if strings.Contains(err.Error(), "body closed by handler") {
|
||||
return status.Error(codes.Canceled, err.Error())
|
||||
}
|
||||
return connectionErrorf(true, err, err.Error())
|
||||
return connectionErrorf(true, err, "%s", err.Error())
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ import (
|
|||
"google.golang.org/grpc/internal/grpcsync"
|
||||
"google.golang.org/grpc/internal/grpcutil"
|
||||
imetadata "google.golang.org/grpc/internal/metadata"
|
||||
"google.golang.org/grpc/internal/proxyattributes"
|
||||
istatus "google.golang.org/grpc/internal/status"
|
||||
isyscall "google.golang.org/grpc/internal/syscall"
|
||||
"google.golang.org/grpc/internal/transport/networktype"
|
||||
|
@ -153,7 +154,7 @@ type http2Client struct {
|
|||
logger *grpclog.PrefixLogger
|
||||
}
|
||||
|
||||
func dial(ctx context.Context, fn func(context.Context, string) (net.Conn, error), addr resolver.Address, useProxy bool, grpcUA string) (net.Conn, error) {
|
||||
func dial(ctx context.Context, fn func(context.Context, string) (net.Conn, error), addr resolver.Address, grpcUA string) (net.Conn, error) {
|
||||
address := addr.Addr
|
||||
networkType, ok := networktype.Get(addr)
|
||||
if fn != nil {
|
||||
|
@ -177,8 +178,8 @@ func dial(ctx context.Context, fn func(context.Context, string) (net.Conn, error
|
|||
if !ok {
|
||||
networkType, address = parseDialTarget(address)
|
||||
}
|
||||
if networkType == "tcp" && useProxy {
|
||||
return proxyDial(ctx, address, grpcUA)
|
||||
if opts, present := proxyattributes.Get(addr); present {
|
||||
return proxyDial(ctx, addr, grpcUA, opts)
|
||||
}
|
||||
return internal.NetDialerWithTCPKeepalive().DialContext(ctx, networkType, address)
|
||||
}
|
||||
|
@ -217,7 +218,7 @@ func NewHTTP2Client(connectCtx, ctx context.Context, addr resolver.Address, opts
|
|||
// address specific arbitrary data to reach custom dialers and credential handshakers.
|
||||
connectCtx = icredentials.NewClientHandshakeInfoContext(connectCtx, credentials.ClientHandshakeInfo{Attributes: addr.Attributes})
|
||||
|
||||
conn, err := dial(connectCtx, opts.Dialer, addr, opts.UseProxy, opts.UserAgent)
|
||||
conn, err := dial(connectCtx, opts.Dialer, addr, opts.UserAgent)
|
||||
if err != nil {
|
||||
if opts.FailOnNonTempDialError {
|
||||
return nil, connectionErrorf(isTemporary(err), err, "transport: error while dialing: %v", err)
|
||||
|
|
|
@ -564,7 +564,7 @@ func (t *http2Server) operateHeaders(ctx context.Context, frame *http2.MetaHeade
|
|||
t.logger.Infof("Aborting the stream early: %v", errMsg)
|
||||
}
|
||||
t.controlBuf.put(&earlyAbortStream{
|
||||
httpStatus: 405,
|
||||
httpStatus: http.StatusMethodNotAllowed,
|
||||
streamID: streamID,
|
||||
contentSubtype: s.contentSubtype,
|
||||
status: status.New(codes.Internal, errMsg),
|
||||
|
@ -585,7 +585,7 @@ func (t *http2Server) operateHeaders(ctx context.Context, frame *http2.MetaHeade
|
|||
stat = status.New(codes.PermissionDenied, err.Error())
|
||||
}
|
||||
t.controlBuf.put(&earlyAbortStream{
|
||||
httpStatus: 200,
|
||||
httpStatus: http.StatusOK,
|
||||
streamID: s.id,
|
||||
contentSubtype: s.contentSubtype,
|
||||
status: stat,
|
||||
|
|
|
@ -30,34 +30,16 @@ import (
|
|||
"net/url"
|
||||
|
||||
"google.golang.org/grpc/internal"
|
||||
"google.golang.org/grpc/internal/proxyattributes"
|
||||
"google.golang.org/grpc/resolver"
|
||||
)
|
||||
|
||||
const proxyAuthHeaderKey = "Proxy-Authorization"
|
||||
|
||||
var (
|
||||
// The following variable will be overwritten in the tests.
|
||||
httpProxyFromEnvironment = http.ProxyFromEnvironment
|
||||
)
|
||||
|
||||
func mapAddress(address string) (*url.URL, error) {
|
||||
req := &http.Request{
|
||||
URL: &url.URL{
|
||||
Scheme: "https",
|
||||
Host: address,
|
||||
},
|
||||
}
|
||||
url, err := httpProxyFromEnvironment(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return url, nil
|
||||
}
|
||||
|
||||
// To read a response from a net.Conn, http.ReadResponse() takes a bufio.Reader.
|
||||
// It's possible that this reader reads more than what's need for the response and stores
|
||||
// those bytes in the buffer.
|
||||
// bufConn wraps the original net.Conn and the bufio.Reader to make sure we don't lose the
|
||||
// bytes in the buffer.
|
||||
// It's possible that this reader reads more than what's need for the response
|
||||
// and stores those bytes in the buffer. bufConn wraps the original net.Conn
|
||||
// and the bufio.Reader to make sure we don't lose the bytes in the buffer.
|
||||
type bufConn struct {
|
||||
net.Conn
|
||||
r io.Reader
|
||||
|
@ -72,7 +54,7 @@ func basicAuth(username, password string) string {
|
|||
return base64.StdEncoding.EncodeToString([]byte(auth))
|
||||
}
|
||||
|
||||
func doHTTPConnectHandshake(ctx context.Context, conn net.Conn, backendAddr string, proxyURL *url.URL, grpcUA string) (_ net.Conn, err error) {
|
||||
func doHTTPConnectHandshake(ctx context.Context, conn net.Conn, grpcUA string, opts proxyattributes.Options) (_ net.Conn, err error) {
|
||||
defer func() {
|
||||
if err != nil {
|
||||
conn.Close()
|
||||
|
@ -81,15 +63,14 @@ func doHTTPConnectHandshake(ctx context.Context, conn net.Conn, backendAddr stri
|
|||
|
||||
req := &http.Request{
|
||||
Method: http.MethodConnect,
|
||||
URL: &url.URL{Host: backendAddr},
|
||||
URL: &url.URL{Host: opts.ConnectAddr},
|
||||
Header: map[string][]string{"User-Agent": {grpcUA}},
|
||||
}
|
||||
if t := proxyURL.User; t != nil {
|
||||
u := t.Username()
|
||||
p, _ := t.Password()
|
||||
if user := opts.User; user != nil {
|
||||
u := user.Username()
|
||||
p, _ := user.Password()
|
||||
req.Header.Add(proxyAuthHeaderKey, "Basic "+basicAuth(u, p))
|
||||
}
|
||||
|
||||
if err := sendHTTPRequest(ctx, req, conn); err != nil {
|
||||
return nil, fmt.Errorf("failed to write the HTTP request: %v", err)
|
||||
}
|
||||
|
@ -117,28 +98,13 @@ func doHTTPConnectHandshake(ctx context.Context, conn net.Conn, backendAddr stri
|
|||
return conn, nil
|
||||
}
|
||||
|
||||
// proxyDial dials, connecting to a proxy first if necessary. Checks if a proxy
|
||||
// is necessary, dials, does the HTTP CONNECT handshake, and returns the
|
||||
// connection.
|
||||
func proxyDial(ctx context.Context, addr string, grpcUA string) (net.Conn, error) {
|
||||
newAddr := addr
|
||||
proxyURL, err := mapAddress(addr)
|
||||
// proxyDial establishes a TCP connection to the specified address and performs an HTTP CONNECT handshake.
|
||||
func proxyDial(ctx context.Context, addr resolver.Address, grpcUA string, opts proxyattributes.Options) (net.Conn, error) {
|
||||
conn, err := internal.NetDialerWithTCPKeepalive().DialContext(ctx, "tcp", addr.Addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if proxyURL != nil {
|
||||
newAddr = proxyURL.Host
|
||||
}
|
||||
|
||||
conn, err := internal.NetDialerWithTCPKeepalive().DialContext(ctx, "tcp", newAddr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if proxyURL == nil {
|
||||
// proxy is disabled if proxyURL is nil.
|
||||
return conn, err
|
||||
}
|
||||
return doHTTPConnectHandshake(ctx, conn, addr, proxyURL, grpcUA)
|
||||
return doHTTPConnectHandshake(ctx, conn, grpcUA, opts)
|
||||
}
|
||||
|
||||
func sendHTTPRequest(ctx context.Context, req *http.Request, conn net.Conn) error {
|
||||
|
|
|
@ -502,8 +502,6 @@ type ConnectOptions struct {
|
|||
ChannelzParent *channelz.SubChannel
|
||||
// MaxHeaderListSize sets the max (uncompressed) size of header list that is prepared to be received.
|
||||
MaxHeaderListSize *uint32
|
||||
// UseProxy specifies if a proxy should be used.
|
||||
UseProxy bool
|
||||
// The mem.BufferPool to use when reading/writing to the wire.
|
||||
BufferPool mem.BufferPool
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ func (pw *pickerWrapper) pick(ctx context.Context, failfast bool, info balancer.
|
|||
if lastPickErr != nil {
|
||||
errStr = "latest balancer error: " + lastPickErr.Error()
|
||||
} else {
|
||||
errStr = fmt.Sprintf("received context error while waiting for new LB policy update: %s", ctx.Err().Error())
|
||||
errStr = fmt.Sprintf("%v while waiting for connections to become ready", ctx.Err())
|
||||
}
|
||||
switch ctx.Err() {
|
||||
case context.DeadlineExceeded:
|
||||
|
|
|
@ -30,6 +30,7 @@ import (
|
|||
|
||||
"google.golang.org/grpc/attributes"
|
||||
"google.golang.org/grpc/credentials"
|
||||
"google.golang.org/grpc/experimental/stats"
|
||||
"google.golang.org/grpc/internal"
|
||||
"google.golang.org/grpc/serviceconfig"
|
||||
)
|
||||
|
@ -175,6 +176,8 @@ type BuildOptions struct {
|
|||
// Authority is the effective authority of the clientconn for which the
|
||||
// resolver is built.
|
||||
Authority string
|
||||
// MetricsRecorder is the metrics recorder to do recording.
|
||||
MetricsRecorder stats.MetricsRecorder
|
||||
}
|
||||
|
||||
// An Endpoint is one network endpoint, or server, which may have multiple
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
"google.golang.org/grpc/internal/channelz"
|
||||
"google.golang.org/grpc/internal/grpcsync"
|
||||
"google.golang.org/grpc/internal/pretty"
|
||||
"google.golang.org/grpc/internal/resolver/delegatingresolver"
|
||||
"google.golang.org/grpc/resolver"
|
||||
"google.golang.org/grpc/serviceconfig"
|
||||
)
|
||||
|
@ -76,9 +77,19 @@ func (ccr *ccResolverWrapper) start() error {
|
|||
CredsBundle: ccr.cc.dopts.copts.CredsBundle,
|
||||
Dialer: ccr.cc.dopts.copts.Dialer,
|
||||
Authority: ccr.cc.authority,
|
||||
MetricsRecorder: ccr.cc.metricsRecorderList,
|
||||
}
|
||||
var err error
|
||||
ccr.resolver, err = ccr.cc.resolverBuilder.Build(ccr.cc.parsedTarget, ccr, opts)
|
||||
// The delegating resolver is used unless:
|
||||
// - A custom dialer is provided via WithContextDialer dialoption or
|
||||
// - Proxy usage is disabled through WithNoProxy dialoption.
|
||||
// In these cases, the resolver is built based on the scheme of target,
|
||||
// using the appropriate resolver builder.
|
||||
if ccr.cc.dopts.copts.Dialer != nil || !ccr.cc.dopts.useProxy {
|
||||
ccr.resolver, err = ccr.cc.resolverBuilder.Build(ccr.cc.parsedTarget, ccr, opts)
|
||||
} else {
|
||||
ccr.resolver, err = delegatingresolver.New(ccr.cc.parsedTarget, ccr, opts, ccr.cc.resolverBuilder, ccr.cc.dopts.enableLocalDNSResolution)
|
||||
}
|
||||
errCh <- err
|
||||
})
|
||||
return <-errCh
|
||||
|
|
|
@ -151,7 +151,7 @@ func (d *gzipDecompressor) Type() string {
|
|||
|
||||
// callInfo contains all related configuration and information about an RPC.
|
||||
type callInfo struct {
|
||||
compressorType string
|
||||
compressorName string
|
||||
failFast bool
|
||||
maxReceiveMessageSize *int
|
||||
maxSendMessageSize *int
|
||||
|
@ -222,7 +222,7 @@ type HeaderCallOption struct {
|
|||
|
||||
func (o HeaderCallOption) before(*callInfo) error { return nil }
|
||||
func (o HeaderCallOption) after(_ *callInfo, attempt *csAttempt) {
|
||||
*o.HeaderAddr, _ = attempt.s.Header()
|
||||
*o.HeaderAddr, _ = attempt.transportStream.Header()
|
||||
}
|
||||
|
||||
// Trailer returns a CallOptions that retrieves the trailer metadata
|
||||
|
@ -244,7 +244,7 @@ type TrailerCallOption struct {
|
|||
|
||||
func (o TrailerCallOption) before(*callInfo) error { return nil }
|
||||
func (o TrailerCallOption) after(_ *callInfo, attempt *csAttempt) {
|
||||
*o.TrailerAddr = attempt.s.Trailer()
|
||||
*o.TrailerAddr = attempt.transportStream.Trailer()
|
||||
}
|
||||
|
||||
// Peer returns a CallOption that retrieves peer information for a unary RPC.
|
||||
|
@ -266,7 +266,7 @@ type PeerCallOption struct {
|
|||
|
||||
func (o PeerCallOption) before(*callInfo) error { return nil }
|
||||
func (o PeerCallOption) after(_ *callInfo, attempt *csAttempt) {
|
||||
if x, ok := peer.FromContext(attempt.s.Context()); ok {
|
||||
if x, ok := peer.FromContext(attempt.transportStream.Context()); ok {
|
||||
*o.PeerAddr = *x
|
||||
}
|
||||
}
|
||||
|
@ -435,7 +435,7 @@ type CompressorCallOption struct {
|
|||
}
|
||||
|
||||
func (o CompressorCallOption) before(c *callInfo) error {
|
||||
c.compressorType = o.CompressorType
|
||||
c.compressorName = o.CompressorType
|
||||
return nil
|
||||
}
|
||||
func (o CompressorCallOption) after(*callInfo, *csAttempt) {}
|
||||
|
@ -692,9 +692,9 @@ func encode(c baseCodec, msg any) (mem.BufferSlice, error) {
|
|||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "grpc: error while marshaling: %v", err.Error())
|
||||
}
|
||||
if uint(b.Len()) > math.MaxUint32 {
|
||||
if bufSize := uint(b.Len()); bufSize > math.MaxUint32 {
|
||||
b.Free()
|
||||
return nil, status.Errorf(codes.ResourceExhausted, "grpc: message too large (%d bytes)", len(b))
|
||||
return nil, status.Errorf(codes.ResourceExhausted, "grpc: message too large (%d bytes)", bufSize)
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
|
@ -828,30 +828,13 @@ func recvAndDecompress(p *parser, s recvCompressor, dc Decompressor, maxReceiveM
|
|||
return nil, st.Err()
|
||||
}
|
||||
|
||||
var size int
|
||||
if pf.isCompressed() {
|
||||
defer compressed.Free()
|
||||
|
||||
// To match legacy behavior, if the decompressor is set by WithDecompressor or RPCDecompressor,
|
||||
// use this decompressor as the default.
|
||||
if dc != nil {
|
||||
var uncompressedBuf []byte
|
||||
uncompressedBuf, err = dc.Do(compressed.Reader())
|
||||
if err == nil {
|
||||
out = mem.BufferSlice{mem.SliceBuffer(uncompressedBuf)}
|
||||
}
|
||||
size = len(uncompressedBuf)
|
||||
} else {
|
||||
out, size, err = decompress(compressor, compressed, maxReceiveMessageSize, p.bufferPool)
|
||||
}
|
||||
out, err = decompress(compressor, compressed, dc, maxReceiveMessageSize, p.bufferPool)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "grpc: failed to decompress the received message: %v", err)
|
||||
}
|
||||
if size > maxReceiveMessageSize {
|
||||
out.Free()
|
||||
// TODO: Revisit the error code. Currently keep it consistent with java
|
||||
// implementation.
|
||||
return nil, status.Errorf(codes.ResourceExhausted, "grpc: received message after decompression larger than max (%d vs. %d)", size, maxReceiveMessageSize)
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
out = compressed
|
||||
|
@ -866,20 +849,46 @@ func recvAndDecompress(p *parser, s recvCompressor, dc Decompressor, maxReceiveM
|
|||
return out, nil
|
||||
}
|
||||
|
||||
// Using compressor, decompress d, returning data and size.
|
||||
// Optionally, if data will be over maxReceiveMessageSize, just return the size.
|
||||
func decompress(compressor encoding.Compressor, d mem.BufferSlice, maxReceiveMessageSize int, pool mem.BufferPool) (mem.BufferSlice, int, error) {
|
||||
dcReader, err := compressor.Decompress(d.Reader())
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
// decompress processes the given data by decompressing it using either a custom decompressor or a standard compressor.
|
||||
// If a custom decompressor is provided, it takes precedence. The function validates that the decompressed data
|
||||
// does not exceed the specified maximum size and returns an error if this limit is exceeded.
|
||||
// On success, it returns the decompressed data. Otherwise, it returns an error if decompression fails or the data exceeds the size limit.
|
||||
func decompress(compressor encoding.Compressor, d mem.BufferSlice, dc Decompressor, maxReceiveMessageSize int, pool mem.BufferPool) (mem.BufferSlice, error) {
|
||||
if dc != nil {
|
||||
uncompressed, err := dc.Do(d.Reader())
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "grpc: failed to decompress the received message: %v", err)
|
||||
}
|
||||
if len(uncompressed) > maxReceiveMessageSize {
|
||||
return nil, status.Errorf(codes.ResourceExhausted, "grpc: message after decompression larger than max (%d vs. %d)", len(uncompressed), maxReceiveMessageSize)
|
||||
}
|
||||
return mem.BufferSlice{mem.SliceBuffer(uncompressed)}, nil
|
||||
}
|
||||
if compressor != nil {
|
||||
dcReader, err := compressor.Decompress(d.Reader())
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "grpc: failed to decompress the message: %v", err)
|
||||
}
|
||||
|
||||
out, err := mem.ReadAll(io.LimitReader(dcReader, int64(maxReceiveMessageSize)+1), pool)
|
||||
if err != nil {
|
||||
out.Free()
|
||||
return nil, 0, err
|
||||
out, err := mem.ReadAll(io.LimitReader(dcReader, int64(maxReceiveMessageSize)), pool)
|
||||
if err != nil {
|
||||
out.Free()
|
||||
return nil, status.Errorf(codes.Internal, "grpc: failed to read decompressed data: %v", err)
|
||||
}
|
||||
|
||||
if out.Len() == maxReceiveMessageSize && !atEOF(dcReader) {
|
||||
out.Free()
|
||||
return nil, status.Errorf(codes.ResourceExhausted, "grpc: received message after decompression larger than max %d", maxReceiveMessageSize)
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
return out, out.Len(), nil
|
||||
return nil, status.Errorf(codes.Internal, "grpc: no decompressor available for compressed payload")
|
||||
}
|
||||
|
||||
// atEOF reads data from r and returns true if zero bytes could be read and r.Read returns EOF.
|
||||
func atEOF(dcReader io.Reader) bool {
|
||||
n, err := dcReader.Read(make([]byte, 1))
|
||||
return n == 0 && err == io.EOF
|
||||
}
|
||||
|
||||
type recvCompressor interface {
|
||||
|
|
|
@ -37,12 +37,14 @@ import (
|
|||
"google.golang.org/grpc/credentials"
|
||||
"google.golang.org/grpc/encoding"
|
||||
"google.golang.org/grpc/encoding/proto"
|
||||
estats "google.golang.org/grpc/experimental/stats"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"google.golang.org/grpc/internal"
|
||||
"google.golang.org/grpc/internal/binarylog"
|
||||
"google.golang.org/grpc/internal/channelz"
|
||||
"google.golang.org/grpc/internal/grpcsync"
|
||||
"google.golang.org/grpc/internal/grpcutil"
|
||||
istats "google.golang.org/grpc/internal/stats"
|
||||
"google.golang.org/grpc/internal/transport"
|
||||
"google.golang.org/grpc/keepalive"
|
||||
"google.golang.org/grpc/mem"
|
||||
|
@ -82,6 +84,9 @@ func init() {
|
|||
internal.BinaryLogger = binaryLogger
|
||||
internal.JoinServerOptions = newJoinServerOption
|
||||
internal.BufferPool = bufferPool
|
||||
internal.MetricsRecorderForServer = func(srv *Server) estats.MetricsRecorder {
|
||||
return istats.NewMetricsRecorderList(srv.opts.statsHandlers)
|
||||
}
|
||||
}
|
||||
|
||||
var statusOK = status.New(codes.OK, "")
|
||||
|
@ -643,7 +648,7 @@ func (s *Server) serverWorker() {
|
|||
// connections to reduce the time spent overall on runtime.morestack.
|
||||
func (s *Server) initServerWorkers() {
|
||||
s.serverWorkerChannel = make(chan func())
|
||||
s.serverWorkerChannelClose = grpcsync.OnceFunc(func() {
|
||||
s.serverWorkerChannelClose = sync.OnceFunc(func() {
|
||||
close(s.serverWorkerChannel)
|
||||
})
|
||||
for i := uint32(0); i < s.opts.numServerWorkers; i++ {
|
||||
|
@ -1360,8 +1365,16 @@ func (s *Server) processUnaryRPC(ctx context.Context, stream *transport.ServerSt
|
|||
}
|
||||
return err
|
||||
}
|
||||
defer d.Free()
|
||||
freed := false
|
||||
dataFree := func() {
|
||||
if !freed {
|
||||
d.Free()
|
||||
freed = true
|
||||
}
|
||||
}
|
||||
defer dataFree()
|
||||
df := func(v any) error {
|
||||
defer dataFree()
|
||||
if err := s.getCodec(stream.ContentSubtype()).Unmarshal(d, v); err != nil {
|
||||
return status.Errorf(codes.Internal, "grpc: error unmarshalling request: %v", err)
|
||||
}
|
||||
|
@ -1637,10 +1650,10 @@ func (s *Server) processStreamingRPC(ctx context.Context, stream *transport.Serv
|
|||
// If dc is set and matches the stream's compression, use it. Otherwise, try
|
||||
// to find a matching registered compressor for decomp.
|
||||
if rc := stream.RecvCompress(); s.opts.dc != nil && s.opts.dc.Type() == rc {
|
||||
ss.dc = s.opts.dc
|
||||
ss.decompressorV0 = s.opts.dc
|
||||
} else if rc != "" && rc != encoding.Identity {
|
||||
ss.decomp = encoding.GetCompressor(rc)
|
||||
if ss.decomp == nil {
|
||||
ss.decompressorV1 = encoding.GetCompressor(rc)
|
||||
if ss.decompressorV1 == nil {
|
||||
st := status.Newf(codes.Unimplemented, "grpc: Decompressor is not installed for grpc-encoding %q", rc)
|
||||
ss.s.WriteStatus(st)
|
||||
return st.Err()
|
||||
|
@ -1652,12 +1665,12 @@ func (s *Server) processStreamingRPC(ctx context.Context, stream *transport.Serv
|
|||
//
|
||||
// NOTE: this needs to be ahead of all handling, https://github.com/grpc/grpc-go/issues/686.
|
||||
if s.opts.cp != nil {
|
||||
ss.cp = s.opts.cp
|
||||
ss.compressorV0 = s.opts.cp
|
||||
ss.sendCompressorName = s.opts.cp.Type()
|
||||
} else if rc := stream.RecvCompress(); rc != "" && rc != encoding.Identity {
|
||||
// Legacy compressor not specified; attempt to respond with same encoding.
|
||||
ss.comp = encoding.GetCompressor(rc)
|
||||
if ss.comp != nil {
|
||||
ss.compressorV1 = encoding.GetCompressor(rc)
|
||||
if ss.compressorV1 != nil {
|
||||
ss.sendCompressorName = rc
|
||||
}
|
||||
}
|
||||
|
@ -1668,7 +1681,7 @@ func (s *Server) processStreamingRPC(ctx context.Context, stream *transport.Serv
|
|||
}
|
||||
}
|
||||
|
||||
ss.ctx = newContextWithRPCInfo(ss.ctx, false, ss.codec, ss.cp, ss.comp)
|
||||
ss.ctx = newContextWithRPCInfo(ss.ctx, false, ss.codec, ss.compressorV0, ss.compressorV1)
|
||||
|
||||
if trInfo != nil {
|
||||
trInfo.tr.LazyLog(&trInfo.firstLine, false)
|
||||
|
@ -1922,7 +1935,7 @@ func (s *Server) stop(graceful bool) {
|
|||
s.conns = nil
|
||||
|
||||
if s.opts.numServerWorkers > 0 {
|
||||
// Closing the channel (only once, via grpcsync.OnceFunc) after all the
|
||||
// Closing the channel (only once, via sync.OnceFunc) after all the
|
||||
// connections have been closed above ensures that there are no
|
||||
// goroutines executing the callback passed to st.HandleStreams (where
|
||||
// the channel is written to).
|
||||
|
|
|
@ -268,18 +268,21 @@ func parseServiceConfig(js string, maxAttempts int) *serviceconfig.ParseResult {
|
|||
return &serviceconfig.ParseResult{Config: &sc}
|
||||
}
|
||||
|
||||
func isValidRetryPolicy(jrp *jsonRetryPolicy) bool {
|
||||
return jrp.MaxAttempts > 1 &&
|
||||
jrp.InitialBackoff > 0 &&
|
||||
jrp.MaxBackoff > 0 &&
|
||||
jrp.BackoffMultiplier > 0 &&
|
||||
len(jrp.RetryableStatusCodes) > 0
|
||||
}
|
||||
|
||||
func convertRetryPolicy(jrp *jsonRetryPolicy, maxAttempts int) (p *internalserviceconfig.RetryPolicy, err error) {
|
||||
if jrp == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
if jrp.MaxAttempts <= 1 ||
|
||||
jrp.InitialBackoff <= 0 ||
|
||||
jrp.MaxBackoff <= 0 ||
|
||||
jrp.BackoffMultiplier <= 0 ||
|
||||
len(jrp.RetryableStatusCodes) == 0 {
|
||||
logger.Warningf("grpc: ignoring retry policy %v due to illegal configuration", jrp)
|
||||
return nil, nil
|
||||
if !isValidRetryPolicy(jrp) {
|
||||
return nil, fmt.Errorf("invalid retry policy (%+v): ", jrp)
|
||||
}
|
||||
|
||||
if jrp.MaxAttempts < maxAttempts {
|
||||
|
|
|
@ -258,9 +258,9 @@ func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, meth
|
|||
}
|
||||
|
||||
func newClientStreamWithParams(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, mc serviceconfig.MethodConfig, onCommit, doneFunc func(), opts ...CallOption) (_ iresolver.ClientStream, err error) {
|
||||
c := defaultCallInfo()
|
||||
callInfo := defaultCallInfo()
|
||||
if mc.WaitForReady != nil {
|
||||
c.failFast = !*mc.WaitForReady
|
||||
callInfo.failFast = !*mc.WaitForReady
|
||||
}
|
||||
|
||||
// Possible context leak:
|
||||
|
@ -281,20 +281,20 @@ func newClientStreamWithParams(ctx context.Context, desc *StreamDesc, cc *Client
|
|||
}()
|
||||
|
||||
for _, o := range opts {
|
||||
if err := o.before(c); err != nil {
|
||||
if err := o.before(callInfo); err != nil {
|
||||
return nil, toRPCErr(err)
|
||||
}
|
||||
}
|
||||
c.maxSendMessageSize = getMaxSize(mc.MaxReqSize, c.maxSendMessageSize, defaultClientMaxSendMessageSize)
|
||||
c.maxReceiveMessageSize = getMaxSize(mc.MaxRespSize, c.maxReceiveMessageSize, defaultClientMaxReceiveMessageSize)
|
||||
if err := setCallInfoCodec(c); err != nil {
|
||||
callInfo.maxSendMessageSize = getMaxSize(mc.MaxReqSize, callInfo.maxSendMessageSize, defaultClientMaxSendMessageSize)
|
||||
callInfo.maxReceiveMessageSize = getMaxSize(mc.MaxRespSize, callInfo.maxReceiveMessageSize, defaultClientMaxReceiveMessageSize)
|
||||
if err := setCallInfoCodec(callInfo); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
callHdr := &transport.CallHdr{
|
||||
Host: cc.authority,
|
||||
Method: method,
|
||||
ContentSubtype: c.contentSubtype,
|
||||
ContentSubtype: callInfo.contentSubtype,
|
||||
DoneFunc: doneFunc,
|
||||
}
|
||||
|
||||
|
@ -302,22 +302,22 @@ func newClientStreamWithParams(ctx context.Context, desc *StreamDesc, cc *Client
|
|||
// set. In that case, also find the compressor from the encoding package.
|
||||
// Otherwise, use the compressor configured by the WithCompressor DialOption,
|
||||
// if set.
|
||||
var cp Compressor
|
||||
var comp encoding.Compressor
|
||||
if ct := c.compressorType; ct != "" {
|
||||
var compressorV0 Compressor
|
||||
var compressorV1 encoding.Compressor
|
||||
if ct := callInfo.compressorName; ct != "" {
|
||||
callHdr.SendCompress = ct
|
||||
if ct != encoding.Identity {
|
||||
comp = encoding.GetCompressor(ct)
|
||||
if comp == nil {
|
||||
compressorV1 = encoding.GetCompressor(ct)
|
||||
if compressorV1 == nil {
|
||||
return nil, status.Errorf(codes.Internal, "grpc: Compressor is not installed for requested grpc-encoding %q", ct)
|
||||
}
|
||||
}
|
||||
} else if cc.dopts.cp != nil {
|
||||
callHdr.SendCompress = cc.dopts.cp.Type()
|
||||
cp = cc.dopts.cp
|
||||
} else if cc.dopts.compressorV0 != nil {
|
||||
callHdr.SendCompress = cc.dopts.compressorV0.Type()
|
||||
compressorV0 = cc.dopts.compressorV0
|
||||
}
|
||||
if c.creds != nil {
|
||||
callHdr.Creds = c.creds
|
||||
if callInfo.creds != nil {
|
||||
callHdr.Creds = callInfo.creds
|
||||
}
|
||||
|
||||
cs := &clientStream{
|
||||
|
@ -325,12 +325,12 @@ func newClientStreamWithParams(ctx context.Context, desc *StreamDesc, cc *Client
|
|||
ctx: ctx,
|
||||
methodConfig: &mc,
|
||||
opts: opts,
|
||||
callInfo: c,
|
||||
callInfo: callInfo,
|
||||
cc: cc,
|
||||
desc: desc,
|
||||
codec: c.codec,
|
||||
cp: cp,
|
||||
comp: comp,
|
||||
codec: callInfo.codec,
|
||||
compressorV0: compressorV0,
|
||||
compressorV1: compressorV1,
|
||||
cancel: cancel,
|
||||
firstAttempt: true,
|
||||
onCommit: onCommit,
|
||||
|
@ -412,7 +412,7 @@ func (cs *clientStream) newAttemptLocked(isTransparent bool) (*csAttempt, error)
|
|||
return nil, ErrClientConnClosing
|
||||
}
|
||||
|
||||
ctx := newContextWithRPCInfo(cs.ctx, cs.callInfo.failFast, cs.callInfo.codec, cs.cp, cs.comp)
|
||||
ctx := newContextWithRPCInfo(cs.ctx, cs.callInfo.failFast, cs.callInfo.codec, cs.compressorV0, cs.compressorV1)
|
||||
method := cs.callHdr.Method
|
||||
var beginTime time.Time
|
||||
shs := cs.cc.dopts.copts.StatsHandlers
|
||||
|
@ -454,12 +454,12 @@ func (cs *clientStream) newAttemptLocked(isTransparent bool) (*csAttempt, error)
|
|||
}
|
||||
|
||||
return &csAttempt{
|
||||
ctx: ctx,
|
||||
beginTime: beginTime,
|
||||
cs: cs,
|
||||
dc: cs.cc.dopts.dc,
|
||||
statsHandlers: shs,
|
||||
trInfo: trInfo,
|
||||
ctx: ctx,
|
||||
beginTime: beginTime,
|
||||
cs: cs,
|
||||
decompressorV0: cs.cc.dopts.dc,
|
||||
statsHandlers: shs,
|
||||
trInfo: trInfo,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -467,7 +467,7 @@ func (a *csAttempt) getTransport() error {
|
|||
cs := a.cs
|
||||
|
||||
var err error
|
||||
a.t, a.pickResult, err = cs.cc.getTransport(a.ctx, cs.callInfo.failFast, cs.callHdr.Method)
|
||||
a.transport, a.pickResult, err = cs.cc.getTransport(a.ctx, cs.callInfo.failFast, cs.callHdr.Method)
|
||||
if err != nil {
|
||||
if de, ok := err.(dropError); ok {
|
||||
err = de.error
|
||||
|
@ -476,7 +476,7 @@ func (a *csAttempt) getTransport() error {
|
|||
return err
|
||||
}
|
||||
if a.trInfo != nil {
|
||||
a.trInfo.firstLine.SetRemoteAddr(a.t.RemoteAddr())
|
||||
a.trInfo.firstLine.SetRemoteAddr(a.transport.RemoteAddr())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -503,7 +503,7 @@ func (a *csAttempt) newStream() error {
|
|||
a.ctx = metadata.NewOutgoingContext(a.ctx, md)
|
||||
}
|
||||
|
||||
s, err := a.t.NewStream(a.ctx, cs.callHdr)
|
||||
s, err := a.transport.NewStream(a.ctx, cs.callHdr)
|
||||
if err != nil {
|
||||
nse, ok := err.(*transport.NewStreamError)
|
||||
if !ok {
|
||||
|
@ -518,9 +518,9 @@ func (a *csAttempt) newStream() error {
|
|||
// Unwrap and convert error.
|
||||
return toRPCErr(nse.Err)
|
||||
}
|
||||
a.s = s
|
||||
a.transportStream = s
|
||||
a.ctx = s.Context()
|
||||
a.p = &parser{r: s, bufferPool: a.cs.cc.dopts.copts.BufferPool}
|
||||
a.parser = &parser{r: s, bufferPool: a.cs.cc.dopts.copts.BufferPool}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -532,9 +532,9 @@ type clientStream struct {
|
|||
cc *ClientConn
|
||||
desc *StreamDesc
|
||||
|
||||
codec baseCodec
|
||||
cp Compressor
|
||||
comp encoding.Compressor
|
||||
codec baseCodec
|
||||
compressorV0 Compressor
|
||||
compressorV1 encoding.Compressor
|
||||
|
||||
cancel context.CancelFunc // cancels all attempts
|
||||
|
||||
|
@ -583,17 +583,17 @@ type replayOp struct {
|
|||
// csAttempt implements a single transport stream attempt within a
|
||||
// clientStream.
|
||||
type csAttempt struct {
|
||||
ctx context.Context
|
||||
cs *clientStream
|
||||
t transport.ClientTransport
|
||||
s *transport.ClientStream
|
||||
p *parser
|
||||
pickResult balancer.PickResult
|
||||
ctx context.Context
|
||||
cs *clientStream
|
||||
transport transport.ClientTransport
|
||||
transportStream *transport.ClientStream
|
||||
parser *parser
|
||||
pickResult balancer.PickResult
|
||||
|
||||
finished bool
|
||||
dc Decompressor
|
||||
decomp encoding.Compressor
|
||||
decompSet bool
|
||||
finished bool
|
||||
decompressorV0 Decompressor
|
||||
decompressorV1 encoding.Compressor
|
||||
decompressorSet bool
|
||||
|
||||
mu sync.Mutex // guards trInfo.tr
|
||||
// trInfo may be nil (if EnableTracing is false).
|
||||
|
@ -639,14 +639,14 @@ func (a *csAttempt) shouldRetry(err error) (bool, error) {
|
|||
// RPC is finished or committed or was dropped by the picker; cannot retry.
|
||||
return false, err
|
||||
}
|
||||
if a.s == nil && a.allowTransparentRetry {
|
||||
if a.transportStream == nil && a.allowTransparentRetry {
|
||||
return true, nil
|
||||
}
|
||||
// Wait for the trailers.
|
||||
unprocessed := false
|
||||
if a.s != nil {
|
||||
<-a.s.Done()
|
||||
unprocessed = a.s.Unprocessed()
|
||||
if a.transportStream != nil {
|
||||
<-a.transportStream.Done()
|
||||
unprocessed = a.transportStream.Unprocessed()
|
||||
}
|
||||
if cs.firstAttempt && unprocessed {
|
||||
// First attempt, stream unprocessed: transparently retry.
|
||||
|
@ -658,14 +658,14 @@ func (a *csAttempt) shouldRetry(err error) (bool, error) {
|
|||
|
||||
pushback := 0
|
||||
hasPushback := false
|
||||
if a.s != nil {
|
||||
if !a.s.TrailersOnly() {
|
||||
if a.transportStream != nil {
|
||||
if !a.transportStream.TrailersOnly() {
|
||||
return false, err
|
||||
}
|
||||
|
||||
// TODO(retry): Move down if the spec changes to not check server pushback
|
||||
// before considering this a failure for throttling.
|
||||
sps := a.s.Trailer()["grpc-retry-pushback-ms"]
|
||||
sps := a.transportStream.Trailer()["grpc-retry-pushback-ms"]
|
||||
if len(sps) == 1 {
|
||||
var e error
|
||||
if pushback, e = strconv.Atoi(sps[0]); e != nil || pushback < 0 {
|
||||
|
@ -682,8 +682,8 @@ func (a *csAttempt) shouldRetry(err error) (bool, error) {
|
|||
}
|
||||
|
||||
var code codes.Code
|
||||
if a.s != nil {
|
||||
code = a.s.Status().Code()
|
||||
if a.transportStream != nil {
|
||||
code = a.transportStream.Status().Code()
|
||||
} else {
|
||||
code = status.Code(err)
|
||||
}
|
||||
|
@ -756,8 +756,8 @@ func (cs *clientStream) Context() context.Context {
|
|||
cs.commitAttempt()
|
||||
// No need to lock before using attempt, since we know it is committed and
|
||||
// cannot change.
|
||||
if cs.attempt.s != nil {
|
||||
return cs.attempt.s.Context()
|
||||
if cs.attempt.transportStream != nil {
|
||||
return cs.attempt.transportStream.Context()
|
||||
}
|
||||
return cs.ctx
|
||||
}
|
||||
|
@ -794,9 +794,9 @@ func (cs *clientStream) withRetry(op func(a *csAttempt) error, onSuccess func())
|
|||
continue
|
||||
}
|
||||
if err == io.EOF {
|
||||
<-a.s.Done()
|
||||
<-a.transportStream.Done()
|
||||
}
|
||||
if err == nil || (err == io.EOF && a.s.Status().Code() == codes.OK) {
|
||||
if err == nil || (err == io.EOF && a.transportStream.Status().Code() == codes.OK) {
|
||||
onSuccess()
|
||||
cs.mu.Unlock()
|
||||
return err
|
||||
|
@ -812,7 +812,7 @@ func (cs *clientStream) Header() (metadata.MD, error) {
|
|||
var m metadata.MD
|
||||
err := cs.withRetry(func(a *csAttempt) error {
|
||||
var err error
|
||||
m, err = a.s.Header()
|
||||
m, err = a.transportStream.Header()
|
||||
return toRPCErr(err)
|
||||
}, cs.commitAttemptLocked)
|
||||
|
||||
|
@ -856,10 +856,10 @@ func (cs *clientStream) Trailer() metadata.MD {
|
|||
// directions -- it will prevent races and should not meaningfully impact
|
||||
// performance.
|
||||
cs.commitAttempt()
|
||||
if cs.attempt.s == nil {
|
||||
if cs.attempt.transportStream == nil {
|
||||
return nil
|
||||
}
|
||||
return cs.attempt.s.Trailer()
|
||||
return cs.attempt.transportStream.Trailer()
|
||||
}
|
||||
|
||||
func (cs *clientStream) replayBufferLocked(attempt *csAttempt) error {
|
||||
|
@ -904,7 +904,7 @@ func (cs *clientStream) SendMsg(m any) (err error) {
|
|||
}
|
||||
|
||||
// load hdr, payload, data
|
||||
hdr, data, payload, pf, err := prepareMsg(m, cs.codec, cs.cp, cs.comp, cs.cc.dopts.copts.BufferPool)
|
||||
hdr, data, payload, pf, err := prepareMsg(m, cs.codec, cs.compressorV0, cs.compressorV1, cs.cc.dopts.copts.BufferPool)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -992,7 +992,7 @@ func (cs *clientStream) CloseSend() error {
|
|||
}
|
||||
cs.sentLast = true
|
||||
op := func(a *csAttempt) error {
|
||||
a.s.Write(nil, nil, &transport.WriteOptions{Last: true})
|
||||
a.transportStream.Write(nil, nil, &transport.WriteOptions{Last: true})
|
||||
// Always return nil; io.EOF is the only error that might make sense
|
||||
// instead, but there is no need to signal the client to call RecvMsg
|
||||
// as the only use left for the stream after CloseSend is to call
|
||||
|
@ -1030,7 +1030,7 @@ func (cs *clientStream) finish(err error) {
|
|||
if cs.attempt != nil {
|
||||
cs.attempt.finish(err)
|
||||
// after functions all rely upon having a stream.
|
||||
if cs.attempt.s != nil {
|
||||
if cs.attempt.transportStream != nil {
|
||||
for _, o := range cs.opts {
|
||||
o.after(cs.callInfo, cs.attempt)
|
||||
}
|
||||
|
@ -1084,7 +1084,7 @@ func (a *csAttempt) sendMsg(m any, hdr []byte, payld mem.BufferSlice, dataLength
|
|||
}
|
||||
a.mu.Unlock()
|
||||
}
|
||||
if err := a.s.Write(hdr, payld, &transport.WriteOptions{Last: !cs.desc.ClientStreams}); err != nil {
|
||||
if err := a.transportStream.Write(hdr, payld, &transport.WriteOptions{Last: !cs.desc.ClientStreams}); err != nil {
|
||||
if !cs.desc.ClientStreams {
|
||||
// For non-client-streaming RPCs, we return nil instead of EOF on error
|
||||
// because the generated code requires it. finish is not called; RecvMsg()
|
||||
|
@ -1108,25 +1108,25 @@ func (a *csAttempt) recvMsg(m any, payInfo *payloadInfo) (err error) {
|
|||
defer payInfo.free()
|
||||
}
|
||||
|
||||
if !a.decompSet {
|
||||
if !a.decompressorSet {
|
||||
// Block until we receive headers containing received message encoding.
|
||||
if ct := a.s.RecvCompress(); ct != "" && ct != encoding.Identity {
|
||||
if a.dc == nil || a.dc.Type() != ct {
|
||||
if ct := a.transportStream.RecvCompress(); ct != "" && ct != encoding.Identity {
|
||||
if a.decompressorV0 == nil || a.decompressorV0.Type() != ct {
|
||||
// No configured decompressor, or it does not match the incoming
|
||||
// message encoding; attempt to find a registered compressor that does.
|
||||
a.dc = nil
|
||||
a.decomp = encoding.GetCompressor(ct)
|
||||
a.decompressorV0 = nil
|
||||
a.decompressorV1 = encoding.GetCompressor(ct)
|
||||
}
|
||||
} else {
|
||||
// No compression is used; disable our decompressor.
|
||||
a.dc = nil
|
||||
a.decompressorV0 = nil
|
||||
}
|
||||
// Only initialize this state once per stream.
|
||||
a.decompSet = true
|
||||
a.decompressorSet = true
|
||||
}
|
||||
if err := recv(a.p, cs.codec, a.s, a.dc, m, *cs.callInfo.maxReceiveMessageSize, payInfo, a.decomp, false); err != nil {
|
||||
if err := recv(a.parser, cs.codec, a.transportStream, a.decompressorV0, m, *cs.callInfo.maxReceiveMessageSize, payInfo, a.decompressorV1, false); err != nil {
|
||||
if err == io.EOF {
|
||||
if statusErr := a.s.Status().Err(); statusErr != nil {
|
||||
if statusErr := a.transportStream.Status().Err(); statusErr != nil {
|
||||
return statusErr
|
||||
}
|
||||
return io.EOF // indicates successful end of stream.
|
||||
|
@ -1157,8 +1157,8 @@ func (a *csAttempt) recvMsg(m any, payInfo *payloadInfo) (err error) {
|
|||
}
|
||||
// Special handling for non-server-stream rpcs.
|
||||
// This recv expects EOF or errors, so we don't collect inPayload.
|
||||
if err := recv(a.p, cs.codec, a.s, a.dc, m, *cs.callInfo.maxReceiveMessageSize, nil, a.decomp, false); err == io.EOF {
|
||||
return a.s.Status().Err() // non-server streaming Recv returns nil on success
|
||||
if err := recv(a.parser, cs.codec, a.transportStream, a.decompressorV0, m, *cs.callInfo.maxReceiveMessageSize, nil, a.decompressorV1, false); err == io.EOF {
|
||||
return a.transportStream.Status().Err() // non-server streaming Recv returns nil on success
|
||||
} else if err != nil {
|
||||
return toRPCErr(err)
|
||||
}
|
||||
|
@ -1177,20 +1177,20 @@ func (a *csAttempt) finish(err error) {
|
|||
err = nil
|
||||
}
|
||||
var tr metadata.MD
|
||||
if a.s != nil {
|
||||
a.s.Close(err)
|
||||
tr = a.s.Trailer()
|
||||
if a.transportStream != nil {
|
||||
a.transportStream.Close(err)
|
||||
tr = a.transportStream.Trailer()
|
||||
}
|
||||
|
||||
if a.pickResult.Done != nil {
|
||||
br := false
|
||||
if a.s != nil {
|
||||
br = a.s.BytesReceived()
|
||||
if a.transportStream != nil {
|
||||
br = a.transportStream.BytesReceived()
|
||||
}
|
||||
a.pickResult.Done(balancer.DoneInfo{
|
||||
Err: err,
|
||||
Trailer: tr,
|
||||
BytesSent: a.s != nil,
|
||||
BytesSent: a.transportStream != nil,
|
||||
BytesReceived: br,
|
||||
ServerLoad: balancerload.Parse(tr),
|
||||
})
|
||||
|
@ -1272,7 +1272,7 @@ func newNonRetryClientStream(ctx context.Context, desc *StreamDesc, method strin
|
|||
// if set.
|
||||
var cp Compressor
|
||||
var comp encoding.Compressor
|
||||
if ct := c.compressorType; ct != "" {
|
||||
if ct := c.compressorName; ct != "" {
|
||||
callHdr.SendCompress = ct
|
||||
if ct != encoding.Identity {
|
||||
comp = encoding.GetCompressor(ct)
|
||||
|
@ -1280,9 +1280,9 @@ func newNonRetryClientStream(ctx context.Context, desc *StreamDesc, method strin
|
|||
return nil, status.Errorf(codes.Internal, "grpc: Compressor is not installed for requested grpc-encoding %q", ct)
|
||||
}
|
||||
}
|
||||
} else if ac.cc.dopts.cp != nil {
|
||||
callHdr.SendCompress = ac.cc.dopts.cp.Type()
|
||||
cp = ac.cc.dopts.cp
|
||||
} else if ac.cc.dopts.compressorV0 != nil {
|
||||
callHdr.SendCompress = ac.cc.dopts.compressorV0.Type()
|
||||
cp = ac.cc.dopts.compressorV0
|
||||
}
|
||||
if c.creds != nil {
|
||||
callHdr.Creds = c.creds
|
||||
|
@ -1290,26 +1290,26 @@ func newNonRetryClientStream(ctx context.Context, desc *StreamDesc, method strin
|
|||
|
||||
// Use a special addrConnStream to avoid retry.
|
||||
as := &addrConnStream{
|
||||
callHdr: callHdr,
|
||||
ac: ac,
|
||||
ctx: ctx,
|
||||
cancel: cancel,
|
||||
opts: opts,
|
||||
callInfo: c,
|
||||
desc: desc,
|
||||
codec: c.codec,
|
||||
cp: cp,
|
||||
comp: comp,
|
||||
t: t,
|
||||
callHdr: callHdr,
|
||||
ac: ac,
|
||||
ctx: ctx,
|
||||
cancel: cancel,
|
||||
opts: opts,
|
||||
callInfo: c,
|
||||
desc: desc,
|
||||
codec: c.codec,
|
||||
sendCompressorV0: cp,
|
||||
sendCompressorV1: comp,
|
||||
transport: t,
|
||||
}
|
||||
|
||||
s, err := as.t.NewStream(as.ctx, as.callHdr)
|
||||
s, err := as.transport.NewStream(as.ctx, as.callHdr)
|
||||
if err != nil {
|
||||
err = toRPCErr(err)
|
||||
return nil, err
|
||||
}
|
||||
as.s = s
|
||||
as.p = &parser{r: s, bufferPool: ac.dopts.copts.BufferPool}
|
||||
as.transportStream = s
|
||||
as.parser = &parser{r: s, bufferPool: ac.dopts.copts.BufferPool}
|
||||
ac.incrCallsStarted()
|
||||
if desc != unaryStreamDesc {
|
||||
// Listen on stream context to cleanup when the stream context is
|
||||
|
@ -1335,29 +1335,31 @@ func newNonRetryClientStream(ctx context.Context, desc *StreamDesc, method strin
|
|||
}
|
||||
|
||||
type addrConnStream struct {
|
||||
s *transport.ClientStream
|
||||
ac *addrConn
|
||||
callHdr *transport.CallHdr
|
||||
cancel context.CancelFunc
|
||||
opts []CallOption
|
||||
callInfo *callInfo
|
||||
t transport.ClientTransport
|
||||
ctx context.Context
|
||||
sentLast bool
|
||||
desc *StreamDesc
|
||||
codec baseCodec
|
||||
cp Compressor
|
||||
comp encoding.Compressor
|
||||
decompSet bool
|
||||
dc Decompressor
|
||||
decomp encoding.Compressor
|
||||
p *parser
|
||||
mu sync.Mutex
|
||||
finished bool
|
||||
transportStream *transport.ClientStream
|
||||
ac *addrConn
|
||||
callHdr *transport.CallHdr
|
||||
cancel context.CancelFunc
|
||||
opts []CallOption
|
||||
callInfo *callInfo
|
||||
transport transport.ClientTransport
|
||||
ctx context.Context
|
||||
sentLast bool
|
||||
desc *StreamDesc
|
||||
codec baseCodec
|
||||
sendCompressorV0 Compressor
|
||||
sendCompressorV1 encoding.Compressor
|
||||
decompressorSet bool
|
||||
decompressorV0 Decompressor
|
||||
decompressorV1 encoding.Compressor
|
||||
parser *parser
|
||||
|
||||
// mu guards finished and is held for the entire finish method.
|
||||
mu sync.Mutex
|
||||
finished bool
|
||||
}
|
||||
|
||||
func (as *addrConnStream) Header() (metadata.MD, error) {
|
||||
m, err := as.s.Header()
|
||||
m, err := as.transportStream.Header()
|
||||
if err != nil {
|
||||
as.finish(toRPCErr(err))
|
||||
}
|
||||
|
@ -1365,7 +1367,7 @@ func (as *addrConnStream) Header() (metadata.MD, error) {
|
|||
}
|
||||
|
||||
func (as *addrConnStream) Trailer() metadata.MD {
|
||||
return as.s.Trailer()
|
||||
return as.transportStream.Trailer()
|
||||
}
|
||||
|
||||
func (as *addrConnStream) CloseSend() error {
|
||||
|
@ -1375,7 +1377,7 @@ func (as *addrConnStream) CloseSend() error {
|
|||
}
|
||||
as.sentLast = true
|
||||
|
||||
as.s.Write(nil, nil, &transport.WriteOptions{Last: true})
|
||||
as.transportStream.Write(nil, nil, &transport.WriteOptions{Last: true})
|
||||
// Always return nil; io.EOF is the only error that might make sense
|
||||
// instead, but there is no need to signal the client to call RecvMsg
|
||||
// as the only use left for the stream after CloseSend is to call
|
||||
|
@ -1384,7 +1386,7 @@ func (as *addrConnStream) CloseSend() error {
|
|||
}
|
||||
|
||||
func (as *addrConnStream) Context() context.Context {
|
||||
return as.s.Context()
|
||||
return as.transportStream.Context()
|
||||
}
|
||||
|
||||
func (as *addrConnStream) SendMsg(m any) (err error) {
|
||||
|
@ -1406,7 +1408,7 @@ func (as *addrConnStream) SendMsg(m any) (err error) {
|
|||
}
|
||||
|
||||
// load hdr, payload, data
|
||||
hdr, data, payload, pf, err := prepareMsg(m, as.codec, as.cp, as.comp, as.ac.dopts.copts.BufferPool)
|
||||
hdr, data, payload, pf, err := prepareMsg(m, as.codec, as.sendCompressorV0, as.sendCompressorV1, as.ac.dopts.copts.BufferPool)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -1425,7 +1427,7 @@ func (as *addrConnStream) SendMsg(m any) (err error) {
|
|||
return status.Errorf(codes.ResourceExhausted, "trying to send message larger than max (%d vs. %d)", payload.Len(), *as.callInfo.maxSendMessageSize)
|
||||
}
|
||||
|
||||
if err := as.s.Write(hdr, payload, &transport.WriteOptions{Last: !as.desc.ClientStreams}); err != nil {
|
||||
if err := as.transportStream.Write(hdr, payload, &transport.WriteOptions{Last: !as.desc.ClientStreams}); err != nil {
|
||||
if !as.desc.ClientStreams {
|
||||
// For non-client-streaming RPCs, we return nil instead of EOF on error
|
||||
// because the generated code requires it. finish is not called; RecvMsg()
|
||||
|
@ -1446,25 +1448,25 @@ func (as *addrConnStream) RecvMsg(m any) (err error) {
|
|||
}
|
||||
}()
|
||||
|
||||
if !as.decompSet {
|
||||
if !as.decompressorSet {
|
||||
// Block until we receive headers containing received message encoding.
|
||||
if ct := as.s.RecvCompress(); ct != "" && ct != encoding.Identity {
|
||||
if as.dc == nil || as.dc.Type() != ct {
|
||||
if ct := as.transportStream.RecvCompress(); ct != "" && ct != encoding.Identity {
|
||||
if as.decompressorV0 == nil || as.decompressorV0.Type() != ct {
|
||||
// No configured decompressor, or it does not match the incoming
|
||||
// message encoding; attempt to find a registered compressor that does.
|
||||
as.dc = nil
|
||||
as.decomp = encoding.GetCompressor(ct)
|
||||
as.decompressorV0 = nil
|
||||
as.decompressorV1 = encoding.GetCompressor(ct)
|
||||
}
|
||||
} else {
|
||||
// No compression is used; disable our decompressor.
|
||||
as.dc = nil
|
||||
as.decompressorV0 = nil
|
||||
}
|
||||
// Only initialize this state once per stream.
|
||||
as.decompSet = true
|
||||
as.decompressorSet = true
|
||||
}
|
||||
if err := recv(as.p, as.codec, as.s, as.dc, m, *as.callInfo.maxReceiveMessageSize, nil, as.decomp, false); err != nil {
|
||||
if err := recv(as.parser, as.codec, as.transportStream, as.decompressorV0, m, *as.callInfo.maxReceiveMessageSize, nil, as.decompressorV1, false); err != nil {
|
||||
if err == io.EOF {
|
||||
if statusErr := as.s.Status().Err(); statusErr != nil {
|
||||
if statusErr := as.transportStream.Status().Err(); statusErr != nil {
|
||||
return statusErr
|
||||
}
|
||||
return io.EOF // indicates successful end of stream.
|
||||
|
@ -1479,8 +1481,8 @@ func (as *addrConnStream) RecvMsg(m any) (err error) {
|
|||
|
||||
// Special handling for non-server-stream rpcs.
|
||||
// This recv expects EOF or errors, so we don't collect inPayload.
|
||||
if err := recv(as.p, as.codec, as.s, as.dc, m, *as.callInfo.maxReceiveMessageSize, nil, as.decomp, false); err == io.EOF {
|
||||
return as.s.Status().Err() // non-server streaming Recv returns nil on success
|
||||
if err := recv(as.parser, as.codec, as.transportStream, as.decompressorV0, m, *as.callInfo.maxReceiveMessageSize, nil, as.decompressorV1, false); err == io.EOF {
|
||||
return as.transportStream.Status().Err() // non-server streaming Recv returns nil on success
|
||||
} else if err != nil {
|
||||
return toRPCErr(err)
|
||||
}
|
||||
|
@ -1498,8 +1500,8 @@ func (as *addrConnStream) finish(err error) {
|
|||
// Ending a stream with EOF indicates a success.
|
||||
err = nil
|
||||
}
|
||||
if as.s != nil {
|
||||
as.s.Close(err)
|
||||
if as.transportStream != nil {
|
||||
as.transportStream.Close(err)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
@ -1570,10 +1572,10 @@ type serverStream struct {
|
|||
p *parser
|
||||
codec baseCodec
|
||||
|
||||
cp Compressor
|
||||
dc Decompressor
|
||||
comp encoding.Compressor
|
||||
decomp encoding.Compressor
|
||||
compressorV0 Compressor
|
||||
compressorV1 encoding.Compressor
|
||||
decompressorV0 Decompressor
|
||||
decompressorV1 encoding.Compressor
|
||||
|
||||
sendCompressorName string
|
||||
|
||||
|
@ -1669,12 +1671,12 @@ func (ss *serverStream) SendMsg(m any) (err error) {
|
|||
// Server handler could have set new compressor by calling SetSendCompressor.
|
||||
// In case it is set, we need to use it for compressing outbound message.
|
||||
if sendCompressorsName := ss.s.SendCompress(); sendCompressorsName != ss.sendCompressorName {
|
||||
ss.comp = encoding.GetCompressor(sendCompressorsName)
|
||||
ss.compressorV1 = encoding.GetCompressor(sendCompressorsName)
|
||||
ss.sendCompressorName = sendCompressorsName
|
||||
}
|
||||
|
||||
// load hdr, payload, data
|
||||
hdr, data, payload, pf, err := prepareMsg(m, ss.codec, ss.cp, ss.comp, ss.p.bufferPool)
|
||||
hdr, data, payload, pf, err := prepareMsg(m, ss.codec, ss.compressorV0, ss.compressorV1, ss.p.bufferPool)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -1755,7 +1757,7 @@ func (ss *serverStream) RecvMsg(m any) (err error) {
|
|||
payInfo = &payloadInfo{}
|
||||
defer payInfo.free()
|
||||
}
|
||||
if err := recv(ss.p, ss.codec, ss.s, ss.dc, m, ss.maxReceiveMessageSize, payInfo, ss.decomp, true); err != nil {
|
||||
if err := recv(ss.p, ss.codec, ss.s, ss.decompressorV0, m, ss.maxReceiveMessageSize, payInfo, ss.decompressorV1, true); err != nil {
|
||||
if err == io.EOF {
|
||||
if len(ss.binlogs) != 0 {
|
||||
chc := &binarylog.ClientHalfClose{}
|
||||
|
@ -1766,7 +1768,7 @@ func (ss *serverStream) RecvMsg(m any) (err error) {
|
|||
return err
|
||||
}
|
||||
if err == io.ErrUnexpectedEOF {
|
||||
err = status.Errorf(codes.Internal, io.ErrUnexpectedEOF.Error())
|
||||
err = status.Error(codes.Internal, io.ErrUnexpectedEOF.Error())
|
||||
}
|
||||
return toRPCErr(err)
|
||||
}
|
||||
|
|
|
@ -19,4 +19,4 @@
|
|||
package grpc
|
||||
|
||||
// Version is the current grpc version.
|
||||
const Version = "1.69.4"
|
||||
const Version = "1.71.0"
|
||||
|
|
|
@ -192,11 +192,6 @@ func (d decoder) unmarshalMessage(m protoreflect.Message, skipTypeURL bool) erro
|
|||
fd = fieldDescs.ByTextName(name)
|
||||
}
|
||||
}
|
||||
if flags.ProtoLegacyWeak {
|
||||
if fd != nil && fd.IsWeak() && fd.Message().IsPlaceholder() {
|
||||
fd = nil // reset since the weak reference is not linked in
|
||||
}
|
||||
}
|
||||
|
||||
if fd == nil {
|
||||
// Field is unknown.
|
||||
|
|
|
@ -185,11 +185,6 @@ func (d decoder) unmarshalMessage(m protoreflect.Message, checkDelims bool) erro
|
|||
} else if xtErr != nil && xtErr != protoregistry.NotFound {
|
||||
return d.newError(tok.Pos(), "unable to resolve [%s]: %v", tok.RawString(), xtErr)
|
||||
}
|
||||
if flags.ProtoLegacyWeak {
|
||||
if fd != nil && fd.IsWeak() && fd.Message().IsPlaceholder() {
|
||||
fd = nil // reset since the weak reference is not linked in
|
||||
}
|
||||
}
|
||||
|
||||
// Handle unknown fields.
|
||||
if fd == nil {
|
||||
|
|
|
@ -26,7 +26,7 @@ var byteType = reflect.TypeOf(byte(0))
|
|||
// The type is the underlying field type (e.g., a repeated field may be
|
||||
// represented by []T, but the Go type passed in is just T).
|
||||
// A list of enum value descriptors must be provided for enum fields.
|
||||
// This does not populate the Enum or Message (except for weak message).
|
||||
// This does not populate the Enum or Message.
|
||||
//
|
||||
// This function is a best effort attempt; parsing errors are ignored.
|
||||
func Unmarshal(tag string, goType reflect.Type, evs protoreflect.EnumValueDescriptors) protoreflect.FieldDescriptor {
|
||||
|
@ -109,9 +109,6 @@ func Unmarshal(tag string, goType reflect.Type, evs protoreflect.EnumValueDescri
|
|||
}
|
||||
case s == "packed":
|
||||
f.L1.EditionFeatures.IsPacked = true
|
||||
case strings.HasPrefix(s, "weak="):
|
||||
f.L1.IsWeak = true
|
||||
f.L1.Message = filedesc.PlaceholderMessage(protoreflect.FullName(s[len("weak="):]))
|
||||
case strings.HasPrefix(s, "def="):
|
||||
// The default tag is special in that everything afterwards is the
|
||||
// default regardless of the presence of commas.
|
||||
|
@ -183,9 +180,6 @@ func Marshal(fd protoreflect.FieldDescriptor, enumName string) string {
|
|||
// the exact same semantics from the previous generator.
|
||||
tag = append(tag, "json="+jsonName)
|
||||
}
|
||||
if fd.IsWeak() {
|
||||
tag = append(tag, "weak="+string(fd.Message().FullName()))
|
||||
}
|
||||
// The previous implementation does not tag extension fields as proto3,
|
||||
// even when the field is defined in a proto3 file. Match that behavior
|
||||
// for consistency.
|
||||
|
|
|
@ -19,7 +19,6 @@ import (
|
|||
"google.golang.org/protobuf/internal/pragma"
|
||||
"google.golang.org/protobuf/internal/strs"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
)
|
||||
|
||||
// Edition is an Enum for proto2.Edition
|
||||
|
@ -275,7 +274,6 @@ type (
|
|||
Kind protoreflect.Kind
|
||||
StringName stringName
|
||||
IsProto3Optional bool // promoted from google.protobuf.FieldDescriptorProto
|
||||
IsWeak bool // promoted from google.protobuf.FieldOptions
|
||||
IsLazy bool // promoted from google.protobuf.FieldOptions
|
||||
Default defaultValue
|
||||
ContainingOneof protoreflect.OneofDescriptor // must be consistent with Message.Oneofs.Fields
|
||||
|
@ -369,7 +367,7 @@ func (fd *Field) IsPacked() bool {
|
|||
return fd.L1.EditionFeatures.IsPacked
|
||||
}
|
||||
func (fd *Field) IsExtension() bool { return false }
|
||||
func (fd *Field) IsWeak() bool { return fd.L1.IsWeak }
|
||||
func (fd *Field) IsWeak() bool { return false }
|
||||
func (fd *Field) IsLazy() bool { return fd.L1.IsLazy }
|
||||
func (fd *Field) IsList() bool { return fd.Cardinality() == protoreflect.Repeated && !fd.IsMap() }
|
||||
func (fd *Field) IsMap() bool { return fd.Message() != nil && fd.Message().IsMapEntry() }
|
||||
|
@ -396,11 +394,6 @@ func (fd *Field) Enum() protoreflect.EnumDescriptor {
|
|||
return fd.L1.Enum
|
||||
}
|
||||
func (fd *Field) Message() protoreflect.MessageDescriptor {
|
||||
if fd.L1.IsWeak {
|
||||
if d, _ := protoregistry.GlobalFiles.FindDescriptorByName(fd.L1.Message.FullName()); d != nil {
|
||||
return d.(protoreflect.MessageDescriptor)
|
||||
}
|
||||
}
|
||||
return fd.L1.Message
|
||||
}
|
||||
func (fd *Field) IsMapEntry() bool {
|
||||
|
|
|
@ -32,11 +32,6 @@ func (file *File) resolveMessages() {
|
|||
for j := range md.L2.Fields.List {
|
||||
fd := &md.L2.Fields.List[j]
|
||||
|
||||
// Weak fields are resolved upon actual use.
|
||||
if fd.L1.IsWeak {
|
||||
continue
|
||||
}
|
||||
|
||||
// Resolve message field dependency.
|
||||
switch fd.L1.Kind {
|
||||
case protoreflect.EnumKind:
|
||||
|
@ -150,8 +145,6 @@ func (fd *File) unmarshalFull(b []byte) {
|
|||
switch num {
|
||||
case genid.FileDescriptorProto_PublicDependency_field_number:
|
||||
fd.L2.Imports[v].IsPublic = true
|
||||
case genid.FileDescriptorProto_WeakDependency_field_number:
|
||||
fd.L2.Imports[v].IsWeak = true
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
|
@ -502,8 +495,6 @@ func (fd *Field) unmarshalOptions(b []byte) {
|
|||
switch num {
|
||||
case genid.FieldOptions_Packed_field_number:
|
||||
fd.L1.EditionFeatures.IsPacked = protowire.DecodeBool(v)
|
||||
case genid.FieldOptions_Weak_field_number:
|
||||
fd.L1.IsWeak = protowire.DecodeBool(v)
|
||||
case genid.FieldOptions_Lazy_field_number:
|
||||
fd.L1.IsLazy = protowire.DecodeBool(v)
|
||||
case FieldOptions_EnforceUTF8:
|
||||
|
|
|
@ -63,7 +63,7 @@ type Builder struct {
|
|||
// message declarations in "flattened ordering".
|
||||
//
|
||||
// Dependencies are Go types for enums or messages referenced by
|
||||
// message fields (excluding weak fields), for parent extended messages of
|
||||
// message fields, for parent extended messages of
|
||||
// extension fields, for enums or messages referenced by extension fields,
|
||||
// and for input and output messages referenced by service methods.
|
||||
// Dependencies must come after declarations, but the ordering of
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
package flags
|
||||
|
||||
// ProtoLegacy specifies whether to enable support for legacy functionality
|
||||
// such as MessageSets, weak fields, and various other obscure behavior
|
||||
// such as MessageSets, and various other obscure behavior
|
||||
// that is necessary to maintain backwards compatibility with proto1 or
|
||||
// the pre-release variants of proto2 and proto3.
|
||||
//
|
||||
|
@ -22,8 +22,3 @@ const ProtoLegacy = protoLegacy
|
|||
// extension fields at unmarshal time, but defers creating the message
|
||||
// structure until the extension is first accessed.
|
||||
const LazyUnmarshalExtensions = ProtoLegacy
|
||||
|
||||
// ProtoLegacyWeak specifies whether to enable support for weak fields.
|
||||
// This flag was split out of ProtoLegacy in preparation for removing
|
||||
// support for weak fields (independent of the other protolegacy features).
|
||||
const ProtoLegacyWeak = ProtoLegacy
|
||||
|
|
|
@ -11,15 +11,10 @@ const (
|
|||
SizeCache_goname = "sizeCache"
|
||||
SizeCacheA_goname = "XXX_sizecache"
|
||||
|
||||
WeakFields_goname = "weakFields"
|
||||
WeakFieldsA_goname = "XXX_weak"
|
||||
|
||||
UnknownFields_goname = "unknownFields"
|
||||
UnknownFieldsA_goname = "XXX_unrecognized"
|
||||
|
||||
ExtensionFields_goname = "extensionFields"
|
||||
ExtensionFieldsA_goname = "XXX_InternalExtensions"
|
||||
ExtensionFieldsB_goname = "XXX_extensions"
|
||||
|
||||
WeakFieldPrefix_goname = "XXX_weak_"
|
||||
)
|
||||
|
|
|
@ -5,15 +5,12 @@
|
|||
package impl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sync"
|
||||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
"google.golang.org/protobuf/runtime/protoiface"
|
||||
)
|
||||
|
||||
|
@ -121,78 +118,6 @@ func (mi *MessageInfo) initOneofFieldCoders(od protoreflect.OneofDescriptor, si
|
|||
}
|
||||
}
|
||||
|
||||
func makeWeakMessageFieldCoder(fd protoreflect.FieldDescriptor) pointerCoderFuncs {
|
||||
var once sync.Once
|
||||
var messageType protoreflect.MessageType
|
||||
lazyInit := func() {
|
||||
once.Do(func() {
|
||||
messageName := fd.Message().FullName()
|
||||
messageType, _ = protoregistry.GlobalTypes.FindMessageByName(messageName)
|
||||
})
|
||||
}
|
||||
|
||||
return pointerCoderFuncs{
|
||||
size: func(p pointer, f *coderFieldInfo, opts marshalOptions) int {
|
||||
m, ok := p.WeakFields().get(f.num)
|
||||
if !ok {
|
||||
return 0
|
||||
}
|
||||
lazyInit()
|
||||
if messageType == nil {
|
||||
panic(fmt.Sprintf("weak message %v is not linked in", fd.Message().FullName()))
|
||||
}
|
||||
return sizeMessage(m, f.tagsize, opts)
|
||||
},
|
||||
marshal: func(b []byte, p pointer, f *coderFieldInfo, opts marshalOptions) ([]byte, error) {
|
||||
m, ok := p.WeakFields().get(f.num)
|
||||
if !ok {
|
||||
return b, nil
|
||||
}
|
||||
lazyInit()
|
||||
if messageType == nil {
|
||||
panic(fmt.Sprintf("weak message %v is not linked in", fd.Message().FullName()))
|
||||
}
|
||||
return appendMessage(b, m, f.wiretag, opts)
|
||||
},
|
||||
unmarshal: func(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (unmarshalOutput, error) {
|
||||
fs := p.WeakFields()
|
||||
m, ok := fs.get(f.num)
|
||||
if !ok {
|
||||
lazyInit()
|
||||
if messageType == nil {
|
||||
return unmarshalOutput{}, errUnknown
|
||||
}
|
||||
m = messageType.New().Interface()
|
||||
fs.set(f.num, m)
|
||||
}
|
||||
return consumeMessage(b, m, wtyp, opts)
|
||||
},
|
||||
isInit: func(p pointer, f *coderFieldInfo) error {
|
||||
m, ok := p.WeakFields().get(f.num)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return proto.CheckInitialized(m)
|
||||
},
|
||||
merge: func(dst, src pointer, f *coderFieldInfo, opts mergeOptions) {
|
||||
sm, ok := src.WeakFields().get(f.num)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
dm, ok := dst.WeakFields().get(f.num)
|
||||
if !ok {
|
||||
lazyInit()
|
||||
if messageType == nil {
|
||||
panic(fmt.Sprintf("weak message %v is not linked in", fd.Message().FullName()))
|
||||
}
|
||||
dm = messageType.New().Interface()
|
||||
dst.WeakFields().set(f.num, dm)
|
||||
}
|
||||
opts.Merge(dm, sm)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func makeMessageFieldCoder(fd protoreflect.FieldDescriptor, ft reflect.Type) pointerCoderFuncs {
|
||||
if mi := getMessageInfo(ft); mi != nil {
|
||||
funcs := pointerCoderFuncs{
|
||||
|
|
|
@ -119,9 +119,6 @@ func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
|
|||
}
|
||||
case isOneof:
|
||||
fieldOffset = offsetOf(fs)
|
||||
case fd.IsWeak():
|
||||
fieldOffset = si.weakOffset
|
||||
funcs = makeWeakMessageFieldCoder(fd)
|
||||
default:
|
||||
fieldOffset = offsetOf(fs)
|
||||
childMessage, funcs = fieldCoder(fd, ft)
|
||||
|
|
|
@ -46,9 +46,6 @@ func (mi *MessageInfo) makeOpaqueCoderMethods(t reflect.Type, si opaqueStructInf
|
|||
switch {
|
||||
case fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic():
|
||||
fieldOffset = offsetOf(fs)
|
||||
case fd.IsWeak():
|
||||
fieldOffset = si.weakOffset
|
||||
funcs = makeWeakMessageFieldCoder(fd)
|
||||
case fd.Message() != nil && !fd.IsMap():
|
||||
fieldOffset = offsetOf(fs)
|
||||
if fd.IsList() {
|
||||
|
|
|
@ -131,7 +131,7 @@ func (mi *MessageInfo) skipField(b []byte, f *coderFieldInfo, wtyp protowire.Typ
|
|||
fmi := f.validation.mi
|
||||
if fmi == nil {
|
||||
fd := mi.Desc.Fields().ByNumber(f.num)
|
||||
if fd == nil || !fd.IsWeak() {
|
||||
if fd == nil {
|
||||
return out, ValidationUnknown
|
||||
}
|
||||
messageName := fd.Message().FullName()
|
||||
|
|
|
@ -310,12 +310,9 @@ func aberrantAppendField(md *filedesc.Message, goType reflect.Type, tag, tagKey,
|
|||
fd.L0.Parent = md
|
||||
fd.L0.Index = n
|
||||
|
||||
if fd.L1.IsWeak || fd.L1.EditionFeatures.IsPacked {
|
||||
if fd.L1.EditionFeatures.IsPacked {
|
||||
fd.L1.Options = func() protoreflect.ProtoMessage {
|
||||
opts := descopts.Field.ProtoReflect().New()
|
||||
if fd.L1.IsWeak {
|
||||
opts.Set(opts.Descriptor().Fields().ByName("weak"), protoreflect.ValueOfBool(true))
|
||||
}
|
||||
if fd.L1.EditionFeatures.IsPacked {
|
||||
opts.Set(opts.Descriptor().Fields().ByName("packed"), protoreflect.ValueOfBool(fd.L1.EditionFeatures.IsPacked))
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ import (
|
|||
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
)
|
||||
|
||||
// MessageInfo provides protobuf related functionality for a given Go type
|
||||
|
@ -120,7 +119,6 @@ type (
|
|||
|
||||
var (
|
||||
sizecacheType = reflect.TypeOf(SizeCache(0))
|
||||
weakFieldsType = reflect.TypeOf(WeakFields(nil))
|
||||
unknownFieldsAType = reflect.TypeOf(unknownFieldsA(nil))
|
||||
unknownFieldsBType = reflect.TypeOf(unknownFieldsB(nil))
|
||||
extensionFieldsType = reflect.TypeOf(ExtensionFields(nil))
|
||||
|
@ -129,8 +127,6 @@ var (
|
|||
type structInfo struct {
|
||||
sizecacheOffset offset
|
||||
sizecacheType reflect.Type
|
||||
weakOffset offset
|
||||
weakType reflect.Type
|
||||
unknownOffset offset
|
||||
unknownType reflect.Type
|
||||
extensionOffset offset
|
||||
|
@ -148,7 +144,6 @@ type structInfo struct {
|
|||
func (mi *MessageInfo) makeStructInfo(t reflect.Type) structInfo {
|
||||
si := structInfo{
|
||||
sizecacheOffset: invalidOffset,
|
||||
weakOffset: invalidOffset,
|
||||
unknownOffset: invalidOffset,
|
||||
extensionOffset: invalidOffset,
|
||||
lazyOffset: invalidOffset,
|
||||
|
@ -168,11 +163,6 @@ fieldLoop:
|
|||
si.sizecacheOffset = offsetOf(f)
|
||||
si.sizecacheType = f.Type
|
||||
}
|
||||
case genid.WeakFields_goname, genid.WeakFieldsA_goname:
|
||||
if f.Type == weakFieldsType {
|
||||
si.weakOffset = offsetOf(f)
|
||||
si.weakType = f.Type
|
||||
}
|
||||
case genid.UnknownFields_goname, genid.UnknownFieldsA_goname:
|
||||
if f.Type == unknownFieldsAType || f.Type == unknownFieldsBType {
|
||||
si.unknownOffset = offsetOf(f)
|
||||
|
@ -256,9 +246,6 @@ func (mi *MessageInfo) Message(i int) protoreflect.MessageType {
|
|||
mi.init()
|
||||
fd := mi.Desc.Fields().Get(i)
|
||||
switch {
|
||||
case fd.IsWeak():
|
||||
mt, _ := protoregistry.GlobalTypes.FindMessageByName(fd.Message().FullName())
|
||||
return mt
|
||||
case fd.IsMap():
|
||||
return mapEntryType{fd.Message(), mi.fieldTypes[fd.Number()]}
|
||||
default:
|
||||
|
|
|
@ -56,9 +56,6 @@ func opaqueInitHook(mi *MessageInfo) bool {
|
|||
usePresence, _ := usePresenceForField(si, fd)
|
||||
|
||||
switch {
|
||||
case fd.IsWeak():
|
||||
// Weak fields are no different for opaque.
|
||||
fi = fieldInfoForWeakMessage(fd, si.weakOffset)
|
||||
case fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic():
|
||||
// Oneofs are no different for opaque.
|
||||
fi = fieldInfoForOneof(fd, si.oneofsByName[fd.ContainingOneof().Name()], mi.Exporter, si.oneofWrappersByNumber[fd.Number()])
|
||||
|
@ -620,8 +617,6 @@ func usePresenceForField(si opaqueStructInfo, fd protoreflect.FieldDescriptor) (
|
|||
switch {
|
||||
case fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic():
|
||||
return false, false
|
||||
case fd.IsWeak():
|
||||
return false, false
|
||||
case fd.IsMap():
|
||||
return false, false
|
||||
case fd.Kind() == protoreflect.MessageKind || fd.Kind() == protoreflect.GroupKind:
|
||||
|
|
|
@ -72,8 +72,6 @@ func (mi *MessageInfo) makeKnownFieldsFunc(si structInfo) {
|
|||
fi = fieldInfoForMap(fd, fs, mi.Exporter)
|
||||
case fd.IsList():
|
||||
fi = fieldInfoForList(fd, fs, mi.Exporter)
|
||||
case fd.IsWeak():
|
||||
fi = fieldInfoForWeakMessage(fd, si.weakOffset)
|
||||
case fd.Message() != nil:
|
||||
fi = fieldInfoForMessage(fd, fs, mi.Exporter)
|
||||
default:
|
||||
|
@ -219,9 +217,6 @@ func (mi *MessageInfo) makeFieldTypes(si structInfo) {
|
|||
}
|
||||
case fd.Message() != nil:
|
||||
ft = fs.Type
|
||||
if fd.IsWeak() {
|
||||
ft = nil
|
||||
}
|
||||
isMessage = true
|
||||
}
|
||||
if isMessage && ft != nil && ft.Kind() != reflect.Ptr {
|
||||
|
|
|
@ -8,11 +8,8 @@ import (
|
|||
"fmt"
|
||||
"math"
|
||||
"reflect"
|
||||
"sync"
|
||||
|
||||
"google.golang.org/protobuf/internal/flags"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
)
|
||||
|
||||
type fieldInfo struct {
|
||||
|
@ -332,79 +329,6 @@ func fieldInfoForScalar(fd protoreflect.FieldDescriptor, fs reflect.StructField,
|
|||
}
|
||||
}
|
||||
|
||||
func fieldInfoForWeakMessage(fd protoreflect.FieldDescriptor, weakOffset offset) fieldInfo {
|
||||
if !flags.ProtoLegacyWeak {
|
||||
panic("no support for proto1 weak fields")
|
||||
}
|
||||
|
||||
var once sync.Once
|
||||
var messageType protoreflect.MessageType
|
||||
lazyInit := func() {
|
||||
once.Do(func() {
|
||||
messageName := fd.Message().FullName()
|
||||
messageType, _ = protoregistry.GlobalTypes.FindMessageByName(messageName)
|
||||
if messageType == nil {
|
||||
panic(fmt.Sprintf("weak message %v for field %v is not linked in", messageName, fd.FullName()))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
num := fd.Number()
|
||||
return fieldInfo{
|
||||
fieldDesc: fd,
|
||||
has: func(p pointer) bool {
|
||||
if p.IsNil() {
|
||||
return false
|
||||
}
|
||||
_, ok := p.Apply(weakOffset).WeakFields().get(num)
|
||||
return ok
|
||||
},
|
||||
clear: func(p pointer) {
|
||||
p.Apply(weakOffset).WeakFields().clear(num)
|
||||
},
|
||||
get: func(p pointer) protoreflect.Value {
|
||||
lazyInit()
|
||||
if p.IsNil() {
|
||||
return protoreflect.ValueOfMessage(messageType.Zero())
|
||||
}
|
||||
m, ok := p.Apply(weakOffset).WeakFields().get(num)
|
||||
if !ok {
|
||||
return protoreflect.ValueOfMessage(messageType.Zero())
|
||||
}
|
||||
return protoreflect.ValueOfMessage(m.ProtoReflect())
|
||||
},
|
||||
set: func(p pointer, v protoreflect.Value) {
|
||||
lazyInit()
|
||||
m := v.Message()
|
||||
if m.Descriptor() != messageType.Descriptor() {
|
||||
if got, want := m.Descriptor().FullName(), messageType.Descriptor().FullName(); got != want {
|
||||
panic(fmt.Sprintf("field %v has mismatching message descriptor: got %v, want %v", fd.FullName(), got, want))
|
||||
}
|
||||
panic(fmt.Sprintf("field %v has mismatching message descriptor: %v", fd.FullName(), m.Descriptor().FullName()))
|
||||
}
|
||||
p.Apply(weakOffset).WeakFields().set(num, m.Interface())
|
||||
},
|
||||
mutable: func(p pointer) protoreflect.Value {
|
||||
lazyInit()
|
||||
fs := p.Apply(weakOffset).WeakFields()
|
||||
m, ok := fs.get(num)
|
||||
if !ok {
|
||||
m = messageType.New().Interface()
|
||||
fs.set(num, m)
|
||||
}
|
||||
return protoreflect.ValueOfMessage(m.ProtoReflect())
|
||||
},
|
||||
newMessage: func() protoreflect.Message {
|
||||
lazyInit()
|
||||
return messageType.New()
|
||||
},
|
||||
newField: func() protoreflect.Value {
|
||||
lazyInit()
|
||||
return protoreflect.ValueOfMessage(messageType.New())
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func fieldInfoForMessage(fd protoreflect.FieldDescriptor, fs reflect.StructField, x exporter) fieldInfo {
|
||||
ft := fs.Type
|
||||
conv := NewConverter(ft, fd)
|
||||
|
|
|
@ -111,7 +111,6 @@ func (p pointer) StringSlice() *[]string { return (*[]string)(p.p
|
|||
func (p pointer) Bytes() *[]byte { return (*[]byte)(p.p) }
|
||||
func (p pointer) BytesPtr() **[]byte { return (**[]byte)(p.p) }
|
||||
func (p pointer) BytesSlice() *[][]byte { return (*[][]byte)(p.p) }
|
||||
func (p pointer) WeakFields() *weakFields { return (*weakFields)(p.p) }
|
||||
func (p pointer) Extensions() *map[int32]ExtensionField { return (*map[int32]ExtensionField)(p.p) }
|
||||
func (p pointer) LazyInfoPtr() **protolazy.XXX_lazyUnmarshalInfo {
|
||||
return (**protolazy.XXX_lazyUnmarshalInfo)(p.p)
|
||||
|
|
|
@ -211,9 +211,7 @@ func newValidationInfo(fd protoreflect.FieldDescriptor, ft reflect.Type) validat
|
|||
switch fd.Kind() {
|
||||
case protoreflect.MessageKind:
|
||||
vi.typ = validationTypeMessage
|
||||
if !fd.IsWeak() {
|
||||
vi.mi = getMessageInfo(ft)
|
||||
}
|
||||
vi.mi = getMessageInfo(ft)
|
||||
case protoreflect.GroupKind:
|
||||
vi.typ = validationTypeGroup
|
||||
vi.mi = getMessageInfo(ft)
|
||||
|
@ -320,26 +318,6 @@ State:
|
|||
}
|
||||
if f != nil {
|
||||
vi = f.validation
|
||||
if vi.typ == validationTypeMessage && vi.mi == nil {
|
||||
// Probable weak field.
|
||||
//
|
||||
// TODO: Consider storing the results of this lookup somewhere
|
||||
// rather than recomputing it on every validation.
|
||||
fd := st.mi.Desc.Fields().ByNumber(num)
|
||||
if fd == nil || !fd.IsWeak() {
|
||||
break
|
||||
}
|
||||
messageName := fd.Message().FullName()
|
||||
messageType, err := protoregistry.GlobalTypes.FindMessageByName(messageName)
|
||||
switch err {
|
||||
case nil:
|
||||
vi.mi, _ = messageType.(*MessageInfo)
|
||||
case protoregistry.NotFound:
|
||||
vi.typ = validationTypeBytes
|
||||
default:
|
||||
return out, ValidationUnknown
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
// Possible extension field.
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package impl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
)
|
||||
|
||||
// weakFields adds methods to the exported WeakFields type for internal use.
|
||||
//
|
||||
// The exported type is an alias to an unnamed type, so methods can't be
|
||||
// defined directly on it.
|
||||
type weakFields WeakFields
|
||||
|
||||
func (w weakFields) get(num protoreflect.FieldNumber) (protoreflect.ProtoMessage, bool) {
|
||||
m, ok := w[int32(num)]
|
||||
return m, ok
|
||||
}
|
||||
|
||||
func (w *weakFields) set(num protoreflect.FieldNumber, m protoreflect.ProtoMessage) {
|
||||
if *w == nil {
|
||||
*w = make(weakFields)
|
||||
}
|
||||
(*w)[int32(num)] = m
|
||||
}
|
||||
|
||||
func (w *weakFields) clear(num protoreflect.FieldNumber) {
|
||||
delete(*w, int32(num))
|
||||
}
|
||||
|
||||
func (Export) HasWeak(w WeakFields, num protoreflect.FieldNumber) bool {
|
||||
_, ok := w[int32(num)]
|
||||
return ok
|
||||
}
|
||||
|
||||
func (Export) ClearWeak(w *WeakFields, num protoreflect.FieldNumber) {
|
||||
delete(*w, int32(num))
|
||||
}
|
||||
|
||||
func (Export) GetWeak(w WeakFields, num protoreflect.FieldNumber, name protoreflect.FullName) protoreflect.ProtoMessage {
|
||||
if m, ok := w[int32(num)]; ok {
|
||||
return m
|
||||
}
|
||||
mt, _ := protoregistry.GlobalTypes.FindMessageByName(name)
|
||||
if mt == nil {
|
||||
panic(fmt.Sprintf("message %v for weak field is not linked in", name))
|
||||
}
|
||||
return mt.Zero().Interface()
|
||||
}
|
||||
|
||||
func (Export) SetWeak(w *WeakFields, num protoreflect.FieldNumber, name protoreflect.FullName, m protoreflect.ProtoMessage) {
|
||||
if m != nil {
|
||||
mt, _ := protoregistry.GlobalTypes.FindMessageByName(name)
|
||||
if mt == nil {
|
||||
panic(fmt.Sprintf("message %v for weak field is not linked in", name))
|
||||
}
|
||||
if mt != m.ProtoReflect().Type() {
|
||||
panic(fmt.Sprintf("invalid message type for weak field: got %T, want %T", m, mt.Zero().Interface()))
|
||||
}
|
||||
}
|
||||
if m == nil || !m.ProtoReflect().IsValid() {
|
||||
delete(*w, int32(num))
|
||||
return
|
||||
}
|
||||
if *w == nil {
|
||||
*w = make(weakFields)
|
||||
}
|
||||
(*w)[int32(num)] = m
|
||||
}
|
|
@ -52,7 +52,7 @@ import (
|
|||
const (
|
||||
Major = 1
|
||||
Minor = 36
|
||||
Patch = 3
|
||||
Patch = 5
|
||||
PreRelease = ""
|
||||
)
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/encoding/messageset"
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/internal/flags"
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/internal/pragma"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
|
@ -172,10 +171,6 @@ func (o UnmarshalOptions) unmarshalMessageSlow(b []byte, m protoreflect.Message)
|
|||
var err error
|
||||
if fd == nil {
|
||||
err = errUnknown
|
||||
} else if flags.ProtoLegacyWeak {
|
||||
if fd.IsWeak() && fd.Message().IsPlaceholder() {
|
||||
err = errUnknown // weak referent is not linked in
|
||||
}
|
||||
}
|
||||
|
||||
// Parse the field value.
|
||||
|
|
|
@ -68,7 +68,7 @@ type Descriptor interface {
|
|||
// dependency is not resolved, in which case only name information is known.
|
||||
//
|
||||
// Placeholder types may only be returned by the following accessors
|
||||
// as a result of unresolved dependencies or weak imports:
|
||||
// as a result of unresolved dependencies:
|
||||
//
|
||||
// ╔═══════════════════════════════════╤═════════════════════╗
|
||||
// ║ Accessor │ Descriptor ║
|
||||
|
@ -168,11 +168,7 @@ type FileImport struct {
|
|||
// The current file and the imported file must be within proto package.
|
||||
IsPublic bool
|
||||
|
||||
// IsWeak reports whether this is a weak import, which does not impose
|
||||
// a direct dependency on the target file.
|
||||
//
|
||||
// Weak imports are a legacy proto1 feature. Equivalent behavior is
|
||||
// achieved using proto2 extension fields or proto3 Any messages.
|
||||
// Deprecated: support for weak fields has been removed.
|
||||
IsWeak bool
|
||||
}
|
||||
|
||||
|
@ -325,9 +321,7 @@ type FieldDescriptor interface {
|
|||
// specified in the source .proto file.
|
||||
HasOptionalKeyword() bool
|
||||
|
||||
// IsWeak reports whether this is a weak field, which does not impose a
|
||||
// direct dependency on the target type.
|
||||
// If true, then Message returns a placeholder type.
|
||||
// Deprecated: support for weak fields has been removed.
|
||||
IsWeak() bool
|
||||
|
||||
// IsPacked reports whether repeated primitive numeric kinds should be
|
||||
|
|
|
@ -122,6 +122,7 @@ import (
|
|||
reflect "reflect"
|
||||
strings "strings"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
// `Any` contains an arbitrary serialized protocol buffer message along with a
|
||||
|
@ -411,7 +412,7 @@ func (x *Any) GetValue() []byte {
|
|||
|
||||
var File_google_protobuf_any_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_google_protobuf_any_proto_rawDesc = []byte{
|
||||
var file_google_protobuf_any_proto_rawDesc = string([]byte{
|
||||
0x0a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
|
||||
0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x67, 0x6f, 0x6f,
|
||||
0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x22, 0x36, 0x0a, 0x03,
|
||||
|
@ -427,16 +428,16 @@ var file_google_protobuf_any_proto_rawDesc = []byte{
|
|||
0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x65,
|
||||
0x6c, 0x6c, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
})
|
||||
|
||||
var (
|
||||
file_google_protobuf_any_proto_rawDescOnce sync.Once
|
||||
file_google_protobuf_any_proto_rawDescData = file_google_protobuf_any_proto_rawDesc
|
||||
file_google_protobuf_any_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_google_protobuf_any_proto_rawDescGZIP() []byte {
|
||||
file_google_protobuf_any_proto_rawDescOnce.Do(func() {
|
||||
file_google_protobuf_any_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_protobuf_any_proto_rawDescData)
|
||||
file_google_protobuf_any_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_google_protobuf_any_proto_rawDesc), len(file_google_protobuf_any_proto_rawDesc)))
|
||||
})
|
||||
return file_google_protobuf_any_proto_rawDescData
|
||||
}
|
||||
|
@ -462,7 +463,7 @@ func file_google_protobuf_any_proto_init() {
|
|||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_google_protobuf_any_proto_rawDesc,
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_google_protobuf_any_proto_rawDesc), len(file_google_protobuf_any_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 1,
|
||||
NumExtensions: 0,
|
||||
|
@ -473,7 +474,6 @@ func file_google_protobuf_any_proto_init() {
|
|||
MessageInfos: file_google_protobuf_any_proto_msgTypes,
|
||||
}.Build()
|
||||
File_google_protobuf_any_proto = out.File
|
||||
file_google_protobuf_any_proto_rawDesc = nil
|
||||
file_google_protobuf_any_proto_goTypes = nil
|
||||
file_google_protobuf_any_proto_depIdxs = nil
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ import (
|
|||
reflect "reflect"
|
||||
sync "sync"
|
||||
time "time"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
// A Duration represents a signed, fixed-length span of time represented
|
||||
|
@ -288,7 +289,7 @@ func (x *Duration) GetNanos() int32 {
|
|||
|
||||
var File_google_protobuf_duration_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_google_protobuf_duration_proto_rawDesc = []byte{
|
||||
var file_google_protobuf_duration_proto_rawDesc = string([]byte{
|
||||
0x0a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
|
||||
0x66, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x12, 0x0f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
|
||||
|
@ -305,16 +306,16 @@ var file_google_protobuf_duration_proto_rawDesc = []byte{
|
|||
0x50, 0x42, 0xaa, 0x02, 0x1e, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x65, 0x6c, 0x6c, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x54, 0x79,
|
||||
0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
})
|
||||
|
||||
var (
|
||||
file_google_protobuf_duration_proto_rawDescOnce sync.Once
|
||||
file_google_protobuf_duration_proto_rawDescData = file_google_protobuf_duration_proto_rawDesc
|
||||
file_google_protobuf_duration_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_google_protobuf_duration_proto_rawDescGZIP() []byte {
|
||||
file_google_protobuf_duration_proto_rawDescOnce.Do(func() {
|
||||
file_google_protobuf_duration_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_protobuf_duration_proto_rawDescData)
|
||||
file_google_protobuf_duration_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_google_protobuf_duration_proto_rawDesc), len(file_google_protobuf_duration_proto_rawDesc)))
|
||||
})
|
||||
return file_google_protobuf_duration_proto_rawDescData
|
||||
}
|
||||
|
@ -340,7 +341,7 @@ func file_google_protobuf_duration_proto_init() {
|
|||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_google_protobuf_duration_proto_rawDesc,
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_google_protobuf_duration_proto_rawDesc), len(file_google_protobuf_duration_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 1,
|
||||
NumExtensions: 0,
|
||||
|
@ -351,7 +352,6 @@ func file_google_protobuf_duration_proto_init() {
|
|||
MessageInfos: file_google_protobuf_duration_proto_msgTypes,
|
||||
}.Build()
|
||||
File_google_protobuf_duration_proto = out.File
|
||||
file_google_protobuf_duration_proto_rawDesc = nil
|
||||
file_google_protobuf_duration_proto_goTypes = nil
|
||||
file_google_protobuf_duration_proto_depIdxs = nil
|
||||
}
|
||||
|
|
|
@ -83,6 +83,7 @@ import (
|
|||
sort "sort"
|
||||
strings "strings"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
// `FieldMask` represents a set of symbolic field paths, for example:
|
||||
|
@ -503,7 +504,7 @@ func (x *FieldMask) GetPaths() []string {
|
|||
|
||||
var File_google_protobuf_field_mask_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_google_protobuf_field_mask_proto_rawDesc = []byte{
|
||||
var file_google_protobuf_field_mask_proto_rawDesc = string([]byte{
|
||||
0x0a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
|
||||
0x66, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x2e, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x12, 0x0f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
|
@ -519,16 +520,16 @@ var file_google_protobuf_field_mask_proto_rawDesc = []byte{
|
|||
0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
|
||||
0x57, 0x65, 0x6c, 0x6c, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
})
|
||||
|
||||
var (
|
||||
file_google_protobuf_field_mask_proto_rawDescOnce sync.Once
|
||||
file_google_protobuf_field_mask_proto_rawDescData = file_google_protobuf_field_mask_proto_rawDesc
|
||||
file_google_protobuf_field_mask_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_google_protobuf_field_mask_proto_rawDescGZIP() []byte {
|
||||
file_google_protobuf_field_mask_proto_rawDescOnce.Do(func() {
|
||||
file_google_protobuf_field_mask_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_protobuf_field_mask_proto_rawDescData)
|
||||
file_google_protobuf_field_mask_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_google_protobuf_field_mask_proto_rawDesc), len(file_google_protobuf_field_mask_proto_rawDesc)))
|
||||
})
|
||||
return file_google_protobuf_field_mask_proto_rawDescData
|
||||
}
|
||||
|
@ -554,7 +555,7 @@ func file_google_protobuf_field_mask_proto_init() {
|
|||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_google_protobuf_field_mask_proto_rawDesc,
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_google_protobuf_field_mask_proto_rawDesc), len(file_google_protobuf_field_mask_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 1,
|
||||
NumExtensions: 0,
|
||||
|
@ -565,7 +566,6 @@ func file_google_protobuf_field_mask_proto_init() {
|
|||
MessageInfos: file_google_protobuf_field_mask_proto_msgTypes,
|
||||
}.Build()
|
||||
File_google_protobuf_field_mask_proto = out.File
|
||||
file_google_protobuf_field_mask_proto_rawDesc = nil
|
||||
file_google_protobuf_field_mask_proto_goTypes = nil
|
||||
file_google_protobuf_field_mask_proto_depIdxs = nil
|
||||
}
|
||||
|
|
|
@ -128,6 +128,7 @@ import (
|
|||
reflect "reflect"
|
||||
sync "sync"
|
||||
utf8 "unicode/utf8"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
// `NullValue` is a singleton enumeration to represent the null value for the
|
||||
|
@ -671,7 +672,7 @@ func (x *ListValue) GetValues() []*Value {
|
|||
|
||||
var File_google_protobuf_struct_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_google_protobuf_struct_proto_rawDesc = []byte{
|
||||
var file_google_protobuf_struct_proto_rawDesc = string([]byte{
|
||||
0x0a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
|
||||
0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f,
|
||||
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x22,
|
||||
|
@ -719,16 +720,16 @@ var file_google_protobuf_struct_proto_rawDesc = []byte{
|
|||
0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x65, 0x6c, 0x6c,
|
||||
0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x33,
|
||||
}
|
||||
})
|
||||
|
||||
var (
|
||||
file_google_protobuf_struct_proto_rawDescOnce sync.Once
|
||||
file_google_protobuf_struct_proto_rawDescData = file_google_protobuf_struct_proto_rawDesc
|
||||
file_google_protobuf_struct_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_google_protobuf_struct_proto_rawDescGZIP() []byte {
|
||||
file_google_protobuf_struct_proto_rawDescOnce.Do(func() {
|
||||
file_google_protobuf_struct_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_protobuf_struct_proto_rawDescData)
|
||||
file_google_protobuf_struct_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_google_protobuf_struct_proto_rawDesc), len(file_google_protobuf_struct_proto_rawDesc)))
|
||||
})
|
||||
return file_google_protobuf_struct_proto_rawDescData
|
||||
}
|
||||
|
@ -773,7 +774,7 @@ func file_google_protobuf_struct_proto_init() {
|
|||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_google_protobuf_struct_proto_rawDesc,
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_google_protobuf_struct_proto_rawDesc), len(file_google_protobuf_struct_proto_rawDesc)),
|
||||
NumEnums: 1,
|
||||
NumMessages: 4,
|
||||
NumExtensions: 0,
|
||||
|
@ -785,7 +786,6 @@ func file_google_protobuf_struct_proto_init() {
|
|||
MessageInfos: file_google_protobuf_struct_proto_msgTypes,
|
||||
}.Build()
|
||||
File_google_protobuf_struct_proto = out.File
|
||||
file_google_protobuf_struct_proto_rawDesc = nil
|
||||
file_google_protobuf_struct_proto_goTypes = nil
|
||||
file_google_protobuf_struct_proto_depIdxs = nil
|
||||
}
|
||||
|
|
|
@ -78,6 +78,7 @@ import (
|
|||
reflect "reflect"
|
||||
sync "sync"
|
||||
time "time"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
// A Timestamp represents a point in time independent of any time zone or local
|
||||
|
@ -297,7 +298,7 @@ func (x *Timestamp) GetNanos() int32 {
|
|||
|
||||
var File_google_protobuf_timestamp_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_google_protobuf_timestamp_proto_rawDesc = []byte{
|
||||
var file_google_protobuf_timestamp_proto_rawDesc = string([]byte{
|
||||
0x0a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
|
||||
0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x12, 0x0f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
|
||||
|
@ -314,16 +315,16 @@ var file_google_protobuf_timestamp_proto_rawDesc = []byte{
|
|||
0xa2, 0x02, 0x03, 0x47, 0x50, 0x42, 0xaa, 0x02, 0x1e, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
|
||||
0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x65, 0x6c, 0x6c, 0x4b, 0x6e, 0x6f,
|
||||
0x77, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
})
|
||||
|
||||
var (
|
||||
file_google_protobuf_timestamp_proto_rawDescOnce sync.Once
|
||||
file_google_protobuf_timestamp_proto_rawDescData = file_google_protobuf_timestamp_proto_rawDesc
|
||||
file_google_protobuf_timestamp_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_google_protobuf_timestamp_proto_rawDescGZIP() []byte {
|
||||
file_google_protobuf_timestamp_proto_rawDescOnce.Do(func() {
|
||||
file_google_protobuf_timestamp_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_protobuf_timestamp_proto_rawDescData)
|
||||
file_google_protobuf_timestamp_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_google_protobuf_timestamp_proto_rawDesc), len(file_google_protobuf_timestamp_proto_rawDesc)))
|
||||
})
|
||||
return file_google_protobuf_timestamp_proto_rawDescData
|
||||
}
|
||||
|
@ -349,7 +350,7 @@ func file_google_protobuf_timestamp_proto_init() {
|
|||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_google_protobuf_timestamp_proto_rawDesc,
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_google_protobuf_timestamp_proto_rawDesc), len(file_google_protobuf_timestamp_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 1,
|
||||
NumExtensions: 0,
|
||||
|
@ -360,7 +361,6 @@ func file_google_protobuf_timestamp_proto_init() {
|
|||
MessageInfos: file_google_protobuf_timestamp_proto_msgTypes,
|
||||
}.Build()
|
||||
File_google_protobuf_timestamp_proto = out.File
|
||||
file_google_protobuf_timestamp_proto_rawDesc = nil
|
||||
file_google_protobuf_timestamp_proto_goTypes = nil
|
||||
file_google_protobuf_timestamp_proto_depIdxs = nil
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ import (
|
|||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
// Wrapper message for `double`.
|
||||
|
@ -529,7 +530,7 @@ func (x *BytesValue) GetValue() []byte {
|
|||
|
||||
var File_google_protobuf_wrappers_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_google_protobuf_wrappers_proto_rawDesc = []byte{
|
||||
var file_google_protobuf_wrappers_proto_rawDesc = string([]byte{
|
||||
0x0a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
|
||||
0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x12, 0x0f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
|
||||
|
@ -563,16 +564,16 @@ var file_google_protobuf_wrappers_proto_rawDesc = []byte{
|
|||
0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
|
||||
0x57, 0x65, 0x6c, 0x6c, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
})
|
||||
|
||||
var (
|
||||
file_google_protobuf_wrappers_proto_rawDescOnce sync.Once
|
||||
file_google_protobuf_wrappers_proto_rawDescData = file_google_protobuf_wrappers_proto_rawDesc
|
||||
file_google_protobuf_wrappers_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_google_protobuf_wrappers_proto_rawDescGZIP() []byte {
|
||||
file_google_protobuf_wrappers_proto_rawDescOnce.Do(func() {
|
||||
file_google_protobuf_wrappers_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_protobuf_wrappers_proto_rawDescData)
|
||||
file_google_protobuf_wrappers_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_google_protobuf_wrappers_proto_rawDesc), len(file_google_protobuf_wrappers_proto_rawDesc)))
|
||||
})
|
||||
return file_google_protobuf_wrappers_proto_rawDescData
|
||||
}
|
||||
|
@ -606,7 +607,7 @@ func file_google_protobuf_wrappers_proto_init() {
|
|||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_google_protobuf_wrappers_proto_rawDesc,
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_google_protobuf_wrappers_proto_rawDesc), len(file_google_protobuf_wrappers_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 9,
|
||||
NumExtensions: 0,
|
||||
|
@ -617,7 +618,6 @@ func file_google_protobuf_wrappers_proto_init() {
|
|||
MessageInfos: file_google_protobuf_wrappers_proto_msgTypes,
|
||||
}.Build()
|
||||
File_google_protobuf_wrappers_proto = out.File
|
||||
file_google_protobuf_wrappers_proto_rawDesc = nil
|
||||
file_google_protobuf_wrappers_proto_goTypes = nil
|
||||
file_google_protobuf_wrappers_proto_depIdxs = nil
|
||||
}
|
||||
|
|
|
@ -555,8 +555,8 @@ github.com/gorilla/sessions
|
|||
# github.com/gorilla/websocket v1.5.3
|
||||
## explicit; go 1.12
|
||||
github.com/gorilla/websocket
|
||||
# github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1
|
||||
## explicit; go 1.22.0
|
||||
# github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1
|
||||
## explicit; go 1.22
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2/internal/httprule
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2/runtime
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2/utilities
|
||||
|
@ -973,7 +973,7 @@ go.mongodb.org/mongo-driver/x/bsonx/bsoncore
|
|||
## explicit; go 1.22.0
|
||||
go.opentelemetry.io/auto/sdk
|
||||
go.opentelemetry.io/auto/sdk/internal/telemetry
|
||||
# go.opentelemetry.io/otel v1.34.0
|
||||
# go.opentelemetry.io/otel v1.35.0
|
||||
## explicit; go 1.22.0
|
||||
go.opentelemetry.io/otel
|
||||
go.opentelemetry.io/otel/attribute
|
||||
|
@ -993,11 +993,11 @@ go.opentelemetry.io/otel/semconv/v1.20.0/httpconv
|
|||
go.opentelemetry.io/otel/semconv/v1.24.0
|
||||
go.opentelemetry.io/otel/semconv/v1.26.0
|
||||
go.opentelemetry.io/otel/semconv/v1.7.0
|
||||
# go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.34.0
|
||||
# go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.35.0
|
||||
## explicit; go 1.22.0
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform
|
||||
# go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.34.0
|
||||
# go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.35.0
|
||||
## explicit; go 1.22.0
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal
|
||||
|
@ -1014,12 +1014,12 @@ go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/retry
|
|||
# go.opentelemetry.io/otel/exporters/prometheus v0.56.0
|
||||
## explicit; go 1.22.0
|
||||
go.opentelemetry.io/otel/exporters/prometheus
|
||||
# go.opentelemetry.io/otel/metric v1.34.0
|
||||
# go.opentelemetry.io/otel/metric v1.35.0
|
||||
## explicit; go 1.22.0
|
||||
go.opentelemetry.io/otel/metric
|
||||
go.opentelemetry.io/otel/metric/embedded
|
||||
go.opentelemetry.io/otel/metric/noop
|
||||
# go.opentelemetry.io/otel/sdk v1.34.0
|
||||
# go.opentelemetry.io/otel/sdk v1.35.0
|
||||
## explicit; go 1.22.0
|
||||
go.opentelemetry.io/otel/sdk
|
||||
go.opentelemetry.io/otel/sdk/instrumentation
|
||||
|
@ -1035,10 +1035,11 @@ go.opentelemetry.io/otel/sdk/metric/internal
|
|||
go.opentelemetry.io/otel/sdk/metric/internal/aggregate
|
||||
go.opentelemetry.io/otel/sdk/metric/internal/x
|
||||
go.opentelemetry.io/otel/sdk/metric/metricdata
|
||||
# go.opentelemetry.io/otel/trace v1.34.0
|
||||
# go.opentelemetry.io/otel/trace v1.35.0
|
||||
## explicit; go 1.22.0
|
||||
go.opentelemetry.io/otel/trace
|
||||
go.opentelemetry.io/otel/trace/embedded
|
||||
go.opentelemetry.io/otel/trace/internal/telemetry
|
||||
go.opentelemetry.io/otel/trace/noop
|
||||
# go.opentelemetry.io/proto/otlp v1.5.0
|
||||
## explicit; go 1.22.0
|
||||
|
@ -1175,20 +1176,21 @@ golang.org/x/tools/internal/stdlib
|
|||
golang.org/x/tools/internal/typeparams
|
||||
golang.org/x/tools/internal/typesinternal
|
||||
golang.org/x/tools/internal/versions
|
||||
# google.golang.org/genproto/googleapis/api v0.0.0-20250115164207-1a7da9e5054f
|
||||
# google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a
|
||||
## explicit; go 1.22
|
||||
google.golang.org/genproto/googleapis/api/httpbody
|
||||
# google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f
|
||||
# google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a
|
||||
## explicit; go 1.22
|
||||
google.golang.org/genproto/googleapis/rpc/errdetails
|
||||
google.golang.org/genproto/googleapis/rpc/status
|
||||
# google.golang.org/grpc v1.69.4
|
||||
## explicit; go 1.22
|
||||
# google.golang.org/grpc v1.71.0
|
||||
## explicit; go 1.22.0
|
||||
google.golang.org/grpc
|
||||
google.golang.org/grpc/attributes
|
||||
google.golang.org/grpc/backoff
|
||||
google.golang.org/grpc/balancer
|
||||
google.golang.org/grpc/balancer/base
|
||||
google.golang.org/grpc/balancer/endpointsharding
|
||||
google.golang.org/grpc/balancer/grpclb/state
|
||||
google.golang.org/grpc/balancer/pickfirst
|
||||
google.golang.org/grpc/balancer/pickfirst/internal
|
||||
|
@ -1222,7 +1224,9 @@ google.golang.org/grpc/internal/grpcutil
|
|||
google.golang.org/grpc/internal/idle
|
||||
google.golang.org/grpc/internal/metadata
|
||||
google.golang.org/grpc/internal/pretty
|
||||
google.golang.org/grpc/internal/proxyattributes
|
||||
google.golang.org/grpc/internal/resolver
|
||||
google.golang.org/grpc/internal/resolver/delegatingresolver
|
||||
google.golang.org/grpc/internal/resolver/dns
|
||||
google.golang.org/grpc/internal/resolver/dns/internal
|
||||
google.golang.org/grpc/internal/resolver/passthrough
|
||||
|
@ -1243,7 +1247,7 @@ google.golang.org/grpc/serviceconfig
|
|||
google.golang.org/grpc/stats
|
||||
google.golang.org/grpc/status
|
||||
google.golang.org/grpc/tap
|
||||
# google.golang.org/protobuf v1.36.3
|
||||
# google.golang.org/protobuf v1.36.5
|
||||
## explicit; go 1.21
|
||||
google.golang.org/protobuf/encoding/protodelim
|
||||
google.golang.org/protobuf/encoding/protojson
|
||||
|
|
Loading…
Reference in New Issue