otlp

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: MIT Imports: 36 Imported by: 9

Documentation

Index

Constants

View Source
const (
	Yearly  = "2006"
	Monthly = "2006/01"
	Daily   = "2006/01/02"
	Hourly  = "2006/01/02/15"
)

Variables

View Source
var (
	ErrAlreadyClosed = errors.New("already closed")
	ErrNotStarted    = errors.New("not started")
)
View Source
var AllowedProtocols = allowedProtocols

AllowedProtocols is the list of allowed protocol values.

View Source
var DefaultServerMux = NewServerMux()

Functions

func AppendMetricData added in v0.3.0

func AppendMetricData(dst *metricspb.Metric, elem *metricspb.Metric) *metricspb.Metric

func AppendMetrics added in v0.3.0

func AppendMetrics(dst []*metricspb.Metric, elems ...*metricspb.Metric) []*metricspb.Metric

func AppendResourceLogs added in v0.3.0

func AppendResourceLogs(dst []*logspb.ResourceLogs, elems ...*logspb.ResourceLogs) []*logspb.ResourceLogs

func AppendResourceMetrics added in v0.3.0

func AppendResourceMetrics(dst []*metricspb.ResourceMetrics, elems ...*metricspb.ResourceMetrics) []*metricspb.ResourceMetrics

AppendResourceMetrics converts a list of ResourceMetrics into a list of ResourceMetrics with unique resources.

func AppendResourceSpans added in v0.3.0

func AppendResourceSpans(dst []*tracepb.ResourceSpans, elems ...*tracepb.ResourceSpans) []*tracepb.ResourceSpans

AppendResourceSpans converts a list of ResourceSpans into a list of ResourceSpans with unique resources.

func AppendScopeLogs added in v0.3.0

func AppendScopeLogs(dst []*logspb.ScopeLogs, elems ...*logspb.ScopeLogs) []*logspb.ScopeLogs

func AppendScopeMetrics added in v0.3.0

func AppendScopeMetrics(dst []*metricspb.ScopeMetrics, elems ...*metricspb.ScopeMetrics) []*metricspb.ScopeMetrics

func AppendScopeSpans added in v0.3.0

func AppendScopeSpans(dst []*tracepb.ScopeSpans, elems ...*tracepb.ScopeSpans) []*tracepb.ScopeSpans

func EqualAttributes added in v0.3.0

func EqualAttributes(attrs1 []*commonpb.KeyValue, attrs2 []*commonpb.KeyValue) bool

func EqualMetric added in v0.3.0

func EqualMetric(metric1 *metricspb.Metric, metric2 *metricspb.Metric) bool

func EqualResource added in v0.3.0

func EqualResource(resource1 *resourcepb.Resource, resource2 *resourcepb.Resource) bool

func EqualScope added in v0.3.0

func EqualScope(scope1 *commonpb.InstrumentationScope, scope2 *commonpb.InstrumentationScope) bool

func FilterResourceLogs added in v0.4.0

func FilterResourceLogs(src []*logspb.ResourceLogs, filters ...func(*resourcepb.Resource, *commonpb.InstrumentationScope, *logspb.LogRecord) bool) []*logspb.ResourceLogs

FilterResourceLogs filters the given ResourceLogs slice based on the given filter function.

func FilterResourceMetrics added in v0.4.0

FilterResourceMetrics filters the given ResourceMetrics slice based on the given filter function.

func FilterResourceSpans added in v0.4.0

func FilterResourceSpans(src []*tracepb.ResourceSpans, filters ...func(*resourcepb.Resource, *commonpb.InstrumentationScope, *tracepb.Span) bool) []*tracepb.ResourceSpans

FilterResourceSpans filters the given ResourceSpans slice based on the given filter function.

func HeadersFromContext

func HeadersFromContext(ctx context.Context) (http.Header, bool)

func LogRecordInTimeRangeFilter added in v0.4.0

func LogRecordInTimeRangeFilter(start, end time.Time) func(*resourcepb.Resource, *commonpb.InstrumentationScope, *logspb.LogRecord) bool

func MarshalIndentJSON added in v0.2.4

func MarshalIndentJSON(msg proto.Message, indent string) ([]byte, error)

MarshalIndentJSON marshals a proto.Message to indented JSON bytes. for OTLP, traceID and spanID are converted from base64 to hex.

func MarshalJSON added in v0.2.4

func MarshalJSON(msg proto.Message) ([]byte, error)

MarshalJSON marshals a proto.Message to JSON bytes. for OTLP, traceID and spanID are converted from base64 to hex.

func MetricDataPointInTimeRangeFilter added in v0.4.0

func MetricDataPointInTimeRangeFilter(start, end time.Time) func(*resourcepb.Resource, *commonpb.InstrumentationScope, *metricspb.Metric) bool

MetricInTimeRangeFilter returns a filter function that filters metrics based on the given time range.

func PartitionByLogObservedTime added in v0.3.0

func PartitionByLogObservedTime(format string, tz *time.Location) func(*logspb.ResourceLogs) string

PartitionByLogObservedTime returns a function that partitions ResourceLogs by Log observation time.

func PartitionByLogSeverityNumber added in v0.3.0

func PartitionByLogSeverityNumber() func(*logspb.ResourceLogs) string

PartitionByLogSeverityNumber returns a function that partitions ResourceLogs by Log severity number.

func PartitionByLogSeverityText added in v0.3.0

func PartitionByLogSeverityText() func(*logspb.ResourceLogs) string

PartitionByLogSeverityText returns a function that partitions ResourceLogs by Log severity text.

func PartitionByLogTime added in v0.3.0

func PartitionByLogTime(format string, tz *time.Location) func(*logspb.ResourceLogs) string

PartitionByLogTime returns a function that partitions ResourceLogs by Log time.

func PartitionByMetricStartTime added in v0.3.0

func PartitionByMetricStartTime(format string, tz *time.Location) func(*metricspb.ResourceMetrics) string

PartitionByMetricStartTime returns a function that partitions ResourceMetrics by Metric start time.

func PartitionByMetricTime added in v0.3.0

func PartitionByMetricTime(format string, tz *time.Location) func(*metricspb.ResourceMetrics) string

PartitionByMetricTime returns a function that partitions ResourceMetrics by Metric time.

func PartitionByMetricType added in v0.3.0

func PartitionByMetricType() func(*metricspb.ResourceMetrics) string

func PartitionBySpanEndTime added in v0.3.0

func PartitionBySpanEndTime(format string, tz *time.Location) func(*tracepb.ResourceSpans) string

PartitionBySpanEndTime returns a function that partitions ResourceSpans by Span end time.

func PartitionBySpanStartTime added in v0.3.0

func PartitionBySpanStartTime(format string, tz *time.Location) func(*tracepb.ResourceSpans) string

PartitionBySpanStartTime returns a function that partitions ResourceSpans by Span start time.

func PartitionResourceLogs added in v0.3.0

func PartitionResourceLogs(src []*logspb.ResourceLogs, getPartitionKey func(*logspb.ResourceLogs) string) map[string][]*logspb.ResourceLogs

PartitionResourceLogs partitions the given ResourceLogs slice into multiple ResourceLogs slices, each containing only one log record, based on the given partition key.

func PartitionResourceMetrics added in v0.3.0

func PartitionResourceMetrics(src []*metricspb.ResourceMetrics, getPartitionKey func(*metricspb.ResourceMetrics) string) map[string][]*metricspb.ResourceMetrics

PartitionResourceMetrics partitions the given ResourceMetrics slice into multiple ResourceMetrics slices, each containing only one data point, based on the given partition key.

func PartitionResourceSpans added in v0.3.0

func PartitionResourceSpans(src []*tracepb.ResourceSpans, getPartitionKey func(*tracepb.ResourceSpans) string) map[string][]*tracepb.ResourceSpans

PartitionResourceSpans partitions the given ResourceSpans slice into multiple ResourceSpans slices, each containing only one Span, based on the given partition key.

func SpanInTimeRangeFilter added in v0.4.0

func SpanInTimeRangeFilter(start, end time.Time) func(*resourcepb.Resource, *commonpb.InstrumentationScope, *tracepb.Span) bool

SpanInTimeRangeFilter returns a filter function that filters spans based on the given time range.

func SplitResourceLogs added in v0.3.0

func SplitResourceLogs(src []*logspb.ResourceLogs) []*logspb.ResourceLogs

SplitResourceLogs splits the given ResourceLogs slice into multiple ResourceLogs slices, each containing only one log record.

func SplitResourceMetrics added in v0.3.0

func SplitResourceMetrics(src []*metricspb.ResourceMetrics) []*metricspb.ResourceMetrics

SplitResourceMetrics splits the given ResourceMetrics slice into multiple ResourceMetrics slices, each containing only one data point.

func SplitResourceSpans added in v0.3.0

func SplitResourceSpans(src []*tracepb.ResourceSpans) []*tracepb.ResourceSpans

SplitResourceSpans splits the given ResourceSpans slice into multiple ResourceSpans slices, each containing only one Span.

func TotalDataPoints added in v0.3.0

func TotalDataPoints(src []*metricspb.ResourceMetrics) int

TotalDataPoints returns the total number of data points in the given ResourceMetrics slice.

func TotalLogRecords added in v0.3.0

func TotalLogRecords(src []*logspb.ResourceLogs) int

TotalLogRecords returns the total number of log records in the given ResourceLogs slice.

func TotalSpans added in v0.3.0

func TotalSpans(src []*tracepb.ResourceSpans) int

TotalSpans returns the total number of spans in the given ResourceSpans slice.

func UnmarshalJSON added in v0.2.4

func UnmarshalJSON(data []byte, msg proto.Message) error

UnmarshalJSON unmarshals JSON bytes to a proto.Message. for OTLP, traceID and spanID are converted from hex to base64.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is OTLP Low-Level Client

func NewClient

func NewClient(endpoint string, opts ...ClientOption) (*Client, error)

func (*Client) Start

func (c *Client) Start(ctx context.Context) error

func (*Client) Stop

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

func (*Client) UploadLogs

func (c *Client) UploadLogs(ctx context.Context, protoLogs []*ResourceLogs) error

func (*Client) UploadMetrics

func (c *Client) UploadMetrics(ctx context.Context, protoMetrics []*ResourceMetrics) error

func (*Client) UploadTraces

func (c *Client) UploadTraces(ctx context.Context, protoSpans []*ResourceSpans) error

type ClientOption

type ClientOption func(*clientOptions) error

func ClientOptionsWithFlagSet added in v0.2.1

func ClientOptionsWithFlagSet(fs *flag.FlagSet, flagPrefix string, envPrefixes ...string) ClientOption

ClientOptionsWithFlagSet returns the client options from the flag set.

func DefaultClientOptions

func DefaultClientOptions(envPrefixes ...string) ClientOption

DefaultClientOptions returns the default client options from the environment variables. see https://opentelemetry.io/docs/specs/otel/protocol/exporter e.g. envPrefixes = []string{"OTEL_EXPORTER_"} OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317

func WithEndpoint

func WithEndpoint(endpoint string) ClientOption

WithEndpoint sets the endpoint to be used with the request.

func WithExportTimeout

func WithExportTimeout(exportTimeout time.Duration) ClientOption

WithExportTimeout sets the timeout to be used with the request.

func WithGzip

func WithGzip(gzip bool) ClientOption

WithGzip sets the gzip compression to be used with the request.

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) ClientOption

WithHTTPClient sets the http client to be used with the request.

func WithHeaders

func WithHeaders(headers map[string]string) ClientOption

WithHeaders sets the headers to be sent with the request.

func WithHeadersString added in v0.2.1

func WithHeadersString(headers string) ClientOption

WithHeadersString sets the headers to be sent with the request. e.g. "key1=value1,key2=value2"

func WithLogger

func WithLogger(logger *slog.Logger) ClientOption

WithLogger sets the logger to be used with the request.

func WithLogsEndpoint

func WithLogsEndpoint(endpoint string) ClientOption

WithLogsEndpoint sets the endpoint to be used with the log request. by default, the endpoint is shared with all signals.

func WithLogsExportTimeout

func WithLogsExportTimeout(exportTimeout time.Duration) ClientOption

WithLogsExportTimeout sets the timeout to be used with the log request. by default, the timeout is shared with all signals.

func WithLogsGzip

func WithLogsGzip(gzip bool) ClientOption

WithLogsGzip sets the gzip compression to be used with the log request. by default, the gzip compression is shared with all signals.

func WithLogsHTTPClient

func WithLogsHTTPClient(httpClient *http.Client) ClientOption

WithLogsHTTPClient sets the http client to be used with the log request. by default, the http client is shared with all signals.

func WithLogsHeaders

func WithLogsHeaders(headers map[string]string) ClientOption

WithLogsHeaders sets the headers to be sent with the log request. by default, the headers are shared with all signals.

func WithLogsHeadersString added in v0.2.1

func WithLogsHeadersString(headers string) ClientOption

WithLogsHeadersString sets the headers to be sent with the log request. by default, the headers are shared with all signals. e.g. "key1=value1,key2=value2"

func WithLogsProtocol

func WithLogsProtocol(protocol string) ClientOption

WithLogsProtocol sets the protocol to be used with the log request. by default, the protocol is shared with all signals.

func WithLogsUserAgent

func WithLogsUserAgent(userAgent string) ClientOption

WithLogsUserAgent sets the user agent to be sent with the log request. by default, the user agent is shared with all signals.

func WithMetricsEndpoint

func WithMetricsEndpoint(endpoint string) ClientOption

WithMetricsEndpoint sets the endpoint to be used with the metrics request. by default, the endpoint is shared with all signals.

func WithMetricsExportTimeout

func WithMetricsExportTimeout(exportTimeout time.Duration) ClientOption

WithMetricsExportTimeout sets the timeout to be used with the metrics request. by default, the timeout is shared with all signals.

func WithMetricsGzip

func WithMetricsGzip(gzip bool) ClientOption

WithMetricsGzip sets the gzip compression to be used with the metrics request. by default, the gzip compression is shared with all signals.

func WithMetricsHTTPClient

func WithMetricsHTTPClient(httpClient *http.Client) ClientOption

WithMetricsHTTPClient sets the http client to be used with the metrics request. by default, the http client is shared with all signals.

func WithMetricsHeaders

func WithMetricsHeaders(headers map[string]string) ClientOption

WithMetricsHeaders sets the headers to be sent with the metrics request. by default, the headers are shared with all signals.

func WithMetricsHeadersString added in v0.2.1

func WithMetricsHeadersString(headers string) ClientOption

WithMetricsHeadersString sets the headers to be sent with the metrics request. by default, the headers are shared with all signals. e.g. "key1=value1,key2=value2"

func WithMetricsProtocol

func WithMetricsProtocol(protocol string) ClientOption

WithMetricsProtocol sets the protocol to be used with the metrics request. by default, the protocol is shared with all signals.

func WithMetricsUserAgent

func WithMetricsUserAgent(userAgent string) ClientOption

WithMetricsUserAgent sets the user agent to be sent with the metrics request. by default, the user agent is shared with all signals.

func WithProtocol

func WithProtocol(protocol string) ClientOption

WithProtocol sets the protocol to be used with the request.

func WithTracesEndpoint

func WithTracesEndpoint(endpoint string) ClientOption

WithTracesEndpoint sets the endpoint to be used with the trace request. by default, the endpoint is shared with all signals.

func WithTracesExportTimeout

func WithTracesExportTimeout(exportTimeout time.Duration) ClientOption

WithTracesExportTimeout sets the timeout to be used with the trace request. by default, the timeout is shared with all signals.

func WithTracesGzip

func WithTracesGzip(gzip bool) ClientOption

WithTracesGzip sets the gzip compression to be used with the trace request. by default, the gzip compression is shared with all signals.

func WithTracesHTTPClient

func WithTracesHTTPClient(httpClient *http.Client) ClientOption

WithTracesHTTPClient sets the http client to be used with the trace request. by default, the http client is shared with all signals.

func WithTracesHeaders

func WithTracesHeaders(headers map[string]string) ClientOption

WithTracesHeaders sets the headers to be sent with the trace request. by default, the headers are shared with all signals.

func WithTracesHeadersString added in v0.2.1

func WithTracesHeadersString(headers string) ClientOption

WithTracesHeadersString sets the headers to be sent with the trace request. by default, the headers are shared with all signals. e.g. "key1=value1,key2=value2"

func WithTracesProtocol

func WithTracesProtocol(protocol string) ClientOption

WithTracesProtocol sets the protocol to be used with the trace request. by default, the protocol is shared with all signals.

func WithTracesUserAgent

func WithTracesUserAgent(userAgent string) ClientOption

WithTracesUserAgent sets the user agent to be sent with the trace request. by default, the user agent is shared with all signals.

func WithUserAgent

func WithUserAgent(userAgent string) ClientOption

WithUserAgent sets the user agent to be sent with the request.

type JSONDecoder added in v0.2.4

type JSONDecoder struct {
	// contains filtered or unexported fields
}

func NewJSONDecoder added in v0.2.4

func NewJSONDecoder(reader io.Reader) *JSONDecoder

func (*JSONDecoder) Decode added in v0.2.4

func (d *JSONDecoder) Decode(msg proto.Message) error

func (*JSONDecoder) More added in v0.2.4

func (d *JSONDecoder) More() bool

type JSONEncoder added in v0.2.4

type JSONEncoder struct {
	// contains filtered or unexported fields
}

func NewJSONEncoder added in v0.2.4

func NewJSONEncoder(writer io.Writer) *JSONEncoder

func (*JSONEncoder) Encode added in v0.2.4

func (e *JSONEncoder) Encode(msg proto.Message) error

func (*JSONEncoder) SetIndent added in v0.2.4

func (e *JSONEncoder) SetIndent(indent string)

type LogsEntry

type LogsEntry interface {
	Handle(handler LogsHandler)
	HandleFunc(handler func(ctx context.Context, request *LogsRequest) (*LogsResponse, error))
	Use(m ...LogsMiddlewareFunc) LogsEntry
}

type LogsHandler

type LogsHandler interface {
	HandleLogs(ctx context.Context, request *LogsRequest) (*LogsResponse, error)
}

type LogsHandlerFunc

type LogsHandlerFunc func(ctx context.Context, request *LogsRequest) (*LogsResponse, error)

func (LogsHandlerFunc) HandleLogs

func (f LogsHandlerFunc) HandleLogs(ctx context.Context, request *LogsRequest) (*LogsResponse, error)

type LogsMiddlewareFunc

type LogsMiddlewareFunc func(next LogsHandler) LogsHandler

type LogsRequest

type LogsRequest = logspb.ExportLogsServiceRequest

type LogsResponse

type LogsResponse = logspb.ExportLogsServiceResponse

type MetricsEntry

type MetricsEntry interface {
	Handle(handler MetricsHandler)
	HandleFunc(handler func(ctx context.Context, request *MetricsRequest) (*MetricsResponse, error))
	Use(m ...MetricsMiddlewareFunc) MetricsEntry
}

type MetricsHandler

type MetricsHandler interface {
	HandleMetrics(ctx context.Context, request *MetricsRequest) (*MetricsResponse, error)
}

type MetricsHandlerFunc

type MetricsHandlerFunc func(ctx context.Context, request *MetricsRequest) (*MetricsResponse, error)

func (MetricsHandlerFunc) HandleMetrics

func (f MetricsHandlerFunc) HandleMetrics(ctx context.Context, request *MetricsRequest) (*MetricsResponse, error)

type MetricsMiddlewareFunc

type MetricsMiddlewareFunc func(next MetricsHandler) MetricsHandler

type MiddlewareFunc

type MiddlewareFunc func(next ProtoHandlerFunc) ProtoHandlerFunc

type ProtoHandlerFunc

type ProtoHandlerFunc func(context.Context, proto.Message) (proto.Message, error)

type ResourceLogs

type ResourceLogs = logspb.ResourceLogs

type ResourceMetrics

type ResourceMetrics = metricspb.ResourceMetrics

type ResourceSpans

type ResourceSpans = tracepb.ResourceSpans

type ServerMux

type ServerMux struct {
	// contains filtered or unexported fields
}

func NewServerMux

func NewServerMux() *ServerMux

func (*ServerMux) Logs

func (mux *ServerMux) Logs() LogsEntry

func (*ServerMux) Metrics

func (mux *ServerMux) Metrics() MetricsEntry

func (*ServerMux) Register

func (mux *ServerMux) Register(reg grpc.ServiceRegistrar)

func (*ServerMux) ServeHTTP

func (mux *ServerMux) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*ServerMux) SetLogger added in v0.2.4

func (mux *ServerMux) SetLogger(logger *slog.Logger)

func (*ServerMux) Trace

func (mux *ServerMux) Trace() TraceEntry

func (*ServerMux) Use

func (mux *ServerMux) Use(m ...MiddlewareFunc) *ServerMux

type TraceEntry

type TraceEntry interface {
	Handle(handler TraceHandler)
	HandleFunc(handler func(ctx context.Context, request *TraceRequest) (*TraceResponse, error))
	Use(m ...TraceMiddlewareFunc) TraceEntry
}

type TraceHandler

type TraceHandler interface {
	HandleTrace(ctx context.Context, request *TraceRequest) (*TraceResponse, error)
}

TraceHandler is an interface that must be implemented by the user of the Server to handle trace requests.

type TraceHandlerFunc

type TraceHandlerFunc func(ctx context.Context, request *TraceRequest) (*TraceResponse, error)

TraceHandlerFunc is a function type that implements the TraceHandler interface.

func (TraceHandlerFunc) HandleTrace

func (f TraceHandlerFunc) HandleTrace(ctx context.Context, request *TraceRequest) (*TraceResponse, error)

type TraceMiddlewareFunc

type TraceMiddlewareFunc func(next TraceHandler) TraceHandler

type UploadLogsPartialSuccessError

type UploadLogsPartialSuccessError struct {
	// contains filtered or unexported fields
}

func (*UploadLogsPartialSuccessError) Error

func (*UploadLogsPartialSuccessError) Response

type UploadMetricsPartialSuccessError

type UploadMetricsPartialSuccessError struct {
	// contains filtered or unexported fields
}

func (*UploadMetricsPartialSuccessError) Error

func (*UploadMetricsPartialSuccessError) Response

type UploadTracesPartialSuccessError

type UploadTracesPartialSuccessError struct {
	// contains filtered or unexported fields
}

func (*UploadTracesPartialSuccessError) Error

func (*UploadTracesPartialSuccessError) Response

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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