pdataconv

package
v0.49.2 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 12 Imported by: 1 module, 0 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 pdataconv is the optional OTel-Go bridge: it converts the collector pdata metrics type (pmetric.Metrics) into the storage library's internal, []byte-based metric.Metrics ingest batch. It exists so OTel users get zero-friction ingestion without the pdata dependency or its allocation profile reaching the storage hot path — pdata is referenced only here, never by the core packages or the storage facade.

The conversion necessarily allocates: pdata stores keys/values as Go strings, so projecting them to the internal []byte model copies each one. Embedders that decode OTLP protobuf themselves should build metric.Metrics directly (aliasing the decode buffer) to stay allocation-free; this bridge is the compatibility path, not the fast path.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendLogs added in v0.3.0

func AppendLogs(dst *log.Logs, ld plog.Logs) (dropped int)

AppendLogs converts an OTLP logs batch into dst, reusing dst's retained capacity (call log.Logs.Reset or use log.GetLogs for a recycled batch). dropped counts the records carrying no usable time at all (see [appendRecord]). Non-string record bodies are rendered to their textual form, since the internal model stores a body as text bytes.

func AppendProfiles added in v0.3.0

func AppendProfiles(dst *profile.Profiles, pd pprofile.Profiles) (dropped int)

AppendProfiles converts an OTLP profiles batch into dst, reusing dst's retained capacity (call profile.Profiles.Reset or use profile.GetProfiles for a recycled batch). The OTLP shared ProfilesDictionary maps one-to-one onto profile.Dictionary, so its tables are copied index-preserving (samples/stacks/locations keep referencing the same indices). Everything is representable, so dropped is always 0; it is returned for symmetry with AppendMetrics's point count (Dropped.Points).

func AppendTraces added in v0.3.0

func AppendTraces(dst *trace.Traces, td ptrace.Traces) (dropped int)

AppendTraces converts an OTLP traces batch into dst, reusing dst's retained capacity (call trace.Traces.Reset or use trace.GetTraces for a recycled batch). Every span, event, and link is representable, so dropped is always 0; it is returned for symmetry with AppendMetrics's point count (Dropped.Points) and to leave room for future unrepresentable cases.

Types

type Dropped added in v0.47.0

type Dropped struct {
	// Points is the number of data points that could not be represented.
	Points int
	// Exemplars is the number of exemplars that could not be represented — those on histogram,
	// exponential-histogram and summary points (see [AppendMetrics]), plus value-less ones.
	Exemplars int
}

Dropped counts what a conversion could not represent. Points and Exemplars are reported separately because they mean different things to a caller: Points feeds the OTLP partial-success response (a rejected data point is data the producer should retry), whereas a dropped exemplar only degrades trace correlation and must not inflate that count.

func AppendMetrics

func AppendMetrics(dst *metric.Metrics, md pmetric.Metrics) (dropped Dropped)

AppendMetrics converts an OTLP metrics batch into dst, reusing dst's retained capacity (call metric.Metrics.Reset or use metric.GetMetrics for a recycled batch). Gauge and sum number points convert directly, with their exemplars; histogram, exponential-histogram, and summary points are stored by **classic decomposition** into `_count`/`_sum`/`_bucket{le}`/`{quantile}` float series (see histogram.go), so they need no engine support.

**Exemplars on decomposed points are dropped, not stored**, and counted in Dropped.Exemplars. One histogram point becomes several series, so an exemplar on it has no unambiguous home; the Prometheus convention would attach it to the `_bucket` whose `le` covers its value, but committing to that before native histograms exist would bake the choice into the stored shape. Value-less number points are skipped and counted in Dropped.Points.

Jump to

Keyboard shortcuts

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