build(deps): bump go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp

Bumps [go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp](https://github.com/open-telemetry/opentelemetry-go-contrib) from 0.63.0 to 0.64.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go-contrib/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go-contrib/compare/zpages/v0.63.0...zpages/v0.64.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp
  dependency-version: 0.64.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot]
2026-01-13 07:40:16 +00:00
committed by Ralf Haferkamp
parent b7ab1b1f40
commit beab7ce18c
16 changed files with 749 additions and 1422 deletions
-28
View File
@@ -1,28 +0,0 @@
// Copyright 2018-2021 CERN
//
// 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.
//
// In applying this license, CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
package ocdav
import (
// initialize reva registries by importing the relevant loader packages
// see cmd/revad/runtime/loader.go for other loaders if a service is not found
_ "github.com/opencloud-eu/reva/v2/internal/http/interceptors/auth/credential/loader"
_ "github.com/opencloud-eu/reva/v2/internal/http/interceptors/auth/token/loader"
_ "github.com/opencloud-eu/reva/v2/internal/http/interceptors/auth/tokenwriter/loader"
_ "github.com/opencloud-eu/reva/v2/pkg/token/manager/loader"
)
-376
View File
@@ -1,376 +0,0 @@
// Copyright 2018-2021 CERN
//
// 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.
//
// In applying this license, CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
package ocdav
import (
"context"
"crypto/tls"
"time"
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
"github.com/opencloud-eu/reva/v2/internal/http/services/owncloud/ocdav"
"github.com/opencloud-eu/reva/v2/internal/http/services/owncloud/ocdav/config"
"github.com/opencloud-eu/reva/v2/pkg/rgrpc/todo/pool"
"github.com/opencloud-eu/reva/v2/pkg/storage/favorite"
"github.com/rs/zerolog"
"go-micro.dev/v4/broker"
"go.opentelemetry.io/otel/trace"
)
// Option defines a single option function.
type Option func(o *Options)
// Options defines the available options for this package.
type Options struct {
TLSConfig *tls.Config
Broker broker.Broker
Address string
Logger zerolog.Logger
Context context.Context
// Metrics *metrics.Metrics
// Flags []cli.Flag
Name string
JWTSecret string
FavoriteManager favorite.Manager
GatewaySelector pool.Selectable[gateway.GatewayAPIClient]
TracesExporter string
TraceProvider trace.TracerProvider
MetricsEnabled bool
MetricsNamespace string
MetricsSubsystem string
// ocdav.* is internal so we need to set config options individually
config config.Config
lockSystem ocdav.LockSystem
AllowCredentials bool
AllowedOrigins []string
AllowedHeaders []string
AllowedMethods []string
AllowDepthInfinity bool
RegisterTTL time.Duration
RegisterInterval time.Duration
}
// newOptions initializes the available default options.
func newOptions(opts ...Option) Options {
opt := Options{}
for _, o := range opts {
o(&opt)
}
return opt
}
// TLSConfig provides a function to set the TLSConfig option.
func TLSConfig(config *tls.Config) Option {
return func(o *Options) {
o.TLSConfig = config
}
}
// Broker provides a function to set the Broker option.
func Broker(b broker.Broker) Option {
return func(o *Options) {
o.Broker = b
}
}
// Address provides a function to set the address option.
func Address(val string) Option {
return func(o *Options) {
o.Address = val
}
}
func AllowDepthInfinity(val bool) Option {
return func(o *Options) {
o.AllowDepthInfinity = val
}
}
// JWTSecret provides a function to set the jwt secret option.
func JWTSecret(s string) Option {
return func(o *Options) {
o.JWTSecret = s
}
}
// MachineAuthAPIKey provides a function to set the machine auth api key option.
func MachineAuthAPIKey(s string) Option {
return func(o *Options) {
o.config.MachineAuthAPIKey = s
}
}
// Context provides a function to set the context option.
func Context(val context.Context) Option {
return func(o *Options) {
o.Context = val
}
}
// Logger provides a function to set the logger option.
func Logger(val zerolog.Logger) Option {
return func(o *Options) {
o.Logger = val
}
}
// Name provides a function to set the Name option.
func Name(val string) Option {
return func(o *Options) {
o.Name = val
}
}
// Prefix provides a function to set the prefix config option.
func Prefix(val string) Option {
return func(o *Options) {
o.config.Prefix = val
}
}
// FilesNamespace provides a function to set the FilesNamespace config option.
func FilesNamespace(val string) Option {
return func(o *Options) {
o.config.FilesNamespace = val
}
}
// WebdavNamespace provides a function to set the WebdavNamespace config option.
func WebdavNamespace(val string) Option {
return func(o *Options) {
o.config.WebdavNamespace = val
}
}
// SharesNamespace provides a function to set the SharesNamespace config option.
func SharesNamespace(val string) Option {
return func(o *Options) {
o.config.SharesNamespace = val
}
}
// OCMNamespace provides a function to set the OCMNamespace config option.
func OCMNamespace(val string) Option {
return func(o *Options) {
o.config.OCMNamespace = val
}
}
// GatewaySvc provides a function to set the GatewaySvc config option.
func GatewaySvc(val string) Option {
return func(o *Options) {
o.config.GatewaySvc = val
}
}
// Timeout provides a function to set the Timeout config option.
func Timeout(val int64) Option {
return func(o *Options) {
o.config.Timeout = val
}
}
// Insecure provides a function to set the Insecure config option.
func Insecure(val bool) Option {
return func(o *Options) {
o.config.Insecure = val
}
}
// PublicURL provides a function to set the PublicURL config option.
func PublicURL(val string) Option {
return func(o *Options) {
o.config.PublicURL = val
}
}
// FavoriteManager provides a function to set the FavoriteManager option.
func FavoriteManager(val favorite.Manager) Option {
return func(o *Options) {
o.FavoriteManager = val
}
}
// GatewaySelector provides a function to set the GatewaySelector option.
func GatewaySelector(val pool.Selectable[gateway.GatewayAPIClient]) Option {
return func(o *Options) {
o.GatewaySelector = val
}
}
// LockSystem provides a function to set the LockSystem option.
func LockSystem(val ocdav.LockSystem) Option {
return func(o *Options) {
o.lockSystem = val
}
}
// WithTracesExporter option
func WithTracesExporter(exporter string) Option {
return func(o *Options) {
o.TracesExporter = exporter
}
}
// WithTracingExporter option
// Deprecated: unused
func WithTracingExporter(exporter string) Option {
return func(o *Options) {}
}
// WithTraceProvider option
func WithTraceProvider(provider trace.TracerProvider) Option {
return func(o *Options) {
o.TraceProvider = provider
}
}
// Version provides a function to set the Version config option.
func Version(val string) Option {
return func(o *Options) {
o.config.Version = val
}
}
// VersionString provides a function to set the VersionString config option.
func VersionString(val string) Option {
return func(o *Options) {
o.config.VersionString = val
}
}
// Edition provides a function to set the Edition config option.
func Edition(val string) Option {
return func(o *Options) {
o.config.Edition = val
}
}
// Product provides a function to set the Product config option.
func Product(val string) Option {
return func(o *Options) {
o.config.Product = val
}
}
// ProductName provides a function to set the ProductName config option.
func ProductName(val string) Option {
return func(o *Options) {
o.config.ProductName = val
}
}
// ProductVersion provides a function to set the ProductVersion config option.
func ProductVersion(val string) Option {
return func(o *Options) {
o.config.ProductVersion = val
}
}
// MetricsEnabled provides a function to set the MetricsEnabled config option.
func MetricsEnabled(val bool) Option {
return func(o *Options) {
o.MetricsEnabled = val
}
}
// MetricsNamespace provides a function to set the MetricsNamespace config option.
func MetricsNamespace(val string) Option {
return func(o *Options) {
o.MetricsNamespace = val
}
}
// MetricsSubsystem provides a function to set the MetricsSubsystem config option.
func MetricsSubsystem(val string) Option {
return func(o *Options) {
o.MetricsSubsystem = val
}
}
// AllowCredentials provides a function to set the AllowCredentials option.
func AllowCredentials(val bool) Option {
return func(o *Options) {
o.AllowCredentials = val
}
}
// AllowedOrigins provides a function to set the AllowedOrigins option.
func AllowedOrigins(val []string) Option {
return func(o *Options) {
o.AllowedOrigins = val
}
}
// AllowedMethods provides a function to set the AllowedMethods option.
func AllowedMethods(val []string) Option {
return func(o *Options) {
o.AllowedMethods = val
}
}
// AllowedHeaders provides a function to set the AllowedHeaders option.
func AllowedHeaders(val []string) Option {
return func(o *Options) {
o.AllowedHeaders = val
}
}
// ItemNameInvalidChars provides a function to set forbidden characters in file or folder names
func ItemNameInvalidChars(chars []string) Option {
return func(o *Options) {
o.config.NameValidation.InvalidChars = chars
}
}
// ItemNameMaxLength provides a function to set the maximum length of a file or folder name
func ItemNameMaxLength(i int) Option {
return func(o *Options) {
o.config.NameValidation.MaxLength = i
}
}
// RegisterTTL provides a function to set the RegisterTTL option.
func RegisterTTL(ttl time.Duration) Option {
return func(o *Options) {
o.RegisterTTL = ttl
}
}
// RegisterInterval provides a function to set the RegisterInterval option.
func RegisterInterval(interval time.Duration) Option {
return func(o *Options) {
o.RegisterInterval = interval
}
}
// URLSigningSharedSecret provides a function to set the URLSigningSharedSecret config option.
func URLSigningSharedSecret(secret string) Option {
return func(o *Options) {
o.config.URLSigningSharedSecret = secret
}
}
-229
View File
@@ -1,229 +0,0 @@
// Copyright 2018-2021 CERN
//
// 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.
//
// In applying this license, CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
package ocdav
import (
"net/http"
"strings"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
httpServer "github.com/go-micro/plugins/v4/server/http"
"github.com/opencloud-eu/opencloud/pkg/registry"
"github.com/opencloud-eu/reva/v2/internal/http/interceptors/appctx"
"github.com/opencloud-eu/reva/v2/internal/http/interceptors/auth"
cors2 "github.com/opencloud-eu/reva/v2/internal/http/interceptors/cors"
revaLogMiddleware "github.com/opencloud-eu/reva/v2/internal/http/interceptors/log"
"github.com/opencloud-eu/reva/v2/internal/http/services/owncloud/ocdav"
"github.com/opencloud-eu/reva/v2/pkg/rgrpc/todo/pool"
"github.com/opencloud-eu/reva/v2/pkg/rhttp/global"
"github.com/opencloud-eu/reva/v2/pkg/storage/favorite/memory"
rtrace "github.com/opencloud-eu/reva/v2/pkg/trace"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"go-micro.dev/v4"
"go-micro.dev/v4/server"
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/trace"
)
func init() {
// register method with chi before any routing is set up
chi.RegisterMethod(ocdav.MethodPropfind)
chi.RegisterMethod(ocdav.MethodProppatch)
chi.RegisterMethod(ocdav.MethodLock)
chi.RegisterMethod(ocdav.MethodUnlock)
chi.RegisterMethod(ocdav.MethodCopy)
chi.RegisterMethod(ocdav.MethodMove)
chi.RegisterMethod(ocdav.MethodMkcol)
chi.RegisterMethod(ocdav.MethodReport)
}
const (
// ServerName to use when announcing the service to the registry
ServerName = "ocdav"
)
// Service initializes the ocdav service and underlying http server.
func Service(opts ...Option) (micro.Service, error) {
sopts := newOptions(opts...)
// set defaults
if err := setDefaults(&sopts); err != nil {
return nil, err
}
sopts.Logger = sopts.Logger.With().Str("name", sopts.Name).Logger()
srv := httpServer.NewServer(
server.Broker(sopts.Broker),
server.TLSConfig(sopts.TLSConfig),
server.Name(sopts.Name),
server.Address(sopts.Address), // Address defaults to ":0" and will pick any free port
server.Version(sopts.config.VersionString),
server.RegisterTTL(sopts.RegisterTTL),
server.RegisterInterval(sopts.RegisterInterval),
)
revaService, err := ocdav.NewWith(&sopts.config, sopts.FavoriteManager, sopts.lockSystem, &sopts.Logger, sopts.GatewaySelector)
if err != nil {
return nil, err
}
r := chi.NewRouter()
tp := sopts.TraceProvider
if tp == nil {
tp = rtrace.NewTracerProvider(sopts.Name, sopts.TracesExporter)
}
if err := useMiddlewares(r, &sopts, revaService, tp); err != nil {
return nil, err
}
r.Handle("/*", revaService.Handler())
_ = chi.Walk(r, func(method string, route string, handler http.Handler, middlewares ...func(http.Handler) http.Handler) error {
sopts.Logger.Debug().Str("service", "ocdav").Str("method", method).Str("route", route).Int("middlewares", len(middlewares)).Msg("serving endpoint")
return nil
})
hd := srv.NewHandler(r)
if err := srv.Handle(hd); err != nil {
return nil, err
}
service := micro.NewService(
micro.Server(srv),
micro.Registry(registry.GetRegistry()),
)
// finally, return the service so it can be Run() by the caller himself
return service, nil
}
func setDefaults(sopts *Options) error {
// set defaults
if sopts.Name == "" {
sopts.Name = ServerName
}
if sopts.lockSystem == nil {
selector, err := pool.GatewaySelector(sopts.config.GatewaySvc)
if err != nil {
return errors.Wrap(err, "error getting gateway selector")
}
sopts.lockSystem = ocdav.NewCS3LS(selector)
}
if sopts.FavoriteManager == nil {
sopts.FavoriteManager, _ = memory.New(map[string]interface{}{})
}
if !strings.HasPrefix(sopts.config.Prefix, "/") {
sopts.config.Prefix = "/" + sopts.config.Prefix
}
if sopts.config.VersionString == "" {
sopts.config.VersionString = "0.0.0"
}
sopts.config.AllowPropfindDepthInfinitiy = sopts.AllowDepthInfinity
return nil
}
func useMiddlewares(r *chi.Mux, sopts *Options, svc global.Service, tp trace.TracerProvider) error {
// auth
for _, v := range svc.Unprotected() {
sopts.Logger.Info().Str("url", v).Msg("unprotected URL")
}
authMiddle, err := auth.New(map[string]interface{}{
"gatewaysvc": sopts.config.GatewaySvc,
"token_managers": map[string]interface{}{
"jwt": map[string]interface{}{
"secret": sopts.JWTSecret,
},
},
}, svc.Unprotected(), tp)
if err != nil {
return err
}
// log
lm := revaLogMiddleware.New()
cors, _, err := cors2.New(map[string]interface{}{
"allow_credentials": sopts.AllowCredentials,
"allowed_methods": sopts.AllowedMethods,
"allowed_headers": sopts.AllowedHeaders,
"allowed_origins": sopts.AllowedOrigins,
})
if err != nil {
return err
}
// tracing
tm := traceHandler(tp, "ocdav")
// metrics
pm := func(h http.Handler) http.Handler { return h }
if sopts.MetricsEnabled {
namespace := sopts.MetricsNamespace
if namespace == "" {
namespace = "reva"
}
subsystem := sopts.MetricsSubsystem
if subsystem == "" {
subsystem = "ocdav"
}
counter := promauto.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "http_requests_total",
Help: "The total number of processed " + subsystem + " HTTP requests for " + namespace,
})
pm = func(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h.ServeHTTP(w, r)
counter.Inc()
})
}
}
// ctx
cm := appctx.New(sopts.Logger, tp)
// request-id
rm := middleware.RequestID
// actually register
r.Use(pm, tm, lm, authMiddle, rm, cm, cors)
return nil
}
func traceHandler(tp trace.TracerProvider, name string) func(http.Handler) http.Handler {
return func(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := rtrace.Propagator.Extract(r.Context(), propagation.HeaderCarrier(r.Header))
t := tp.Tracer("reva")
ctx, span := t.Start(ctx, name)
defer span.End()
rtrace.Propagator.Inject(ctx, propagation.HeaderCarrier(r.Header))
h.ServeHTTP(w, r.WithContext(ctx))
})
}
}