otel

package
v0.0.0-...-d4dfa1c Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package otel provides data structures to represent and generate otel configuration.

Index

Constants

This section is empty.

Variables

View Source
var ToggleScalarDataType = map[string]interface{}{"action": "toggle_scalar_data_type"}

ToggleScalarDataType transforms int -> double and double -> int.

Functions

func AddLabel

func AddLabel(key, value string) map[string]interface{}

AddLabel adds a label with a fixed value.

func AggregateLabels

func AggregateLabels(aggregationType string, labels ...string) map[string]interface{}

AggregateLabels removes all labels except those in the passed list, aggregating values using aggregationType.

func CombineMetrics

func CombineMetrics(old, new string, operations ...map[string]interface{}) map[string]interface{}

CombineMetrics returns a config snippet that renames metrics matching the regex old to new, applying zero or more transformations.

func ExtractCountMetric

func ExtractCountMetric(monotonic bool, metricName string) []string

ExtractCountMetric creates a new metric based on the count value of a Histogram metric

func RenameLabel

func RenameLabel(old, new string) map[string]interface{}

RenameLabel renames old to new

func RenameMetric

func RenameMetric(old, new string, operations ...map[string]interface{}) map[string]interface{}

RenameMetric returns a config snippet that renames old to new, applying zero or more transformations.

Types

type Component

type Component struct {
	// Type is the string type needed to instantiate the OT component.
	Type string
	// Config is an object which can be serialized by mapstructure into the configuration for the component.
	// This can either be a map[string]interface{} or a Config struct from OT.
	Config interface{}
}

Component represents a single OT component (receiver, processor, exporter, etc.)

func AddResourceAttr

func AddResourceAttr(key, from string) Component

AddResourceAttr adds a resource attribute using a processor.

func GCPResourceDetector

func GCPResourceDetector() Component

GCPResourceDetector returns a resourcedetection processor configured for only GCP.

func GroupByGMPAttrs

func GroupByGMPAttrs() Component

GroupByGMPAttrs moves the "namespace" and "cluster" metric attributes to resource attributes.

Metrics coming from run-gmp-sidecar are written against the `prometheus_target` monitored resource in Cloud Monitoring. The labels for these monitored resources come from the OTel resource labels. As a result, this processor needs to promote certain metric labels to resource labels so the translation can happen correctly.

See https://cloud.google.com/monitoring/api/resources#tag_prometheus_target for more information about the monitored resource used.

func MetricsFilter

func MetricsFilter(polarity, matchType string, metricNames ...string) Component

MetricsFilter returns a Component that filters metrics. polarity should be "include" or "exclude". matchType should be "strict" or "regexp".

func MetricsTransform

func MetricsTransform(metrics ...map[string]interface{}) Component

MetricsTransform returns a Component that performs the transformations specified as arguments.

func Transform

func Transform(statementType, context string, statements []string) Component

Transform returns a transform processor object that executes statements on statementType data.

func TransformationMetrics

func TransformationMetrics(queries ...TransformQuery) Component

TransformationMetrics returns a transform processor object that contains all the queries passed into it.

type ModularConfig

type ModularConfig struct {
	LogLevel          string
	ReceiverPipelines map[string]ReceiverPipeline
	Exporter          Component
	SelfMetricsPort   int
}

func (ModularConfig) Generate

func (c ModularConfig) Generate() (string, error)

type ReceiverPipeline

type ReceiverPipeline struct {
	Receiver   Component
	Processors []Component
}

ReceiverPipeline represents a single OT receiver and zero or more processors that must be chained after that receiver.

type TransformQuery

type TransformQuery string

TransformQuery is a type wrapper for query expressions supported by the transform processor found here: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/transformprocessor

func AddMetricLabel

func AddMetricLabel(key, val string) TransformQuery

AddMetricLabel adds a new metric attribute. If it already exists, then it is overwritten.

func DeleteMetricAttribute

func DeleteMetricAttribute(metricAttribute string) TransformQuery

DeleteMetricAttribute returns an expression that removes the metric attribute specified.

func FlattenResourceAttribute

func FlattenResourceAttribute(resourceAttribute, metricAttribute string) TransformQuery

FlattenResourceAttribute returns an expression that brings down a resource attribute to a metric attribute.

func GroupByAttribute

func GroupByAttribute(resourceAttribute, metricAttribute string) TransformQuery

GroupByAttribute returns an expression that makes a metric attribute into a resource attribute.

func PrefixResourceAttribute

func PrefixResourceAttribute(destResourceAttribute, srcResourceAttribute, delimiter string) TransformQuery

PrefixResourceAttribute prefixes the resource attribute with another resource attribute.

Note: Mutating the resource attribute results in this update happening for each data point. Since the OTTL statement uses the resource attribute in both the target and the source labels, we must make sure after the first mutation, the subsequent transformations for the same resource is a no-op.

Jump to

Keyboard shortcuts

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