otelservicedetector

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: MIT Imports: 6 Imported by: 1

README

status PkgGoDev

otel-service-detector

otel-service-detector provides OpenTelemetry resource detector that detects service attributes from the container metadata.

Synopsis

import (
	otelservicedetector "github.com/aereal/otel-service-detector"
	"github.com/aereal/otel-service-detector/awsecs"
	"go.opentelemetry.io/otel/sdk/resource"
)

func _() {
  detector := otelservicedetector.New(otelservicedetector.WithContainerMetadataProvider(awsecs.New()))
  _, _ = resource.New(context.TODO(), resource.WithDetectors(detector))
}

Installation

go get github.com/aereal/otel-service-detector

License

See LICENSE file.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContainerMetadata

type ContainerMetadata struct {
	Image  string
	Labels Labels
}

type ContainerMetadataProvider

type ContainerMetadataProvider interface {
	ProvideContainerMetadata(context.Context) (*ContainerMetadata, error)
}

ContainerMetadataProvider provides container's metadata.

It may communicate with remote endpoints for collecting container's metadata.

type ContainerMetadataProviderFunc

type ContainerMetadataProviderFunc func(ctx context.Context) (*ContainerMetadata, error)

func (ContainerMetadataProviderFunc) ProvideContainerMetadata

func (f ContainerMetadataProviderFunc) ProvideContainerMetadata(ctx context.Context) (*ContainerMetadata, error)

type Detector

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

func New

func New(opts ...Option) *Detector

func (*Detector) Detect

func (d *Detector) Detect(ctx context.Context) (*resource.Resource, error)

type Labels

type Labels interface {
	Get(key string) string
}

type LabelsMap

type LabelsMap map[string]string

func (LabelsMap) Get

func (m LabelsMap) Get(key string) string

type Option

type Option func(d *Detector)

func WithContainerMetadataProvider

func WithContainerMetadataProvider(p ContainerMetadataProvider) Option

func WithDeploymentEnvironmentLabel

func WithDeploymentEnvironmentLabel(labels ...string) Option

func WithServiceNameLabel

func WithServiceNameLabel(labels ...string) Option

func WithServiceVersionLabel

func WithServiceVersionLabel(labels ...string) Option

type ProvideContainerMetadataError

type ProvideContainerMetadataError struct {
	Err error
}

func (*ProvideContainerMetadataError) Error

func (*ProvideContainerMetadataError) Unwrap

type StaticContainerMetadataProvider

type StaticContainerMetadataProvider struct{ *ContainerMetadata }

func (StaticContainerMetadataProvider) ProvideContainerMetadata

func (p StaticContainerMetadataProvider) ProvideContainerMetadata(context.Context) (*ContainerMetadata, error)

Directories

Path Synopsis
awsecs module

Jump to

Keyboard shortcuts

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