resource

package
v0.22.3 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2020 License: Apache-2.0 Imports: 7 Imported by: 48

Documentation

Overview

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

Index

Constants

View Source
const (
	EnvVarType   = "OC_RESOURCE_TYPE"
	EnvVarLabels = "OC_RESOURCE_LABELS"
)

Environment variables used by FromEnv to decode a resource.

Variables

This section is empty.

Functions

func DecodeLabels

func DecodeLabels(s string) (map[string]string, error)

DecodeLabels decodes a serialized label map as used in the OC_RESOURCE_LABELS variable. A list of labels of the form `<key1>="<value1>",<key2>="<value2>",...` is accepted. Domain names and paths are accepted as label keys. Most users will want to use FromEnv instead.

func EncodeLabels

func EncodeLabels(labels map[string]string) string

EncodeLabels encodes a labels map to a string as provided via the OC_RESOURCE_LABELS environment variable.

Types

type Detector

type Detector func(context.Context) (*Resource, error)

Detector attempts to detect resource information. If the detector cannot find resource information, the returned resource is nil but no error is returned. An error is only returned on unexpected failures.

func MultiDetector

func MultiDetector(detectors ...Detector) Detector

MultiDetector returns a Detector that calls all input detectors in order and merges each result with the previous one. In case a type of label key is already set, the first set value is takes precedence. It returns on the first error that a sub-detector encounters.

type Resource

type Resource struct {
	Type   string
	Labels map[string]string
}

Resource describes an entity about which identifying information and metadata is exposed. For example, a type "k8s.io/container" may hold labels describing the pod name and namespace.

func FromEnv

func FromEnv(context.Context) (*Resource, error)

FromEnv is a detector that loads resource information from the OC_RESOURCE_TYPE and OC_RESOURCE_labelS environment variables.

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