Help us shape the future of Go! Take the 2026 Go Developer Survey

writer

package
v0.84.6 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 27 Imported by: 3

Documentation

Overview

Package writer contains the logic for sending payloads to the Datadog intake.

Index

Constants

This section is empty.

Variables

View Source
var MaxPayloadSize = 3200000 // 3.2MB is the maximum allowed by the Datadog API

MaxPayloadSize specifies the maximum accumulated payload size that is allowed before a flush is triggered; replaced in tests.

Functions

This section is empty.

Types

type DatadogStatsWriter added in v0.56.0

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

DatadogStatsWriter ingests stats buckets, combining them over time and flushing them to the API. This implements the stats.Writer interface.

func NewStatsWriter

func NewStatsWriter(
	cfg *config.AgentConfig,
	telemetryCollector telemetry.TelemetryCollector,
	statsd statsd.ClientInterface,
	timing timing.Reporter,
	containerTagsBuffer containertagsbuffer.ContainerTagsBuffer,
) *DatadogStatsWriter

NewStatsWriter returns a new DatadogStatsWriter. It must be started using Run.

func (*DatadogStatsWriter) FlushSync added in v0.56.0

func (w *DatadogStatsWriter) FlushSync() error

FlushSync blocks and sends pending payloads when syncMode is true

func (*DatadogStatsWriter) Run added in v0.56.0

func (w *DatadogStatsWriter) Run()

Run starts the DatadogStatsWriter, making it ready to receive stats and report w.statsd.

func (*DatadogStatsWriter) SendPayload added in v0.56.0

func (w *DatadogStatsWriter) SendPayload(p *pb.StatsPayload)

SendPayload sends a stats payload to the Datadog backend.

func (*DatadogStatsWriter) Stop added in v0.56.0

func (w *DatadogStatsWriter) Stop()

Stop stops a running DatadogStatsWriter.

func (*DatadogStatsWriter) UpdateAPIKey added in v0.59.0

func (w *DatadogStatsWriter) UpdateAPIKey(oldKey, newKey string)

UpdateAPIKey updates the API Key, if needed, on Stats Writer senders.

func (*DatadogStatsWriter) Write added in v0.56.0

func (w *DatadogStatsWriter) Write(sp *pb.StatsPayload)

Add appends this StatsPayload to the writer's buffer (flushing immediately if syncMode is enabled)

type SampledChunks

type SampledChunks struct {
	// TracerPayload contains all the chunks that were sampled as part of processing a payload.
	TracerPayload *pb.TracerPayload
	// Size represents the approximated message size in bytes (upper bound).
	Size int
	// SpanCount specifies the number of spans that were sampled as part of a trace inside the TracerPayload.
	SpanCount int64
	// EventCount specifies the total number of events found in Traces.
	EventCount int64
}

SampledChunks represents the result of a trace sampling operation.

type SampledChunksV1 added in v0.73.0

type SampledChunksV1 struct {
	TracerPayload *idx.InternalTracerPayload
	SpanCount     int64
	EventCount    int64
}

SampledChunksV1 is a wrapper around an InternalTracerPayload that contains the size of the payload, the number of spans, and the number of events

type TraceWriter

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

TraceWriter implements TraceWriter interface, and buffers traces and APM events, flushing them to the Datadog API.

func NewTraceWriter

func NewTraceWriter(
	cfg *config.AgentConfig,
	prioritySampler samplerTPSReader,
	errorsSampler samplerTPSReader,
	rareSampler samplerEnabledReader,
	telemetryCollector telemetry.TelemetryCollector,
	statsd statsd.ClientInterface,
	timing timing.Reporter,
	compressor compression.Component,
) *TraceWriter

NewTraceWriter returns a new TraceWriter. It is created for the given agent configuration and will accept incoming spans via the in channel.

func (*TraceWriter) FlushSync

func (w *TraceWriter) FlushSync() error

FlushSync blocks and sends pending payloads when syncMode is true

func (*TraceWriter) Stop

func (w *TraceWriter) Stop()

Stop stops the TraceWriter and attempts to flush whatever is left in the senders buffers.

func (*TraceWriter) UpdateAPIKey added in v0.59.0

func (w *TraceWriter) UpdateAPIKey(oldKey, newKey string)

UpdateAPIKey updates the API Key, if needed, on Trace Writer senders.

func (*TraceWriter) WriteChunks added in v0.56.0

func (w *TraceWriter) WriteChunks(pkg *SampledChunks)

WriteChunks serializes the provided chunks, enqueueing them to be sent

type TraceWriterV1 added in v0.73.0

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

TraceWriterV1 implements TraceWriterV1 interface, and buffers traces and APM events, flushing them to the Datadog API.

func NewTraceWriterV1 added in v0.73.0

func NewTraceWriterV1(
	cfg *config.AgentConfig,
	prioritySampler samplerTPSReader,
	errorsSampler samplerTPSReader,
	rareSampler samplerEnabledReader,
	telemetryCollector telemetry.TelemetryCollector,
	statsd statsd.ClientInterface,
	timing timing.Reporter,
	compressor compression.Component,
) *TraceWriterV1

NewTraceWriterV1 returns a new TraceWriterV1. It is created for the given agent configuration and will accept incoming spans via the in channel.

func (*TraceWriterV1) FlushSync added in v0.73.0

func (w *TraceWriterV1) FlushSync() error

FlushSync blocks and sends pending payloads when syncMode is true

func (*TraceWriterV1) Stop added in v0.73.0

func (w *TraceWriterV1) Stop()

Stop stops the TraceWriter and attempts to flush whatever is left in the senders buffers.

func (*TraceWriterV1) UpdateAPIKey added in v0.73.0

func (w *TraceWriterV1) UpdateAPIKey(oldKey, newKey string)

UpdateAPIKey updates the API Key, if needed, on Trace Writer senders.

func (*TraceWriterV1) WriteChunksV1 added in v0.73.0

func (w *TraceWriterV1) WriteChunksV1(pkg *SampledChunksV1)

WriteChunksV1 serializes the provided chunks, enqueueing them to be sent Chunks must not be used after this point as the trace writer may modify the payload in-place.

Jump to

Keyboard shortcuts

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