usm

package
v0.0.0-...-b86caed Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package usm provides functionality to detect the most appropriate service name for a process.

Index

Constants

View Source
const (
	// The path to the Node service's package.json
	NodePackageJSONPath = iota
	// The SubdirFS instance package.json path is valid in.
	ServiceSubFS = iota
)

DetectorContextMap keys enum

Variables

This section is empty.

Functions

func ReadlinkFS

func ReadlinkFS(fsfs fs.FS, name string) (string, error)

ReadlinkFS reads the symlink on the provided FS. There is no standard SymlinkFS interface yet https://github.com/golang/go/issues/49580.

func SizeVerifiedReader

func SizeVerifiedReader(file fs.File) (io.Reader, error)

SizeVerifiedReader returns a reader for the file after ensuring that the file is a regular file and that the size that can be read from the reader will not exceed a pre-defined safety limit to control memory usage.

Types

type DetectionContext

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

DetectionContext allows to detect ServiceMetadata.

func NewDetectionContext

func NewDetectionContext(args []string, envs map[string]string, fs fs.SubFS) DetectionContext

NewDetectionContext initializes DetectionContext.

type DetectorContextMap

type DetectorContextMap map[int]interface{}

DetectorContextMap is a map for passing data between the different detectors of the service discovery (i.e between the service name detector and the instrumentation detector)

type RealFs

type RealFs struct{}

RealFs implements real fs operations.

func (RealFs) Open

func (RealFs) Open(name string) (fs.File, error)

Open calls os.Open.

func (RealFs) Sub

func (RealFs) Sub(dir string) (fs.FS, error)

Sub calls os.DirFS.

type ServiceMetadata

type ServiceMetadata struct {
	Name              string
	AdditionalNames   []string
	DDService         string
	DDServiceInjected bool
}

ServiceMetadata holds information about a service.

func ExtractServiceMetadata

func ExtractServiceMetadata(args []string, envs map[string]string, fs fs.SubFS, lang language.Language, contextMap DetectorContextMap) (metadata ServiceMetadata, success bool)

ExtractServiceMetadata attempts to detect ServiceMetadata from the given process.

func NewServiceMetadata

func NewServiceMetadata(name string, additional ...string) ServiceMetadata

NewServiceMetadata initializes ServiceMetadata.

func (ServiceMetadata) GetServiceKey

func (s ServiceMetadata) GetServiceKey() string

GetServiceKey returns the key for the service.

func (*ServiceMetadata) SetAdditionalNames

func (s *ServiceMetadata) SetAdditionalNames(additional ...string)

SetAdditionalNames set additional names for the service

func (*ServiceMetadata) SetNames

func (s *ServiceMetadata) SetNames(name string, additional ...string)

SetNames sets generated names for the service.

type SubDirFS

type SubDirFS struct {
	fs.FS
	// contains filtered or unexported fields
}

SubDirFS is like the fs.FS implemented by os.DirFS, except that it allows absolute paths to be passed in the Open/Stat/etc, and attaches them to the root dir. It also implements SubFS, unlink the one implemented by os.DirFS.

func NewSubDirFS

func NewSubDirFS(root string) SubDirFS

NewSubDirFS creates a new SubDirFS rooted at the specified path.

func (SubDirFS) Open

func (s SubDirFS) Open(name string) (fs.File, error)

Open opens the specified file

func (SubDirFS) ReadDir

func (s SubDirFS) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir reads the specified subdirectory

func (s SubDirFS) Readlink(name string) (string, error)

Readlink reads the specified symlink.

func (SubDirFS) Stat

func (s SubDirFS) Stat(name string) (fs.FileInfo, error)

Stat stats the specified file

func (SubDirFS) Sub

func (s SubDirFS) Sub(dir string) (fs.FS, error)

Sub provides a fs.FS for the specified subdirectory.

Jump to

Keyboard shortcuts

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