usm

package
v0.0.0-...-a4a88c6 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

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

Index

Constants

View Source
const (
	// NodePackageJSONPath The path to the Node service's package.json
	NodePackageJSONPath = iota
	// ServiceSubFS The SubdirFS instance package.json path is valid in.
	ServiceSubFS = iota
	// The pointer to the Process instance of the service
	ServiceProc = 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 {
	// Pid process PID
	Pid int
	// Args the command line arguments of the process
	Args []string
	// Envs targeted environment variables of the process
	Envs envs.Variables

	// DetectorContextMap a map to pass data between detectors, like some paths.
	ContextMap DetectorContextMap
	// contains filtered or unexported fields
}

DetectionContext allows to detect ServiceMetadata.

func NewDetectionContext

func NewDetectionContext(args []string, envs envs.Variables, 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
	Source            ServiceNameSource
	AdditionalNames   []string
	DDService         string
	DDServiceInjected bool
}

ServiceMetadata holds information about a service.

func ExtractServiceMetadata

func ExtractServiceMetadata(lang language.Language, ctx DetectionContext) (metadata ServiceMetadata, success bool)

ExtractServiceMetadata attempts to detect ServiceMetadata from the given process.

func NewServiceMetadata

func NewServiceMetadata(name string, source ServiceNameSource, 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, source ServiceNameSource, additional ...string)

SetNames sets generated names for the service.

type ServiceNameSource

type ServiceNameSource string

ServiceNameSource is a string enum that represents the source of a generated service name

const (
	// CommandLine indicates that the name comes from the command line
	CommandLine ServiceNameSource = "command-line"
	// Container indicates the name comes from the container tags
	Container ServiceNameSource = "container"
	// Laravel indicates that the name comes from the Laravel application name
	Laravel ServiceNameSource = "laravel"
	// Python indicates that the name comes from the Python package name
	Python ServiceNameSource = "python"
	// Nodejs indicates that the name comes from the Node.js package name
	Nodejs ServiceNameSource = "nodejs"
	// Gunicorn indicates that the name comes from the Gunicorn application name
	Gunicorn ServiceNameSource = "gunicorn"
	// Rails indicates that the name comes from the Rails application name
	Rails ServiceNameSource = "rails"
	// Spring indicates that the name comes from the Spring application name
	Spring ServiceNameSource = "spring"
	// JBoss indicates that the name comes from the JBoss application name
	JBoss ServiceNameSource = "jboss"
	// Tomcat indicates that the name comes from the Tomcat application name
	Tomcat ServiceNameSource = "tomcat"
	// WebLogic indicates that the name comes from the WebLogic application name
	WebLogic ServiceNameSource = "weblogic"
	// WebSphere indicates that the name comes from the WebSphere application name
	WebSphere ServiceNameSource = "websphere"
)

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