mirror of
https://github.com/kubernetes/kubernetes.git
synced 2026-02-03 20:40:26 -05:00
Core packages (opentelemetry-go): - go.opentelemetry.io/otel: v1.38.0 → v1.39.0 - go.opentelemetry.io/otel/metric: v1.38.0 → v1.39.0 - go.opentelemetry.io/otel/trace: v1.38.0 → v1.39.0 - go.opentelemetry.io/otel/sdk: v1.38.0 → v1.39.0 Exporters: - go.opentelemetry.io/otel/exporters/otlp/otlptrace: v1.34.0 → v1.39.0 - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc: v1.34.0 → v1.39.0 Contrib instrumentation (opentelemetry-go-contrib): - go.opentelemetry.io/contrib/.../otelhttp: v0.61.0 → v0.64.0 - go.opentelemetry.io/contrib/.../otelrestful: v0.44.0 → v0.64.0 Protocol definitions (opentelemetry-proto-go): - go.opentelemetry.io/proto/otlp: v1.5.0 → v1.9.0 Notable changes: - Go 1.24 is now the minimum required version (Go 1.23 support dropped) for OTEL components - Performance: ~4x improvement in histogram concurrent operations; xxhash replaces fnv for attribute hashing - Fixed goroutine leak in span processors when context is canceled - otelrestful migrated semantic conventions from v1.20.0 to v1.34.0 (e.g., http.method → http.request.method) - Partial OTLP export errors now surfaced instead of being silently dropped - otelrestful no longer depends on json-iterator/go, modern-go/concurrent, or modern-go/reflect2; unwanted-dependencies.json updated accordingly Signed-off-by: Davanum Srinivas <davanum@gmail.com>
59 lines
1.6 KiB
Go
59 lines
1.6 KiB
Go
package restful
|
|
|
|
// Copyright 2025 Ernest Micklei. All rights reserved.
|
|
// Use of this source code is governed by a license
|
|
// that can be found in the LICENSE file.
|
|
|
|
import (
|
|
"fmt"
|
|
"regexp"
|
|
"sync"
|
|
)
|
|
|
|
var (
|
|
customVerbReg = regexp.MustCompile(":([A-Za-z]+)$")
|
|
customVerbCache sync.Map // Cache for compiled custom verb regexes
|
|
customVerbCacheEnabled = true // Enable/disable custom verb regex caching
|
|
)
|
|
|
|
// SetCustomVerbCacheEnabled enables or disables custom verb regex caching.
|
|
// When disabled, custom verb regex patterns will be compiled on every request.
|
|
// When enabled (default), compiled custom verb regex patterns are cached for better performance.
|
|
func SetCustomVerbCacheEnabled(enabled bool) {
|
|
customVerbCacheEnabled = enabled
|
|
}
|
|
|
|
func hasCustomVerb(routeToken string) bool {
|
|
return customVerbReg.MatchString(routeToken)
|
|
}
|
|
|
|
func isMatchCustomVerb(routeToken string, pathToken string) bool {
|
|
rs := customVerbReg.FindStringSubmatch(routeToken)
|
|
if len(rs) < 2 {
|
|
return false
|
|
}
|
|
|
|
customVerb := rs[1]
|
|
regexPattern := fmt.Sprintf(":%s$", customVerb)
|
|
|
|
// Check cache first (if enabled)
|
|
if customVerbCacheEnabled {
|
|
if specificVerbReg, found := getCachedRegexp(&customVerbCache, regexPattern); found {
|
|
return specificVerbReg.MatchString(pathToken)
|
|
}
|
|
}
|
|
|
|
// Compile the regex
|
|
specificVerbReg := regexp.MustCompile(regexPattern)
|
|
|
|
// Cache the regex (if enabled)
|
|
if customVerbCacheEnabled {
|
|
customVerbCache.Store(regexPattern, specificVerbReg)
|
|
}
|
|
|
|
return specificVerbReg.MatchString(pathToken)
|
|
}
|
|
|
|
func removeCustomVerb(str string) string {
|
|
return customVerbReg.ReplaceAllString(str, "")
|
|
}
|