serializeprofiles

package
v0.133.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const EcsVersionString = "1.12.0"

EcsVersionString is the value for the `ecs.version` metrics field. It is relatively arbitrary and currently has no consumer. APM server is using 1.12.0. We stick with it as well.

View Source
const ExeMetadataUpsertScript = `` /* 411-byte string literal not displayed */

Script written in Painless that will both create a new document (if DocID does not exist), and update timestamp of an existing document. Named parameters are used to improve performance re: script compilation (since the script does not change across executions, it can be compiled once and cached).

Variables

This section is empty.

Functions

func GetStartOfWeekFromTime

func GetStartOfWeekFromTime(t time.Time) uint32

func IndexDownsampledEvent added in v0.122.0

func IndexDownsampledEvent(event StackTraceEvent, pushData func(any, string, string) error) error

Types

type EcsVersion

type EcsVersion struct {
	V string `json:"ecs.version"`
}

EcsVersion is a struct to hold the `ecs.version` metrics field. Used as a helper in ES index struct types.

type ExeMetadata

type ExeMetadata struct {
	DocID string `json:"-"`
	// ScriptedUpsert needs to be 'true' for the script to execute regardless of the
	// document existing or not.
	ScriptedUpsert bool              `json:"scripted_upsert"`
	Script         ExeMetadataScript `json:"script"`
	// This needs to exist for document creation to succeed (if document does not exist),
	// but can be empty as the script implements both document creation and updating.
	Upsert struct{} `json:"upsert"`
}

ExeMetadata represents executable metadata serializable into the executables index. DocID should be the base64-encoded FileID.

func NewExeMetadata

func NewExeMetadata(docID string, lastSeen uint32, buildID, fileName string) ExeMetadata

type ExeMetadataParams

type ExeMetadataParams struct {
	LastSeen   uint32 `json:"timestamp"`
	BuildID    string `json:"buildid"`
	FileName   string `json:"filename"`
	EcsVersion string `json:"ecsversion"`
}

type ExeMetadataScript

type ExeMetadataScript struct {
	Source string            `json:"source"`
	Params ExeMetadataParams `json:"params"`
}

type StackFrame

type StackFrame struct {
	EcsVersion
	DocID          string   `json:"-"`
	FileName       []string `json:"Stackframe.file.name,omitempty"`
	FunctionName   []string `json:"Stackframe.function.name,omitempty"`
	LineNumber     []int32  `json:"Stackframe.line.number,omitempty"`
	FunctionOffset []int32  `json:"Stackframe.function.offset,omitempty"`
}

StackFrame represents a stacktrace serializable into the stackframes index. DocID should be the base64-encoded FileID+Address (24 bytes). To simplify the unmarshalling for readers, we use arrays here, even though host agent doesn't send inline information yet. The symbolizer already stores arrays, which requires the reader to handle both formats if we don't use arrays here.

type StackPayload

type StackPayload struct {
	StackTraceEvent StackTraceEvent
	StackTrace      StackTrace
	StackFrames     []StackFrame
	Executables     []ExeMetadata

	UnsymbolizedLeafFrames  []UnsymbolizedLeafFrame
	UnsymbolizedExecutables []UnsymbolizedExecutable
}

StackPayload represents a single StackTraceEvent, with a StackTrace, a map of [StackFrames] and a map of ExeMetadata that have been serialized, and need to be ingested into ES.

func Transform

Transform transforms a pprofile.Profile into our own representation, for ingestion into Elasticsearch

type StackTrace

type StackTrace struct {
	EcsVersion
	DocID    string `json:"-"`
	FrameIDs string `json:"Stacktrace.frame.ids"`
	Types    string `json:"Stacktrace.frame.types"`
}

StackTrace represents a stacktrace serializable into the stacktraces index. DocID should be the base64-encoded Stacktrace ID.

type StackTraceEvent

type StackTraceEvent struct {
	EcsVersion
	TimeStamp    unixTime64 `json:"@timestamp"`
	HostID       string     `json:"host.id"`
	StackTraceID string     `json:"Stacktrace.id"` // 128-bit hash in binary form

	// Event-specific metadata
	PodName          string `json:"orchestrator.resource.name,omitempty"`
	ContainerID      string `json:"container.id,omitempty"`
	ContainerName    string `json:"container.name,omitempty"`
	K8sNamespaceName string `json:"k8s.namespace.name,omitempty"`
	ThreadName       string `json:"process.thread.name"`
	ExecutableName   string `json:"process.executable.name"`
	ServiceName      string `json:"service.name,omitempty"`
	Frequency        int64  `json:"Stacktrace.sampling_frequency"`
	Count            uint16 `json:"Stacktrace.count"`
}

StackTraceEvent represents a stacktrace event serializable into ES. The json field names need to be case-sensitively equal to the fields defined in the schema mapping.

type UnsymbolizedExecutable added in v0.123.0

type UnsymbolizedExecutable struct {
	EcsVersion
	DocID   string    `json:"-"`
	FileID  []string  `json:"Executable.file.id"`
	Created time.Time `json:"Time.created"`
	Next    time.Time `json:"Symbolization.time.next"`
	Retries int       `json:"Symbolization.retries"`
}

UnsymbolizedExecutable represents an array of executable FileIDs written into the executable symbolization queue index.

type UnsymbolizedLeafFrame added in v0.123.0

type UnsymbolizedLeafFrame struct {
	EcsVersion
	DocID   string    `json:"-"`
	FrameID []string  `json:"Stacktrace.frame.id"`
	Created time.Time `json:"Time.created"`
	Next    time.Time `json:"Symbolization.time.next"`
	Retries int       `json:"Symbolization.retries"`
}

UnsymbolizedLeafFrame represents an array of frame IDs written into the leaf frame symbolization queue index.

Jump to

Keyboard shortcuts

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