inframetadata

package module
v0.68.0-rc.5 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2025 License: Apache-2.0 Imports: 11 Imported by: 4

Documentation

Overview

Package inframetadata handles host metadata and infrastructure list related features. It stores the host metadata and gohai payload definitions as well as the `Reporter` implementation.

A `Reporter` keeps a `HostMap` (a map of hostnames to host metadata payloads) and periodically clears it out and reports the information using a `Pusher`

The `Reporter` has three public methods: - The `Run() error` and `Stop()` methods manage its lifecycle - The `ConsumeResource(pcommon.Resource) (bool, error)` method ingests resources, updates host metadata payloads, and reports whether any changes or errors occurred during processing.

Internally, the `Reporter` manages a `HostMap`, which has two public methods: - The `Update(host string, resource pcommon.Resource) (changed bool, err error)` method updates a hosts information and reports whether any changes or errors occurred during processing. - The `Extract() map[string]payloads.HostMetadata` method clears out the `HostMap` and returns a copy of its internal information.

Index

Constants

View Source
const (
	// AttributeDatadogHostUseAsMetadata states if a payload should be used for host metadata.
	// It overrides the default behavior (see below).
	AttributeDatadogHostUseAsMetadata = "datadog.host.use_as_metadata"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Pusher

type Pusher interface {
	// Push host metadata to a remote endpoint.
	// MUST be safe to call concurrently.
	Push(context.Context, payload.HostMetadata) error
}

Pusher is the interface for pushing host metadata to a remote endpoint.

type Reporter

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

Reporter of host metadata based on pcommon.Resource payloads.

func NewReporter

func NewReporter(logger *zap.Logger, pusher Pusher, period time.Duration) (*Reporter, error)

NewReporter creates a new host metadata reporter. The reporter consumes pcommon.Resources through its 'Consume' method and merges them into payload.HostMetadata payloads. It then exports the payloads through the pusher with a specified period.

func (*Reporter) ConsumeHostMetadata

func (r *Reporter) ConsumeHostMetadata(hm payload.HostMetadata) error

ConsumeHostMetadata consumes a host metadata payload and pushes it.

func (*Reporter) ConsumeMetrics

func (r *Reporter) ConsumeMetrics(md pmetric.Metrics) error

ConsumeMetrics checks if a metric is tracked by the reporter and if so updates the host metadata accordingly.

func (*Reporter) ConsumeResource

func (r *Reporter) ConsumeResource(res pcommon.Resource) error

ConsumeResource for host metadata reporting purposes. The resource will be used only if it is usable (see 'hasHostMetadata') and it has a host attribute.

func (*Reporter) Run

func (r *Reporter) Run(ctx context.Context) error

Run the reporter to periodically export

func (*Reporter) Stop

func (r *Reporter) Stop()

Stop the reporter.

Directories

Path Synopsis
Package gohai implements the Gohai payload.
Package gohai implements the Gohai payload.
internal
hostmap
Package hostmap provides constants for the hostmap.
Package hostmap provides constants for the hostmap.
testutils
Package testutils provides utilities for testing the hostmap.
Package testutils provides utilities for testing the hostmap.
Package payload implements the host metadata payload.
Package payload implements the host metadata payload.

Jump to

Keyboard shortcuts

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