mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-01 17:22:25 -05:00
[chore] update otel libraries (#3740)
* chore: update otel dependencies * refactor: combine tracing & metrics in observability package * chore: update example tracing compose file
This commit is contained in:
parent
baed591a1d
commit
dd094e4012
217 changed files with 6873 additions and 2734 deletions
38
vendor/google.golang.org/grpc/experimental/stats/metricregistry.go
generated
vendored
38
vendor/google.golang.org/grpc/experimental/stats/metricregistry.go
generated
vendored
|
|
@ -20,10 +20,10 @@ package stats
|
|||
|
||||
import (
|
||||
"maps"
|
||||
"testing"
|
||||
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"google.golang.org/grpc/internal"
|
||||
"google.golang.org/grpc/stats"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
@ -35,7 +35,7 @@ var logger = grpclog.Component("metrics-registry")
|
|||
// DefaultMetrics are the default metrics registered through global metrics
|
||||
// registry. This is written to at initialization time only, and is read only
|
||||
// after initialization.
|
||||
var DefaultMetrics = NewMetrics()
|
||||
var DefaultMetrics = stats.NewMetricSet()
|
||||
|
||||
// MetricDescriptor is the data for a registered metric.
|
||||
type MetricDescriptor struct {
|
||||
|
|
@ -43,7 +43,7 @@ type MetricDescriptor struct {
|
|||
// (including any per call metrics). See
|
||||
// https://github.com/grpc/proposal/blob/master/A79-non-per-call-metrics-architecture.md#metric-instrument-naming-conventions
|
||||
// for metric naming conventions.
|
||||
Name Metric
|
||||
Name string
|
||||
// The description of this metric.
|
||||
Description string
|
||||
// The unit (e.g. entries, seconds) of this metric.
|
||||
|
|
@ -155,27 +155,27 @@ func (h *Int64GaugeHandle) Record(recorder MetricsRecorder, incr int64, labels .
|
|||
}
|
||||
|
||||
// registeredMetrics are the registered metric descriptor names.
|
||||
var registeredMetrics = make(map[Metric]bool)
|
||||
var registeredMetrics = make(map[string]bool)
|
||||
|
||||
// metricsRegistry contains all of the registered metrics.
|
||||
//
|
||||
// This is written to only at init time, and read only after that.
|
||||
var metricsRegistry = make(map[Metric]*MetricDescriptor)
|
||||
var metricsRegistry = make(map[string]*MetricDescriptor)
|
||||
|
||||
// DescriptorForMetric returns the MetricDescriptor from the global registry.
|
||||
//
|
||||
// Returns nil if MetricDescriptor not present.
|
||||
func DescriptorForMetric(metric Metric) *MetricDescriptor {
|
||||
return metricsRegistry[metric]
|
||||
func DescriptorForMetric(metricName string) *MetricDescriptor {
|
||||
return metricsRegistry[metricName]
|
||||
}
|
||||
|
||||
func registerMetric(name Metric, def bool) {
|
||||
if registeredMetrics[name] {
|
||||
logger.Fatalf("metric %v already registered", name)
|
||||
func registerMetric(metricName string, def bool) {
|
||||
if registeredMetrics[metricName] {
|
||||
logger.Fatalf("metric %v already registered", metricName)
|
||||
}
|
||||
registeredMetrics[name] = true
|
||||
registeredMetrics[metricName] = true
|
||||
if def {
|
||||
DefaultMetrics = DefaultMetrics.Add(name)
|
||||
DefaultMetrics = DefaultMetrics.Add(metricName)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -250,21 +250,21 @@ func RegisterInt64Gauge(descriptor MetricDescriptor) *Int64GaugeHandle {
|
|||
}
|
||||
|
||||
// snapshotMetricsRegistryForTesting snapshots the global data of the metrics
|
||||
// registry. Registers a cleanup function on the provided testing.T that sets
|
||||
// the metrics registry to its original state. Only called in testing functions.
|
||||
func snapshotMetricsRegistryForTesting(t *testing.T) {
|
||||
// registry. Returns a cleanup function that sets the metrics registry to its
|
||||
// original state.
|
||||
func snapshotMetricsRegistryForTesting() func() {
|
||||
oldDefaultMetrics := DefaultMetrics
|
||||
oldRegisteredMetrics := registeredMetrics
|
||||
oldMetricsRegistry := metricsRegistry
|
||||
|
||||
registeredMetrics = make(map[Metric]bool)
|
||||
metricsRegistry = make(map[Metric]*MetricDescriptor)
|
||||
registeredMetrics = make(map[string]bool)
|
||||
metricsRegistry = make(map[string]*MetricDescriptor)
|
||||
maps.Copy(registeredMetrics, registeredMetrics)
|
||||
maps.Copy(metricsRegistry, metricsRegistry)
|
||||
|
||||
t.Cleanup(func() {
|
||||
return func() {
|
||||
DefaultMetrics = oldDefaultMetrics
|
||||
registeredMetrics = oldRegisteredMetrics
|
||||
metricsRegistry = oldMetricsRegistry
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
78
vendor/google.golang.org/grpc/experimental/stats/metrics.go
generated
vendored
78
vendor/google.golang.org/grpc/experimental/stats/metrics.go
generated
vendored
|
|
@ -19,7 +19,7 @@
|
|||
// Package stats contains experimental metrics/stats API's.
|
||||
package stats
|
||||
|
||||
import "maps"
|
||||
import "google.golang.org/grpc/stats"
|
||||
|
||||
// MetricsRecorder records on metrics derived from metric registry.
|
||||
type MetricsRecorder interface {
|
||||
|
|
@ -40,75 +40,15 @@ type MetricsRecorder interface {
|
|||
RecordInt64Gauge(handle *Int64GaugeHandle, incr int64, labels ...string)
|
||||
}
|
||||
|
||||
// Metric is an identifier for a metric.
|
||||
type Metric string
|
||||
// Metrics is an experimental legacy alias of the now-stable stats.MetricSet.
|
||||
// Metrics will be deleted in a future release.
|
||||
type Metrics = stats.MetricSet
|
||||
|
||||
// Metrics is a set of metrics to record. Once created, Metrics is immutable,
|
||||
// however Add and Remove can make copies with specific metrics added or
|
||||
// removed, respectively.
|
||||
//
|
||||
// Do not construct directly; use NewMetrics instead.
|
||||
type Metrics struct {
|
||||
// metrics are the set of metrics to initialize.
|
||||
metrics map[Metric]bool
|
||||
}
|
||||
// Metric was replaced by direct usage of strings.
|
||||
type Metric = string
|
||||
|
||||
// NewMetrics returns a Metrics containing Metrics.
|
||||
// NewMetrics is an experimental legacy alias of the now-stable
|
||||
// stats.NewMetricSet. NewMetrics will be deleted in a future release.
|
||||
func NewMetrics(metrics ...Metric) *Metrics {
|
||||
newMetrics := make(map[Metric]bool)
|
||||
for _, metric := range metrics {
|
||||
newMetrics[metric] = true
|
||||
}
|
||||
return &Metrics{
|
||||
metrics: newMetrics,
|
||||
}
|
||||
}
|
||||
|
||||
// Metrics returns the metrics set. The returned map is read-only and must not
|
||||
// be modified.
|
||||
func (m *Metrics) Metrics() map[Metric]bool {
|
||||
return m.metrics
|
||||
}
|
||||
|
||||
// Add adds the metrics to the metrics set and returns a new copy with the
|
||||
// additional metrics.
|
||||
func (m *Metrics) Add(metrics ...Metric) *Metrics {
|
||||
newMetrics := make(map[Metric]bool)
|
||||
for metric := range m.metrics {
|
||||
newMetrics[metric] = true
|
||||
}
|
||||
|
||||
for _, metric := range metrics {
|
||||
newMetrics[metric] = true
|
||||
}
|
||||
return &Metrics{
|
||||
metrics: newMetrics,
|
||||
}
|
||||
}
|
||||
|
||||
// Join joins the metrics passed in with the metrics set, and returns a new copy
|
||||
// with the merged metrics.
|
||||
func (m *Metrics) Join(metrics *Metrics) *Metrics {
|
||||
newMetrics := make(map[Metric]bool)
|
||||
maps.Copy(newMetrics, m.metrics)
|
||||
maps.Copy(newMetrics, metrics.metrics)
|
||||
return &Metrics{
|
||||
metrics: newMetrics,
|
||||
}
|
||||
}
|
||||
|
||||
// Remove removes the metrics from the metrics set and returns a new copy with
|
||||
// the metrics removed.
|
||||
func (m *Metrics) Remove(metrics ...Metric) *Metrics {
|
||||
newMetrics := make(map[Metric]bool)
|
||||
for metric := range m.metrics {
|
||||
newMetrics[metric] = true
|
||||
}
|
||||
|
||||
for _, metric := range metrics {
|
||||
delete(newMetrics, metric)
|
||||
}
|
||||
return &Metrics{
|
||||
metrics: newMetrics,
|
||||
}
|
||||
return stats.NewMetricSet(metrics...)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue