Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Attributes ¶
func Attributes(keys ...string) trace.TracerProviderOption
Attributes returns an OpenTelemetry SDK TracerProviderOption. It registers an OpenTelemetry SpanProcessor that redacts attributes of new spans matching the passed keys.
Example ¶
package main import ( "github.com/MrAlias/redact" "go.opentelemetry.io/otel/sdk/trace" ) func main() { _ = trace.NewTracerProvider( // Replace attributes from new spans that have keys matching // "password", "user", and "secret" with the redacted value // "****REDACTED****". redact.Attributes("password", "user", "secret"), /* From here, configure your trace pipeline as normal ... */ ) }
Output:
func Span ¶
func Span(names ...string) trace.TracerProviderOption
Span returns an OpenTelemetry SDK TracerProviderOption. It registers an OpenTelemetry Sampler that drops all spans with matching names. A name can be the exact span name, or contain wildcards. See NewSpanCensor for information about matching.
Example ¶
package main import ( "github.com/MrAlias/redact" "go.opentelemetry.io/otel/sdk/trace" ) func main() { _ = trace.NewTracerProvider( // Drop spans whose name is `"health-check"`. redact.Span("health-check"), /* From here, configure your trace pipeline as normal ... */ ) }
Output:
Types ¶
type AttributeCensor ¶
type AttributeCensor struct {
// contains filtered or unexported fields
}
AttributeCensor is an OpenTelemetry SpanProcessor that censors attributes of new spans.
func NewAttributeCensor ¶
func NewAttributeCensor(replacements map[attribute.Key]attribute.Value) AttributeCensor
NewAttributeCensor returns an AttributeCensor that uses the provided mapping of replacement values for a set of keys to redact matching attributes. Attributes are matched based on the equality of keys.
func (AttributeCensor) ForceFlush ¶
func (AttributeCensor) ForceFlush(context.Context) error
ForceFlush does nothing.
func (AttributeCensor) OnEnd ¶
func (c AttributeCensor) OnEnd(s trace.ReadOnlySpan)
OnEnd censors the attributes of s matching the Replacements keys of c.
func (AttributeCensor) OnStart ¶
func (c AttributeCensor) OnStart(_ context.Context, _ trace.ReadWriteSpan)
OnStart does nothing.
type SpanCensor ¶
type SpanCensor struct {
// contains filtered or unexported fields
}
SpanCensor is an OpenTelemetry Sampler that drops spans with certain names. See NewSpanCensor for information about name matching.
func NewSpanCensor ¶
func NewSpanCensor(parent trace.Sampler, names ...string) SpanCensor
NewSpanCensor returns a new configured SpanCensor. Any span with a name matching one of the passed names will be dropped. A name can be an exact string match for the span name, or contain wildcards. The * wildcard is expanded to match zero or more characters and the ? wildcard matches exactly one character. One or more wildcards can be used in combination to match a name.
func (SpanCensor) Description ¶
func (s SpanCensor) Description() string
Description returns an identification description of the SpanCensor.
func (SpanCensor) ShouldSample ¶
func (s SpanCensor) ShouldSample(p trace.SamplingParameters) trace.SamplingResult
ShouldSample returns a sampling decision to drop when p contains a name matching the SpanCensor criteria. Otherwise, the sampling decision is delegated to the Sampler SpanCensor wraps.