resource

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2020 License: Apache-2.0 Imports: 2 Imported by: 2,913

Documentation

Overview

Package resource provides functionality for resource, which capture identifying information about the entities for which signals are exported.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Resource

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

Resource describes an entity about which identifying information and metadata is exposed. Resource is an immutable object, equivalent to a map from key to unique value.

Resources should be passed and stored as pointers (`*resource.Resource`). The `nil` value is equivalent to an empty Resource.

func Empty added in v0.4.3

func Empty() *Resource

Empty returns an instance of Resource with no attributes. It is equivalent to a `nil` Resource.

func Merge

func Merge(a, b *Resource) *Resource

Merge creates a new resource by combining resource a and b.

If there are common keys between resource a and b, then the value from resource a is preserved.

func New

func New(kvs ...kv.KeyValue) *Resource

Key creates a resource from a set of attributes. If there are duplicate keys present in the list of attributes, then the last value found for the key is preserved.

func (*Resource) Attributes

func (r *Resource) Attributes() []kv.KeyValue

Attributes returns a copy of attributes from the resource in a sorted order. To avoid allocating a new slice, use an iterator.

func (*Resource) Encoded added in v0.4.3

func (r *Resource) Encoded(enc label.Encoder) string

Encoded returns an encoded representation of the resource by applying a label encoder. The result is cached by the underlying label set.

func (*Resource) Equal

func (r *Resource) Equal(eq *Resource) bool

Equal returns true when a Resource is equivalent to this Resource.

func (*Resource) Equivalent added in v0.4.3

func (r *Resource) Equivalent() label.Distinct

Equivalent returns an object that can be compared for equality between two resources. This value is suitable for use as a key in a map.

func (*Resource) Iter added in v0.4.3

func (r *Resource) Iter() label.Iterator

Iter returns an interator of the Resource attributes. This is ideal to use if you do not want a copy of the attributes.

func (*Resource) Len added in v0.4.3

func (r *Resource) Len() int

Len returns the number of unique key-values in this Resource.

func (*Resource) MarshalJSON added in v0.4.3

func (r *Resource) MarshalJSON() ([]byte, error)

MarshalJSON encodes labels as a JSON list of { "Key": "...", "Value": ... } pairs in order sorted by key.

func (*Resource) String added in v0.4.3

func (r *Resource) String() string

String implements the Stringer interface and provides a human-readable form of the resource.

Avoid using this representation as the key in a map of resources, use Equivalent() as the key instead.

Directories

Path Synopsis
Package resourcekeys contains well known type and label keys for resources.
Package resourcekeys contains well known type and label keys for resources.

Jump to

Keyboard shortcuts

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