telemetry

package
v0.0.0-...-80cdaea Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PDataLogs

func PDataLogs() plog.Logs

func PDataMetrics

func PDataMetrics() pmetric.Metrics

func PDataTraces

func PDataTraces() ptrace.Traces

Types

type InstrumentationScope

type InstrumentationScope struct {
	Attributes *map[string]any `yaml:"attributes,omitempty"`
	Name       string          `yaml:"name,omitempty"`
	Version    string          `yaml:"version,omitempty"`
}

func (InstrumentationScope) Equals

func (is InstrumentationScope) Equals(toCompare InstrumentationScope) bool

Equals determines the equivalence of two InstrumentationScope items.

func (InstrumentationScope) Hash

func (is InstrumentationScope) Hash() string

Hash provides an md5 hash determined by InstrumentationScope fields.

func (InstrumentationScope) String

func (is InstrumentationScope) String() string

type Log

type Log struct {
	ObservedTimestamp time.Time            `yaml:"observed_timestamp,omitempty"`
	Timestamp         time.Time            `yaml:"timestamp,omitempty"`
	Body              any                  `yaml:"body,omitempty"`
	Attributes        *map[string]any      `yaml:"attributes,omitempty"`
	Severity          *plog.SeverityNumber `yaml:"severity,omitempty"`
	SeverityText      string               `yaml:"severity_text,omitempty"`
}

Log is the log content, representing both the overall definition and a single datapoint.

func (Log) Equals

func (log Log) Equals(toCompare Log) bool

Equals confirms that all fields, defined or not, in receiver Log are equal to toCompare.

func (Log) Hash

func (log Log) Hash() string

Hash provides an md5 hash determined by Log content.

func (Log) RelaxedEquals

func (log Log) RelaxedEquals(toCompare Log) bool

RelaxedEquals confirms that all defined fields in receiver Log are matched in toCompare, ignoring those not set.

func (Log) String

func (log Log) String() string

type Metric

type Metric struct {
	Value       any             `yaml:"value,omitempty"`
	Sum         any             `yaml:"sum,omitempty"`
	Count       any             `yaml:"count,omitempty"`
	Attributes  *map[string]any `yaml:"attributes,omitempty"`
	Name        string          `yaml:"name"`
	Description string          `yaml:"description,omitempty"`
	Unit        string          `yaml:"unit,omitempty"`
	Type        MetricType      `yaml:"type"`
}

Metric is the metric content, representing both the overall definition and a single datapoint. TODO: Timestamps, additional Histogram fields

func (Metric) Equals

func (metric Metric) Equals(toCompare Metric) bool

Confirms that all fields, defined or not, in receiver Metric are equal to toCompare. TODO: ensure that Metric.Hash equivalence is valid given all possible field values.

func (Metric) Hash

func (metric Metric) Hash() string

Provides an md5 hash determined by Metric content.

func (Metric) MarshalYAML

func (metric Metric) MarshalYAML() (any, error)

func (Metric) RelaxedEquals

func (metric Metric) RelaxedEquals(toCompare Metric) bool

Confirms that all defined fields in receiver Metric are matched in toCompare, ignoring those not set with the exception of Labels. All receiver Metric labels must be equal with those of the candidate to match.

func (Metric) String

func (metric Metric) String() string

type MetricType

type MetricType string
const (
	DoubleGauge                      MetricType = "DoubleGauge"
	DoubleMonotonicCumulativeSum     MetricType = "DoubleMonotonicCumulativeSum"
	DoubleMonotonicDeltaSum          MetricType = "DoubleMonotonicDeltaSum"
	DoubleMonotonicUnspecifiedSum    MetricType = "DoubleMonotonicUnspecifiedSum"
	DoubleNonmonotonicCumulativeSum  MetricType = "DoubleNonmonotonicCumulativeSum"
	DoubleNonmonotonicDeltaSum       MetricType = "DoubleNonmonotonicDeltaSum"
	DoubleNonmonotonicUnspecifiedSum MetricType = "DoubleNonmonotonicUnspecifiedSum"
	IntGauge                         MetricType = "IntGauge"
	IntMonotonicCumulativeSum        MetricType = "IntMonotonicCumulativeSum"
	IntMonotonicDeltaSum             MetricType = "IntMonotonicDeltaSum"
	IntMonotonicUnspecifiedSum       MetricType = "IntMonotonicUnspecifiedSum"
	IntNonmonotonicCumulativeSum     MetricType = "IntNonmonotonicCumulativeSum"
	IntNonmonotonicDeltaSum          MetricType = "IntNonmonotonicDeltaSum"
	IntNonmonotonicUnspecifiedSum    MetricType = "IntNonmonotonicUnspecifiedSum"
	Summary                          MetricType = "Summary"
	Histogram                        MetricType = "Histogram"
	ExponentialHistogram             MetricType = "ExponentialHistogram"
)

type Resource

type Resource struct {
	Attributes *map[string]any `yaml:"attributes,omitempty"`
}

func (Resource) Equals

func (resource Resource) Equals(toCompare Resource) bool

Equals determines the equivalence of two Resource items by their Attributes.

func (Resource) FillDefaultValues

func (resource Resource) FillDefaultValues()

func (Resource) Hash

func (resource Resource) Hash() string

Hash provides an md5 hash determined by Resource content.

func (Resource) String

func (resource Resource) String() string

type ResourceLog

type ResourceLog struct {
	Resource  Resource    `yaml:",inline,omitempty"`
	ScopeLogs []ScopeLogs `yaml:"scope_logs"`
}

ResourceLog is the top level log type for a given Resource (set of attributes) and its associated ScopeLogs.

func (ResourceLog) String

func (resourceLog ResourceLog) String() string

type ResourceLogs

type ResourceLogs struct {
	ResourceLogs []ResourceLog `yaml:"resource_logs"`
}

ResourceLogs is a convenience type for testing helpers and assertions. Analogous to pdata form, with the exception that InstrumentationScope.Logs items act as both parent log container and records whose identity is based on differing attributes and other fields.

func FlattenResourceLogs

func FlattenResourceLogs(resourceLogs ...ResourceLogs) ResourceLogs

FlattenResourceLogs takes multiple instances of ResourceLogs and flattens them to only unique entries by Resource, InstrumentationScope, and Log content. It will preserve order by removing subsequent occurrences of repeated items from the returned flattened ResourceLogs item

func LoadResourceLogs

func LoadResourceLogs(path string) (*ResourceLogs, error)

LoadResourceLogs returns a ResourceLogs instance generated via parsing a valid yaml file at the provided path.

func PDataToResourceLogs

func PDataToResourceLogs(pdataLogs ...plog.Logs) (ResourceLogs, error)

PDataToResourceLogs returns a ResourceLogs item generated from plog.Logs content.

func (ResourceLogs) ContainsAll

func (resourceLogs ResourceLogs) ContainsAll(expected ResourceLogs) (bool, error)

ContainsAll determines if everything in expected ResourceLogs is in the receiver ResourceLogs item (i.e. expected ⊆ resourceLogs). Neither guarantees equivalence, nor that expected contains all of resourceLogs (i.e. is not an expected ≣ resourceLogs nor resourceLogs ⊆ expected check). Log equivalence is based on RelaxedEquals() check: fields not in expected (e.g. unit, type, value, etc.) are not compared to received, but all labels must match. For better reliability, it's advised that both ResourceLogs items have been flattened by FlattenResourceLogs.

func (*ResourceLogs) FillDefaultValues

func (resourceLogs *ResourceLogs) FillDefaultValues()

FillDefaultValues fills ResourceLogs with default values

func (ResourceLogs) String

func (resourceLogs ResourceLogs) String() string

func (ResourceLogs) Validate

func (resourceLogs ResourceLogs) Validate() error

Determines if all values in ResourceLogs item are valid

type ResourceMetric

type ResourceMetric struct {
	Resource     Resource       `yaml:",inline,omitempty"`
	ScopeMetrics []ScopeMetrics `yaml:"scope_metrics"`
}

ResourceMetric is the top level metric type for a given Resource (set of attributes) and its associated ScopeMetrics.

func (ResourceMetric) String

func (resourceMetric ResourceMetric) String() string

type ResourceMetrics

type ResourceMetrics struct {
	ResourceMetrics []ResourceMetric `yaml:"resource_metrics"`
}

ResourceMetrics is a convenience type for testing helpers and assertions. Analogous to pdata form, with the exception that InstrumentationScope.Metrics items act as both parent metric container and datapoints whose identity is based on differing labels and other fields.

func FlattenResourceMetrics

func FlattenResourceMetrics(resourceMetrics ...ResourceMetrics) ResourceMetrics

FlattenResourceMetrics takes multiple instances of ResourceMetrics and flattens them to only unique entries by Resource, InstrumentationScope, and Metric content. It will preserve order by removing subsequent occurrences of repeated items from the returned flattened ResourceMetrics item

func LoadResourceMetrics

func LoadResourceMetrics(path string) (*ResourceMetrics, error)

LoadResourceMetrics returns a ResourceMetrics instance generated via parsing a valid yaml file at the provided path.

func PDataToResourceMetrics

func PDataToResourceMetrics(pdataMetrics ...pmetric.Metrics) (ResourceMetrics, error)

PDataToResourceMetrics returns a ResourceMetrics item generated from pmetric.Metrics content. At this time histograms and summaries aren't supported.

func (ResourceMetrics) ContainsAll

func (resourceMetrics ResourceMetrics) ContainsAll(expected ResourceMetrics) (bool, error)

ContainsAll determines if everything in `expected` ResourceMetrics is in the receiver ResourceMetrics item (i.e. expected ⊆ resourceMetrics). Neither guarantees equivalence, nor that expected contains all of received (i.e. is not an expected ≣ resourceMetrics nor resourceMetrics ⊆ expected check). Metric equivalence is based on RelaxedEquals() check: fields not in expected (e.g. unit, type, value, etc.) are not compared to received, but all labels must match. For better reliability, it's advised that both ResourceMetrics items have been flattened by FlattenResourceMetrics.

func (ResourceMetrics) ContainsOnly

func (resourceMetrics ResourceMetrics) ContainsOnly(expected ResourceMetrics) (bool, error)

ContainsOnly confirms both resourceMetrics.ContainsAll(expected) and that no additional metrics are reported

func (*ResourceMetrics) FillDefaultValues

func (resourceMetrics *ResourceMetrics) FillDefaultValues()

FillDefaultValues fills ResourceMetrics with default values

func (ResourceMetrics) String

func (resourceMetrics ResourceMetrics) String() string

func (ResourceMetrics) Validate

func (resourceMetrics ResourceMetrics) Validate() error

Determines if all values in ResourceMetrics item are valid

type ResourceSpans

type ResourceSpans struct {
	Resource   Resource     `yaml:",inline,omitempty"`
	ScopeSpans []ScopeSpans `yaml:"scope_spans"`
}

ResourceSpans is the top level grouping of trace data given a Resource (set of attributes) and associated ScopeSpans.

func (ResourceSpans) String

func (resourceSpans ResourceSpans) String() string

type ResourceTraces

type ResourceTraces struct {
	ResourceSpans []ResourceSpans `yaml:"resource_spans"`
}

ResourceTraces is a convenience type for test helpers and assertions.

func FlattenResourceTraces

func FlattenResourceTraces(resourceTracesSlice ...ResourceTraces) ResourceTraces

FlattenResourceTraces takes multiple instances of ResourceTraces and flattens them to only unique entries by Resource, InstrumentationScope, and Span contents. It will preserve order by removing subsequent occurrences of repeated items from the returned flattened ResourceTraces item

func LoadResourceTraces

func LoadResourceTraces(path string) (*ResourceTraces, error)

LoadResourceTraces returns a ResourceTraces instance generated via parsing a valid yaml file at the provided path.

func PDataToResourceTraces

func PDataToResourceTraces(pdataTraces ...ptrace.Traces) (ResourceTraces, error)

PDataToResourceTraces returns a ResourceTraces item generated from ptrace.Traces content.

func (ResourceTraces) ContainsAll

func (rt ResourceTraces) ContainsAll(expected ResourceTraces) (bool, error)

ContainsAll determines if everything in `expected` ResourceTraces is in the receiver ResourceTraces item (i.e. expected ⊆ resourceTraces). Neither guarantees equivalence, nor that expected contains all of received (i.e. is not an expected ≣ resourceTraces nor resourceTraces ⊆ expected check). Span equivalence is based on RelaxedEquals() check: fields not in expected (e.g. unit, type, value, etc.) are not compared to received, but all labels must match. For better reliability, it's advised that both ResourceTraces items have been flattened by FlattenResourceTraces.

func (*ResourceTraces) SaveResourceTraces

func (rt *ResourceTraces) SaveResourceTraces(path string) error

SaveResourceTraces is a helper function that saves the ResourceTraces to an yaml file.

func (ResourceTraces) String

func (rt ResourceTraces) String() string

type ScopeLogs

type ScopeLogs struct {
	Scope InstrumentationScope `yaml:"instrumentation_scope,omitempty"`
	Logs  []Log                `yaml:"logs,omitempty"`
}

ScopeLogs are the collection of logs produced by a given InstrumentationScope

func (ScopeLogs) String

func (scopeLogs ScopeLogs) String() string

type ScopeMetrics

type ScopeMetrics struct {
	Scope   InstrumentationScope `yaml:"instrumentation_scope,omitempty"`
	Metrics []Metric             `yaml:"metrics,omitempty"`
}

ScopeMetrics are the collection of metrics produced by a given InstrumentationScope

func (ScopeMetrics) String

func (scopeMetrics ScopeMetrics) String() string

type ScopeSpans

type ScopeSpans struct {
	Scope InstrumentationScope `yaml:"instrumentation_scope,omitempty"`
	Spans []Span               `yaml:"spans,omitempty"`
}

ScopeSpans is the top level grouping of trace data given InstrumentationScope and associated collection of Span instances.

func (ScopeSpans) String

func (scopeSpans ScopeSpans) String() string

type Span

type Span struct {
	Attributes *map[string]any `yaml:"attributes,omitempty"`
	Name       string          `yaml:"name,omitempty"`
}

Span is the trace content, here defined only with the fields required for tests.

func (Span) RelaxedEquals

func (span Span) RelaxedEquals(toCompare Span) bool

func (Span) String

func (span Span) String() string

Jump to

Keyboard shortcuts

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