Documentation
¶
Overview ¶
Package model provides Go structs describing the APM output data model, and methods for encoding them to the Elasticsearch document JSON structure.
Index ¶
- Variables
- type APMEvent
- type Agent
- type AggregatedDuration
- type Batch
- type BatchProcessor
- type Child
- type Client
- type Cloud
- type CloudOrigin
- type Composite
- type Container
- type DB
- type DataStream
- type Destination
- type DestinationService
- type Device
- type DeviceModel
- type DroppedSpanStats
- type Error
- type ErrorLog
- type Event
- type Exception
- type FAAS
- type Framework
- type HTTP
- type HTTPRequest
- type HTTPResponse
- type Histogram
- type Host
- type Kubernetes
- type LabelValue
- type Labels
- type Language
- type Log
- type LogOrigin
- type LogOriginFile
- type LongtaskMetrics
- type Message
- type MetricType
- type Metricset
- type MetricsetSample
- type NAT
- type Network
- type NetworkCarrier
- type NetworkConnection
- type NumericLabelValue
- type NumericLabels
- type OS
- type Observer
- type Original
- type Parent
- type Process
- type ProcessBatchFunc
- type ProcessThread
- type Processor
- type Runtime
- type Service
- type ServiceNode
- type ServiceOrigin
- type ServiceTarget
- type Session
- type Source
- type Span
- type SpanCount
- type SpanLink
- type Stacktrace
- type StacktraceFrame
- type SummaryMetric
- type Trace
- type Transaction
- type TransactionMark
- type TransactionMarks
- type URL
- type User
- type UserAgent
- type UserExperience
Constants ¶
This section is empty.
Variables ¶
var ( // ErrorProcessor is the Processor value that should be assigned to error events. ErrorProcessor = Processor{Name: "error", Event: "error"} )
var ( // LogProcessor is the Processor value that should be assigned to log events. LogProcessor = Processor{Name: "log", Event: "log"} )
var ( // MetricsetProcessor is the Processor value that should be assigned to metricset events. MetricsetProcessor = Processor{Name: "metric", Event: "metric"} )
var ( // SpanProcessor is the Processor value that should be assigned to span events. SpanProcessor = Processor{Name: "transaction", Event: "span"} )
var ( // TransactionProcessor is the Processor value that should be assigned to transaction events. TransactionProcessor = Processor{Name: "transaction", Event: "transaction"} )
Functions ¶
This section is empty.
Types ¶
type APMEvent ¶
type APMEvent struct { // DataStream optionally holds data stream identifiers. DataStream DataStream Event Event Agent Agent Observer Observer Container Container Kubernetes Kubernetes Service Service Process Process Device Device Host Host User User UserAgent UserAgent Client Client Source Source Destination Destination Cloud Cloud Network Network Session Session URL URL Processor Processor Trace Trace Parent Parent Child Child HTTP HTTP FAAS FAAS Log Log // Timestamp holds the event timestamp. // // See https://www.elastic.co/guide/en/ecs/current/ecs-base.html#field-timestamp Timestamp time.Time // Labels holds the string (keyword) labels to apply to the event, stored as // keywords. Supports slice values. // // See https://www.elastic.co/guide/en/ecs/current/ecs-base.html#field-labels Labels Labels // NumericLabels holds the numeric (scaled_float) labels to apply to the event. // Supports slice values. NumericLabels NumericLabels // Message holds the message for log events. // // See https://www.elastic.co/guide/en/ecs/current/ecs-base.html#field-message Message string Transaction *Transaction Span *Span Metricset *Metricset Error *Error }
APMEvent holds the details of an APM event.
Exactly one of the event fields should be non-nil.
func (*APMEvent) MarshalFastJSON ¶
MarshalFastJSON marshals e as JSON, writing the result to w.
func (*APMEvent) MarshalJSON ¶
MarshalJSON marshals e as JSON.
type AggregatedDuration ¶
type AggregatedDuration struct { // Count holds the number of durations aggregated. Count int // Sum holds the sum of aggregated durations. Sum time.Duration }
AggregatedDuration holds a count and sum of aggregated durations.
type BatchProcessor ¶
type BatchProcessor interface { // ProcessBatch is called with a batch of events for processing. // // Processing may involve anything, e.g. modifying, adding, removing, // aggregating, or publishing events. // // The caller should not assume the batch to be valid after the // method has returned. // If the batch needs to be processed asynchronously or kept around, // the processor must create a copy of the slice. ProcessBatch(context.Context, *Batch) error }
BatchProcessor can be used to process a batch of events, giving the opportunity to update, add or remove events.
type Child ¶
type Child struct { // ID holds IDs of child events. ID []string }
Child holds information about the children of a trace event.
type Client ¶
type Client struct { // Domain holds the client's domain (FQDN). Domain string // IP holds the client's IP address. IP netip.Addr // Port holds the client's IP port. Port int }
Client holds information about the client of a request.
type Cloud ¶
type Cloud struct { AccountID string AccountName string AvailabilityZone string InstanceID string InstanceName string MachineType string ProjectID string ProjectName string Provider string Region string ServiceName string Origin *CloudOrigin }
Cloud holds information about the cloud computing environment in which a service is running.
type CloudOrigin ¶
type DB ¶
type DB struct { Instance string Statement string Type string UserName string Link string RowsAffected *int }
DB contains information related to a database query of a span event
type DataStream ¶
type DataStream struct { // Type holds the data_stream.type identifier. Type string // Dataset holds the data_stream.dataset identifier. Dataset string // Namespace holds the data_stream.namespace identifier. Namespace string }
DataStream identifies the data stream to which an event will be written.
type Destination ¶
Destination holds information about the destination of a request.
type DestinationService ¶
type DestinationService struct { Type string // Deprecated Name string // Deprecated Resource string // Deprecated // ResponseTime holds aggregated span durations for the destination service resource. ResponseTime AggregatedDuration }
DestinationService contains information about the destination service of a span event
type Device ¶
type Device struct { // ID holds the unique identifier of a device. ID string // Model holds information about the device model. Model DeviceModel // Manufacturer the vendor name of the device manufacturer. Manufacturer string }
type DeviceModel ¶
type DroppedSpanStats ¶
type DroppedSpanStats struct { DestinationServiceResource string ServiceTargetType string ServiceTargetName string Outcome string Duration AggregatedDuration }
type Error ¶
type Error struct { ID string GroupingKey string Culprit string Custom map[string]any // StackTrace holds an unparsed stack trace. // // This may be set when a stack trace cannot be parsed. StackTrace string // Message holds an error message. // // Message is the ECS field equivalent of the APM field `error.log.message`. Message string // Type holds the type of the error. Type string Exception *Exception Log *ErrorLog }
type ErrorLog ¶
type ErrorLog struct { Message string Level string ParamMessage string LoggerName string Stacktrace Stacktrace }
type Event ¶
type Event struct { // Duration holds the event duration. // // Duration is only added as a field (`duration`) if greater than zero. Duration time.Duration // Outcome holds the event outcome: "success", "failure", or "unknown". Outcome string // Severity holds the numeric severity of the event for log events. Severity int64 // Action holds the action captured by the event for log events. Action string // Dataset holds the the dataset which produces the events. If an event // source publishes more than one type of log or events (e.g. access log, // error log), the dataset is used to specify which one the event comes from. Dataset string }
Event holds information about an event, in ECS terms.
type FAAS ¶
type FAAS struct { ID string Coldstart *bool Execution string TriggerType string TriggerRequestID string Name string Version string }
FAAS holds information about a function as a service.
type HTTP ¶
type HTTP struct { Version string Request *HTTPRequest Response *HTTPResponse }
HTTP holds information about an HTTP request and/or response.
type HTTPRequest ¶
type HTTPRequest struct { ID string Method string Referrer string Body interface{} Headers map[string]any Env map[string]any Cookies map[string]any }
HTTPRequest holds information about an HTTP request.
type HTTPResponse ¶
type HTTPResponse struct { StatusCode int Headers map[string]any Finished *bool HeadersSent *bool TransferSize *int EncodedBodySize *int DecodedBodySize *int }
HTTPResponse holds information about an HTTP response.
type Histogram ¶
type Histogram struct { // Values holds the bucket values for histogram metrics. // // These values must be provided in ascending order. Values []float64 // Counts holds the bucket counts for histogram metrics. // // These numbers must be positive or zero. // // If Counts is specified, then Values is expected to be // specified with the same number of elements, and with the // same order. Counts []int64 }
Histogram holds bucket values and counts for a histogram metric.
type Host ¶
type Host struct { // Hostname holds the detected hostname of the host. Hostname string // Name holds the user-defined name of the host, or the // detected hostname. Name string // ID holds a unique ID for the host. ID string // Architecture holds the host machine architecture. Architecture string // Type holds the host type, e.g. cloud instance machine type. Type string // IP holds the IP addresses of the host. IP []netip.Addr // OS holds information about the operating system running on the host. OS OS }
type Kubernetes ¶
type LabelValue ¶
type LabelValue struct { // Value holds the label `string` value. Value string // Values holds the label `[]string` value. Values []string // Global is `true` when the label is defined at the agent level, rather // than being event-specific. Global bool }
LabelValue wraps a `string` or `[]slice` to be set as a value for a key. Only one should be set, in cases where both are set, the `Values` field will be used and `Value` will be ignored.
type Labels ¶
type Labels map[string]LabelValue
Labels wraps a map[string]string or map[string][]string with utility methods.
type Log ¶
type Log struct { // Level holds the log level of the log event. Level string // Logger holds the name of the logger instance. Logger string Origin LogOrigin }
Log holds information about a log, as defined by ECS.
type LogOrigin ¶
type LogOrigin struct { File LogOriginFile FunctionName string }
LogOrigin holds information about the origin of the log.
type LogOriginFile ¶
LogOriginFile holds information about the file and the line of the origin of the log.
type LongtaskMetrics ¶
type LongtaskMetrics struct { // Count holds the number of longtasks, or a negative value if unknown. Count int // Sum holds the sum of longtask durations. Sum float64 // Max holds the maximum longtask duration. Max float64 }
LongtaskMetrics holds metrics related to RUM longtasks.
type Message ¶
type Message struct { Body string Headers http.Header AgeMillis *int QueueName string RoutingKey string }
Message holds information about a recorded message, such as the message body and meta information
type MetricType ¶
type MetricType string
MetricType describes the type of a metric: gauge, counter, or histogram.
const ( MetricTypeGauge MetricType = "gauge" MetricTypeCounter MetricType = "counter" MetricTypeHistogram MetricType = "histogram" MetricTypeSummary MetricType = "summary" )
Valid MetricType values.
type Metricset ¶
type Metricset struct { // Samples holds the metrics in the set. Samples []MetricsetSample // Name holds an optional name for the metricset. Name string // DocCount holds the document count for pre-aggregated metrics. // // See https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-doc-count-field.html DocCount int64 }
Metricset describes a set of metrics and associated metadata.
type MetricsetSample ¶
type MetricsetSample struct { // Type holds an optional metric type. // // If Type is unspecified or invalid, it will be ignored. Type MetricType // Name holds the metric name. // // Name is required. Name string // Unit holds an optional unit: // // - "percent" (value is in the range [0,1]) // - "byte" // - a time unit: "nanos", "micros", "ms", "s", "m", "h", "d" // // If Unit is unspecified or invalid, it will be ignored. Unit string // Value holds the metric value for single-value metrics. // // If Counts and Values are specified, then Value will be ignored. Value float64 // Histogram holds bucket values and counts for histogram metrics. Histogram // SummaryMetric holds a combined count and sum of aggregated // measurements. SummaryMetric }
MetricsetSample represents a single named metric.
type Network ¶
type Network struct { // Connection holds information about a network connection. Connection NetworkConnection // Carrier holds information about a connection carrier. Carrier NetworkCarrier }
type NetworkCarrier ¶
type NetworkConnection ¶
type NetworkConnection struct { // Type holds the connection type category, // e.g. "wifi", "wired", and "cell". Type string // Subtype holds more details of the connection type, // specific to the connection type category. // // For example, if ConnectionType is "cell" then ConnectionSubtype // may hold the cell technology, e.g. "LTE", or "GRPS". Subtype string }
type NumericLabelValue ¶
type NumericLabelValue struct { // Values holds holds the label `[]float64` value. Values []float64 // Value holds the label `float64` value. Value float64 // Global is `true` when the label is defined at the agent level, rather // than being event-specific. Global bool }
NumericLabelValue wraps a `float64` or `[]float64` to be set as a value for a key. Only one should be set, in cases where both are set, the `Values` field will be used and `Value` will be ignored.
type NumericLabels ¶
type NumericLabels map[string]NumericLabelValue
NumericLabels wraps a map[string]float64 or map[string][]float64 with utility methods.
func (NumericLabels) Clone ¶
func (l NumericLabels) Clone() NumericLabels
Clone creates a deep copy of NumericLabels.
func (NumericLabels) Set ¶
func (l NumericLabels) Set(k string, v float64)
Set sets the label k to value v. If there existed a label in l with the same key, it will be replaced and its Global field will be set to false.
func (NumericLabels) SetSlice ¶
func (l NumericLabels) SetSlice(k string, v []float64)
SetSlice sets the label k to value v. If there existed a label in l with the same key, it will be replaced and its Global field will be set to false.
type OS ¶
type OS struct { // Name holds the operating system name, e.g. Android. Name string // Version holds the operating system version, e.g. 15.5.0. Version string // Platform holds the operating system platform, e.g. centos, ubuntu, windows. Platform string // Full holds the full operating system name, including the version or code name. Full string // Type categorizes the operating system into one of the broad commercial families. // // If specified, Type must beone of the following (lowercase): linux, macos, unix, windows. // If the OS you’re dealing with is not in the list, the field should not be populated. Type string }
OS holds information about the operating system.
type Observer ¶
Observer describes a special network, security, or application device used to detect, observe, or create network, security, or application-related events and metrics.
https://www.elastic.co/guide/en/ecs/current/ecs-observer.html
type Parent ¶
type Parent struct { // ID holds the ID of the parent event. ID string }
Parent holds information about the parent of a trace event.
type ProcessBatchFunc ¶
ProcessBatchFunc is a function type that implements BatchProcessor.
func (ProcessBatchFunc) ProcessBatch ¶
func (f ProcessBatchFunc) ProcessBatch(ctx context.Context, b *Batch) error
ProcessBatch calls f(ctx, b)
type ProcessThread ¶
ProcessThread represents the thread information.
type Processor ¶
Processor identifies an event type, and is used for routing events to the appropriate data stream or index.
TODO(axw) this should be replaced with ECS event categorisation fields.
type Service ¶
type Service struct { Name string Version string Environment string Language Language Runtime Runtime Framework Framework Node ServiceNode Origin *ServiceOrigin Target *ServiceTarget }
Service bundles together information related to the monitored service and the agent used for monitoring
type ServiceNode ¶
type ServiceNode struct {
Name string
}
type ServiceOrigin ¶
ServiceOrigin holds information about the service that originated a transaction.
type ServiceTarget ¶
ServiceTarget holds information about the target service in case of an outgoing event w.r.t. the instrumented service
type Session ¶
type Session struct { // ID holds a session ID for grouping a set of related transactions. ID string // Sequence holds an optional sequence number for a transaction // within a session. Sequence is ignored if it is zero or if // ID is empty. Sequence int }
Session holds information about a group of related transactions, such as a sequence of web interactions.
type Source ¶
type Source struct { // Domain holds the client's domain (FQDN). Domain string // IP holds the client's IP address. IP netip.Addr // Port holds the client's IP port. Port int // NAT holds the translated source based NAT sessions. NAT *NAT }
Source holds information about the source of a network exchange.
type Span ¶
type Span struct { ID string // Name holds the span name: "SELECT FROM table_name", etc. Name string // Type holds the span type: "external", "db", etc. Type string // Kind holds the span kind: "CLIENT", "SERVER", "PRODUCER", "CONSUMER" and "INTERNAL". Kind string // Subtype holds the span subtype: "http", "sql", etc. Subtype string // Action holds the span action: "query", "execute", etc. Action string // SelfTime holds the aggregated span durations, for breakdown metrics. SelfTime AggregatedDuration Message *Message Stacktrace Stacktrace Sync *bool Links []SpanLink DB *DB DestinationService *DestinationService Composite *Composite // RepresentativeCount holds the approximate number of spans that // this span represents for aggregation. This will only be set when // the sampling rate is known, and is used for scaling metrics. RepresentativeCount float64 }
type SpanLink ¶
type SpanLink struct { // Span holds information about the linked span event. Span Span // Trace holds information about the trace of the linked span event. Trace Trace }
SpanLink represents a link between two span events, possibly (but not necessarily) in different traces.
type Stacktrace ¶
type Stacktrace []*StacktraceFrame
type StacktraceFrame ¶
type StacktraceFrame struct { AbsPath string Filename string Classname string Lineno *int Colno *int ContextLine string Module string Function string LibraryFrame bool Vars map[string]any PreContext []string PostContext []string ExcludeFromGrouping bool SourcemapUpdated bool SourcemapError string Original Original }
type SummaryMetric ¶
type SummaryMetric struct { // Count holds the number of aggregated measurements. Count int64 // Sum holds the sum of aggregated measurements. Sum float64 }
SummaryMetric holds summary metrics (count and sum).
type Trace ¶
type Trace struct { // ID holds a unique identifier of the trace. ID string }
Trace holds information about a distributed trace.
type Transaction ¶
type Transaction struct { ID string // Name holds the transaction name: "GET /foo", etc. Name string // Type holds the transaction type: "request", "message", etc. Type string // Result holds the transaction result: "HTTP 2xx", "OK", "Error", etc. Result string // Sampled holds the transaction's sampling decision. // // If Sampled is false, then it will be omitted from the output event. Sampled bool // DurationHistogram holds a transaction duration histogram, // with bucket values measured in microseconds, for transaction // duration metrics. DurationHistogram Histogram // DurationSummary holds an aggregated transaction duration summary, // for service metrics. The DurationSummary.Sum field has microsecond // resolution. // // NOTE(axw) this is used only for service metrics, which are in technical // preview. Do not use this field without discussion, as the field mapping // is subject to removal. DurationSummary SummaryMetric // SuccessCount holds an aggregated count of transactions with different // outcomes. A "failure" adds to the Count. A "success" adds to both the // Count and the Sum. An "unknown" has no effect. If Count is zero, it // will be omitted from the output event. SuccessCount SummaryMetric Marks TransactionMarks Message *Message SpanCount SpanCount Custom map[string]any UserExperience *UserExperience // DroppedSpanStats holds a list of the spans that were dropped by an // agent; not indexed. DroppedSpansStats []DroppedSpanStats // RepresentativeCount holds the approximate number of // transactions that this transaction represents for aggregation. // This is used for scaling metrics. RepresentativeCount float64 // Root indicates whether or not the transaction is the trace root. // // If Root is false, it will be omitted from the output event. Root bool }
Transaction holds values for transaction.* fields. This may be used in transaction, span, and error events (i.e. transaction.id), as well as internal metrics such as breakdowns (i.e. including transaction.name).
type TransactionMark ¶
type TransactionMarks ¶
type TransactionMarks map[string]TransactionMark
type URL ¶
type URL struct { Original string Scheme string Full string Domain string Port int Path string Query string Fragment string }
URL describes an URL and its components
type UserAgent ¶
type UserAgent struct { // Original holds the original, full, User-Agent string. Original string // Name holds the user_agent.name value from the parsed User-Agent string. // If Original is set, then this should typically not be set, as the full // User-Agent string can be parsed by ingest node. Name string }
type UserExperience ¶
type UserExperience struct { // CumulativeLayoutShift holds the Cumulative Layout Shift (CLS) metric value, // or a negative value if CLS is unknown. See https://web.dev/cls/ CumulativeLayoutShift float64 // FirstInputDelay holds the First Input Delay (FID) metric value, // or a negative value if FID is unknown. See https://web.dev/fid/ FirstInputDelay float64 // TotalBlockingTime holds the Total Blocking Time (TBT) metric value, // or a negative value if TBT is unknown. See https://web.dev/tbt/ TotalBlockingTime float64 // Longtask holds longtask metrics. If Longtask.Count is negative, // then Longtask is considered unset. See https://www.w3.org/TR/longtasks/ Longtask LongtaskMetrics }
UserExperience holds real user (browser) experience metrics.
func (*UserExperience) Fields ¶
func (u *UserExperience) Fields() map[string]any
Source Files
¶
- agent.go
- apmevent.go
- batch.go
- child.go
- client.go
- cloud.go
- container.go
- context.go
- datastream.go
- destination.go
- device.go
- doc.go
- error.go
- event.go
- experience.go
- faas.go
- host.go
- http.go
- kubernetes.go
- labels.go
- log.go
- mapstr.go
- message.go
- metricset.go
- network.go
- observer.go
- os.go
- parent.go
- process.go
- processor.go
- service.go
- session.go
- source.go
- span.go
- spanlink.go
- stacktrace.go
- trace.go
- transaction.go
- url.go
- user.go
- useragent.go