mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-22 20:48:10 +02:00
only configure tracing in envoy if it is enabled in pomerium
This commit is contained in:
parent
180c7e04af
commit
de68673819
3 changed files with 50 additions and 10 deletions
|
@ -437,16 +437,6 @@ func grpcHealthChecks(name string) []*envoy_config_core_v3.HealthCheck {
|
|||
ServiceName: name,
|
||||
},
|
||||
},
|
||||
// EventLogger: []*envoy_config_core_v3.TypedExtensionConfig{
|
||||
// {
|
||||
// Name: "envoy.health_check.event_sink.file",
|
||||
// TypedConfig: marshalAny(&envoy_extensions_eventsinks_file_v3.HealthCheckEventFileSink{
|
||||
// EventLogPath: "/tmp/healthchecks",
|
||||
// }),
|
||||
// },
|
||||
// },
|
||||
// AlwaysLogHealthCheckFailures: true,
|
||||
// AlwaysLogHealthCheckSuccess: true,
|
||||
}}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,13 +15,31 @@ import (
|
|||
envoy_type_v3 "github.com/envoyproxy/go-control-plane/envoy/type/v3"
|
||||
"github.com/pomerium/pomerium/config"
|
||||
"github.com/pomerium/pomerium/config/envoyconfig/extensions"
|
||||
"github.com/pomerium/pomerium/internal/telemetry/trace"
|
||||
"google.golang.org/protobuf/types/known/wrapperspb"
|
||||
)
|
||||
|
||||
func isTracingEnabled(cfg *config.Options) bool {
|
||||
if os.Getenv("OTEL_SDK_DISABLED") == "true" {
|
||||
return false
|
||||
}
|
||||
switch cfg.TracingProvider {
|
||||
case "none", "noop": // explicitly disabled from config
|
||||
return false
|
||||
case "": // unset
|
||||
return trace.IsEnabledViaEnvironment()
|
||||
default: // set to a non-empty value
|
||||
return !trace.IsDisabledViaEnvironment()
|
||||
}
|
||||
}
|
||||
|
||||
func applyTracingConfig(
|
||||
mgr *envoy_extensions_filters_network_http_connection_manager.HttpConnectionManager,
|
||||
opts *config.Options,
|
||||
) {
|
||||
if !isTracingEnabled(opts) {
|
||||
return
|
||||
}
|
||||
mgr.HttpFilters = append([]*envoy_extensions_filters_network_http_connection_manager.HttpFilter{
|
||||
tracingMetadataFilter(),
|
||||
}, mgr.HttpFilters...)
|
||||
|
|
|
@ -225,3 +225,35 @@ func (n NoopClient) Stop(context.Context) error {
|
|||
func (n NoopClient) UploadTraces(context.Context, []*v1.ResourceSpans) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func IsDisabledViaEnvironment() bool {
|
||||
if os.Getenv("OTEL_SDK_DISABLED") == "true" {
|
||||
return true
|
||||
}
|
||||
exporter, ok := os.LookupEnv("OTEL_TRACES_EXPORTER")
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
switch strings.ToLower(strings.TrimSpace(exporter)) {
|
||||
case "none, noop":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func IsEnabledViaEnvironment() bool {
|
||||
if os.Getenv("OTEL_SDK_DISABLED") == "true" {
|
||||
return false
|
||||
}
|
||||
exporter, ok := os.LookupEnv("OTEL_TRACES_EXPORTER")
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
switch strings.ToLower(strings.TrimSpace(exporter)) {
|
||||
case "none, noop", "":
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue