1
0
Fork 0

Introduce trace verbosity config and produce less spans by default

This commit is contained in:
Romain 2025-07-18 15:32:05 +02:00 committed by GitHub
parent 77ef7fe490
commit 8c23eb6833
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
93 changed files with 1005 additions and 524 deletions

View file

@ -23,6 +23,22 @@ import (
"google.golang.org/grpc/encoding/gzip"
)
type TracingVerbosity string
const (
MinimalVerbosity TracingVerbosity = "minimal"
DetailedVerbosity TracingVerbosity = "detailed"
)
func (v TracingVerbosity) Allows(verbosity TracingVerbosity) bool {
switch v {
case DetailedVerbosity:
return verbosity == DetailedVerbosity || verbosity == MinimalVerbosity
default:
return verbosity == MinimalVerbosity
}
}
// OTelTracing provides configuration settings for the open-telemetry tracer.
type OTelTracing struct {
GRPC *OTelGRPC `description:"gRPC configuration for the OpenTelemetry collector." json:"grpc,omitempty" toml:"grpc,omitempty" yaml:"grpc,omitempty" label:"allowEmpty" file:"allowEmpty" export:"true"`

72
pkg/types/tracing_test.go Normal file
View file

@ -0,0 +1,72 @@
package types
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestTracingVerbosity_Allows(t *testing.T) {
tests := []struct {
desc string
from TracingVerbosity
to TracingVerbosity
allows bool
}{
{
desc: "minimal vs minimal",
from: MinimalVerbosity,
to: MinimalVerbosity,
allows: true,
},
{
desc: "minimal vs detailed",
from: MinimalVerbosity,
to: DetailedVerbosity,
allows: false,
},
{
desc: "detailed vs minimal",
from: DetailedVerbosity,
to: MinimalVerbosity,
allows: true,
},
{
desc: "detailed vs detailed",
from: DetailedVerbosity,
to: DetailedVerbosity,
allows: true,
},
{
desc: "unknown vs minimal",
from: TracingVerbosity("unknown"),
to: MinimalVerbosity,
allows: true,
},
{
desc: "unknown vs detailed",
from: TracingVerbosity("unknown"),
to: DetailedVerbosity,
allows: false,
},
{
desc: "minimal vs unknown",
from: MinimalVerbosity,
to: TracingVerbosity("unknown"),
allows: false,
},
{
desc: "detailed vs unknown",
from: DetailedVerbosity,
to: TracingVerbosity("unknown"),
allows: false,
},
}
for _, test := range tests {
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
require.Equal(t, test.allows, test.from.Allows(test.to))
})
}
}