integration

package
v3.8.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: Apache-2.0 Imports: 18 Imported by: 104

Documentation

Index

Constants

View Source
const (
	CustomAttrPrefix  = "NRI_"
	CustomAttrCluster = "cluster_name"
	CustomAttrService = "service_name"
)

Custom attribute keys:

View Source
const (
	AttrReportingEntity   = "reportingEntityKey"
	AttrReportingEndpoint = "reportingEndpoint"
)

Standard attributes

Variables

View Source
var EmptyKey = EntityKey("")

EmptyKey empty entity key.

Functions

This section is empty.

Types

type Entity

type Entity struct {
	Metadata    *EntityMetadata      `json:"entity,omitempty"`
	Metrics     []*metric.Set        `json:"metrics"`
	Inventory   *inventory.Inventory `json:"inventory"`
	Events      []*event.Event       `json:"events"`
	AddHostname bool                 `json:"add_hostname,omitempty"` // add hostname to metadata at agent level
	// contains filtered or unexported fields
}

Entity is the producer of the data. Entity could be a host, a container, a pod, or whatever unit of meaning.

func (*Entity) AddAttributes

func (e *Entity) AddAttributes(attributes ...attribute.Attribute)

AddAttributes adds attributes to every entity metric-set.

func (*Entity) AddEvent

func (e *Entity) AddEvent(evnt *event.Event) error

AddEvent method adds a new Event.

func (*Entity) Key

func (e *Entity) Key() (EntityKey, error)

Key unique entity identifier within a New Relic customer account.

func (*Entity) NewMetricSet

func (e *Entity) NewMetricSet(eventType string, nameSpacingAttributes ...attribute.Attribute) *metric.Set

NewMetricSet returns a new instance of Set with its sample attached to the integration.

func (*Entity) SameAs

func (e *Entity) SameAs(b *Entity) bool

SameAs return true when is same entity

func (*Entity) SetInventoryItem

func (e *Entity) SetInventoryItem(key string, field string, value interface{}) error

SetInventoryItem method adds a inventory item.

type EntityKey

type EntityKey string

EntityKey unique identifier for an entity within a New Relic customer account.

func (EntityKey) String

func (k EntityKey) String() string

String stringer stuff

type EntityMetadata

type EntityMetadata struct {
	Name      string       `json:"name"`
	Namespace string       `json:"type"`          // For compatibility reasons we keep the type.
	IDAttrs   IDAttributes `json:"id_attributes"` // For entity Key uniqueness
	// contains filtered or unexported fields
}

EntityMetadata stores entity Metadata

func (*EntityMetadata) EqualsTo

func (m *EntityMetadata) EqualsTo(b *EntityMetadata) bool

EqualsTo returns true when both metadata are equal.

func (*EntityMetadata) Key

func (m *EntityMetadata) Key() (EntityKey, error)

Key generates the entity key based on the entity metadata.

type IDAttribute

type IDAttribute struct {
	Key   string
	Value string
}

IDAttribute identifier attribute key-value pair.

func NewIDAttribute

func NewIDAttribute(key, value string) IDAttribute

NewIDAttribute creates new identifier attribute.

type IDAttributes

type IDAttributes []IDAttribute

IDAttributes list of identifier attributes used to provide uniqueness for an entity key.

func (IDAttributes) Len

func (a IDAttributes) Len() int

Len is part of sort.Interface.

func (IDAttributes) Less

func (a IDAttributes) Less(i, j int) bool

Less is part of sort.Interface.

func (IDAttributes) Swap

func (a IDAttributes) Swap(i, j int)

Swap is part of sort.Interface.

type Integration

type Integration struct {
	Name               string    `json:"name"`
	ProtocolVersion    string    `json:"protocol_version"`
	IntegrationVersion string    `json:"integration_version"`
	Entities           []*Entity `json:"data"`
	// contains filtered or unexported fields
}

Integration defines the format of the output JSON that integrations will return for protocol 2.

func New

func New(name, version string, opts ...Option) (i *Integration, err error)

New creates new integration with sane default values.

func (*Integration) Clear

func (i *Integration) Clear()

Clear re-initializes the Inventory, Metrics and Events for this integration. Used after publishing so the object can be reused.

func (*Integration) CreateUniqueID

func (i *Integration) CreateUniqueID() string

CreateUniqueID will generate an md5 string from integration arguments to unique identify the integration instance.

func (*Integration) Entity

func (i *Integration) Entity(name, namespace string, idAttributes ...IDAttribute) (e *Entity, err error)

Entity method creates or retrieves an already created entity.

func (*Integration) EntityReportedBy

func (i *Integration) EntityReportedBy(reportingEntity EntityKey, reportedEntityName, reportedEntityNamespace string, idAttributes ...IDAttribute) (e *Entity, err error)

EntityReportedBy entity being reported from another entity that is not producing the actual entity data.

func (*Integration) EntityReportedVia

func (i *Integration) EntityReportedVia(endpoint, reportedEntityName, reportedEntityNamespace string, idAttributes ...IDAttribute) (e *Entity, err error)

EntityReportedVia entity being reported from a known endpoint.

func (*Integration) LocalEntity

func (i *Integration) LocalEntity() *Entity

LocalEntity retrieves default (local) entity to monitorize.

func (*Integration) Logger

func (i *Integration) Logger() log.Logger

Logger returns the integration logger instance.

func (*Integration) MarshalJSON

func (i *Integration) MarshalJSON() (output []byte, err error)

MarshalJSON serializes integration to JSON, fulfilling Marshaler interface.

func (*Integration) Publish

func (i *Integration) Publish() error

Publish runs all necessary tasks before publishing the data. Currently, it stores the Storer, prints the JSON representation of the integration using a writer (stdout by default) and re-initializes the integration object (allowing re-use it during the execution of your code).

type Option

type Option func(*Integration) error

Option sets an option on integration level.

func Args

func Args(a interface{}) Option

Args sets the destination struct (pointer) where the command-line flags will be parsed to.

func InMemoryStore

func InMemoryStore() Option

InMemoryStore replaces the metrics storage by an ephemeral in-memory store.

func Logger

func Logger(l log.Logger) Option

Logger replaces the logger.

func Storer

func Storer(s persist.Storer) Option

Storer replaces the metrics storage.

func Writer

func Writer(w io.Writer) Option

Writer replaces the output writer.

Jump to

Keyboard shortcuts

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