otel

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package otel provides functionality for managing OpenTelemetry collector processes.

Index

Constants

View Source
const (
	// DefaultCollectorBinary is the default path to the otel-collector binary
	DefaultCollectorBinary = "/bin/otel-collector"

	// DefaultLogsDir is the default directory for logs
	DefaultLogsDir = "/var/log/apoxy"

	// CollectorStdoutLogFile is the name of the collector stdout log file
	CollectorStdoutLogFile = "otel-collector.stdout.log"

	// CollectorStderrLogFile is the name of the collector stderr log file
	CollectorStderrLogFile = "otel-collector.stderr.log"

	// DefaultConfigPath is the default path to the otel-collector config file
	DefaultConfigPath = "/etc/otelcol/config.yaml"

	// Default collector port
	DefaultCollectorPort = 4317
)

Variables

This section is empty.

Functions

func RenderConfigTemplate

func RenderConfigTemplate(vars TemplateVars) (string, error)

RenderConfigTemplate renders the OpenTelemetry collector config template with the provided variables

Types

type Collector

type Collector struct {
	// CollectorBinary is the path to the otel-collector binary
	CollectorBinary string
	// LogsDir is the directory where logs will be written
	LogsDir string
	// ConfigPath is the path to the otel-collector config file
	ConfigPath string
	// Args are additional arguments to pass to the otel-collector
	Args []string
	// ClickHouseOpts are the options for the ClickHouse exporter
	ClickHouseOpts *clickhouse.Options
	// contains filtered or unexported fields
}

Collector manages the OpenTelemetry collector process.

func (*Collector) Start

func (c *Collector) Start(ctx context.Context, opts ...Option) error

Start starts the otel-collector process.

func (*Collector) Status

func (c *Collector) Status() CollectorStatus

Status returns the current status of the otel-collector process.

func (*Collector) Stop

func (c *Collector) Stop(ctx context.Context) error

Stop stops the otel-collector process.

type CollectorStatus

type CollectorStatus struct {
	StartedAt time.Time
	Running   bool
	ProcState *os.ProcessState
}

CollectorStatus represents the status of the otel-collector process.

type Option

type Option func(*Collector)

Option configures a Collector.

func WithArgs

func WithArgs(args ...string) Option

WithArgs sets additional arguments to pass to the otel-collector.

func WithCollectorBinary

func WithCollectorBinary(path string) Option

WithCollectorBinary sets the path to the otel-collector binary.

func WithConfig

func WithConfig(configPath string) Option

WithConfig sets the configuration file path for the otel-collector.

func WithLogsDir

func WithLogsDir(path string) Option

WithLogsDir sets the directory where logs will be written.

type TemplateVars

type TemplateVars struct {
	OTLPPort                    int
	ClickHouseAddr              string
	ClickHouseDatabase          string
	EnableClickHouse            bool
	OTLPTracesEndpoint          string
	OTLPTracesProtocol          string
	OTLPTracesInsecure          bool
	OTLPTracesCertificate       string
	OTLPTracesClientKey         string
	OTLPTracesClientCertificate string
}

TemplateVars represents the variables used in the OpenTelemetry collector config template

Jump to

Keyboard shortcuts

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