normalize

package
v0.85.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 7 Imported by: 8 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package normalize contains functions for normalizing trace data.

Index

Constants

View Source
const (
	// DefaultSpanName is the default name we assign a span if it's missing and we have no reasonable fallback
	DefaultSpanName = "unnamed_operation"
	// DefaultServiceName is the default name we assign a service if it's missing and we have no reasonable fallback
	DefaultServiceName = "unnamed-service"
)
View Source
const (
	// MaxNameLen the maximum length a name can have
	MaxNameLen = 100
	// MaxServiceLen the maximum length a service can have
	MaxServiceLen = 100
	// MaxResourceLen the maximum length a resource can have
	MaxResourceLen = 5000
)

Variables

View Source
var (
	// ErrEmpty specifies that the passed input was empty.
	ErrEmpty = errors.New("empty")
	// ErrTooLong signifies that the input was too long.
	ErrTooLong = errors.New("too long")
	// ErrInvalid signifies that the input was invalid.
	ErrInvalid = errors.New("invalid")
)
View Source
var Year2000NanosecTS = time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC).UnixNano()

Year2000NanosecTS is an arbitrary cutoff to spot weird-looking start timestamps.

Functions

func FixDuration added in v0.85.0

func FixDuration(start, duration int64) (fixed int64, invalid bool)

FixDuration validates a span duration relative to its start time, returning a corrected value and whether the input was invalid. A negative duration, or one that would overflow when added to start, is reset to 0.

func FixStartTime added in v0.85.0

func FixStartTime(start, duration int64) (fixed int64, invalid bool)

FixStartTime validates a span start time, returning a corrected value and whether the input was invalid. A start predating Year2000NanosecTS is considered garbage and reset to "now - duration" (clamped to "now").

func NormalizeName

func NormalizeName(name string) (string, error)

NormalizeName normalizes a span name and returns an error describing the reason (if any) why the name was modified.

func NormalizePeerService

func NormalizePeerService(svc string) (string, error)

NormalizePeerService normalizes a span's peer.service and returns an error describing the reason (if any) why the name was modified.

func NormalizeService

func NormalizeService(svc string, lang string) (string, error)

NormalizeService normalizes a span service and returns an error describing the reason (if any) why the name was modified.

func NormalizeTag

func NormalizeTag(v string) string

NormalizeTag applies some normalization to ensure the full tag_key:tag_value string matches the backend requirements.

func NormalizeTagValue

func NormalizeTagValue(v string) string

NormalizeTagValue applies some normalization to ensure the tag value matches the backend requirements. It should be used for cases where we have just the tag_value as the input (instead of tag_key:tag_value).

func TruncateUTF8

func TruncateUTF8(s string, limit int) string

TruncateUTF8 truncates the given string to make sure it uses less than limit bytes. If the last character is an utf8 character that would be splitten, it removes it entirely to make sure the resulting string is not broken.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL