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 ¶
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 }
type Reporter ¶
type Reporter struct {
// contains filtered or unexported fields
}
Reporter of host metadata based on pcommon.Resource payloads.
func NewReporter ¶
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 ¶ added in v0.7.1
func (r *Reporter) ConsumeHostMetadata(hm payload.HostMetadata) error
ConsumeHostMetadata consumes a host metadata payload and pushes it.
func (*Reporter) ConsumeMetrics ¶ added in v0.11.0
ConsumeMetrics checks if a metric is tracked by the reporter and if so updates the host metadata accordingly.
func (*Reporter) ConsumeResource ¶
ConsumeResource for host metadata reporting purposes. The resource will be used only if it is usable (see 'hasHostMetadata') and it has a host attribute.