detector

package
v0.1.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectLanguageForFile

func DetectLanguageForFile(filePath string) (string, error)

func DetectLanguages

func DetectLanguages(rootPath string) (map[string]string, error)

DetectLanguages scans a directory and detects the primary programming language of each subdirectory

Types

type Analysis

type Analysis struct {
	RootPath          string                        `json:"root_path"`
	DirectoryAnalyses map[string]*DirectoryAnalysis `json:"directory_analyses"`
}

Analysis contains the results of language detection and library discovery

type CodebaseAnalyzer

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

CodebaseAnalyzer coordinates the detection process

func NewCodebaseAnalyzer

func NewCodebaseAnalyzer(detectors []IssueDetector, languages map[string]Language, logger logger.Logger) *CodebaseAnalyzer

NewCodebaseAnalyzer creates a new analysis engine

func (*CodebaseAnalyzer) AnalyzeCodebase

func (ca *CodebaseAnalyzer) AnalyzeCodebase(ctx context.Context, rootPath string) (*Analysis, error)

AnalyzeCodebase performs the full analysis

type DirectoryAnalysis

type DirectoryAnalysis struct {
	Directory                 string                       `json:"directory"`
	Language                  string                       `json:"language"`
	Libraries                 []domain.Library             `json:"libraries"`
	Packages                  []domain.Package             `json:"packages"`
	AvailableInstrumentations []domain.InstrumentationInfo `json:"available_instrumentations"`
	Issues                    []domain.Issue               `json:"issues"`
}

DirectoryAnalysis contains analysis results for a specific directory

type InstrumentationRegistryService

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

InstrumentationRegistryService handles communication with the OpenTelemetry instrumentation registry

func NewInstrumentationRegistryService

func NewInstrumentationRegistryService() *InstrumentationRegistryService

NewInstrumentationRegistryService creates a new instrumentation registry service

func (*InstrumentationRegistryService) CanonicalLanguage

func (s *InstrumentationRegistryService) CanonicalLanguage(language string) string

CanonicalLanguage normalizes registry language identifiers to our internal ones

func (*InstrumentationRegistryService) GetInstrumentation

GetInstrumentation checks if instrumentation exists for a given package

func (*InstrumentationRegistryService) PackageName

func (s *InstrumentationRegistryService) PackageName(packageName string) string

normalizedomain.PackageName converts package names to the format used in the registry

func (*InstrumentationRegistryService) RegistryLanguage

func (s *InstrumentationRegistryService) RegistryLanguage(language string) string

RegistryLanguage normalizes language names to the ones used by the registry filenames

type IssueDetector

type IssueDetector interface {
	// ID returns a unique identifier for this detector
	ID() string
	// Name returns a human-readable name
	Name() string
	// Description returns what this detector looks for
	Description() string
	// Category returns the issue category
	Category() domain.Category
	// Languages returns which languages this detector applies to (empty = all)
	Languages() []string
	// Detect finds issues in the given context
	Detect(ctx context.Context, analysis *DirectoryAnalysis) ([]domain.Issue, error)
}

IssueDetector defines how to detect specific issues

type KnowledgeBasedInstrumentationService

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

KnowledgeBasedInstrumentationService integrates the new knowledge base with the detector system

func NewKnowledgeBasedInstrumentationService

func NewKnowledgeBasedInstrumentationService(logger logger.Logger) (*KnowledgeBasedInstrumentationService, error)

NewKnowledgeBasedInstrumentationService creates a new knowledge-based instrumentation service

func (*KnowledgeBasedInstrumentationService) Close

Close closes the underlying storage connection

func (*KnowledgeBasedInstrumentationService) GetBreakingChanges

GetBreakingChanges returns breaking changes for a given package

func (*KnowledgeBasedInstrumentationService) GetCompatibleVersions

GetCompatibleVersions returns compatible versions for a given package

func (*KnowledgeBasedInstrumentationService) GetInstrumentation

GetInstrumentation finds instrumentation information using the knowledge base

func (*KnowledgeBasedInstrumentationService) GetLatestVersion

GetLatestVersion returns the latest stable version of a package

func (*KnowledgeBasedInstrumentationService) GetRecommendedInstrumentations

func (s *KnowledgeBasedInstrumentationService) GetRecommendedInstrumentations(ctx context.Context, pkg domain.Package) ([]domain.InstrumentationInfo, error)

GetRecommendedInstrumentations returns recommended instrumentations for a given package

type Language

type Language interface {
	// Name returns the language name
	Name() string
	// GetOTelLibraries finds OpenTelemetry libraries used in the codebase
	GetOTelLibraries(ctx context.Context, rootPath string) ([]domain.Library, error)
	// GetAllPackages finds all packages/dependencies used in the codebase
	GetAllPackages(ctx context.Context, rootPath string) ([]domain.Package, error)
	// GetFilePatterns returns file patterns this language detector should scan
	GetFilePatterns() []string
}

Language represents a programming language detector

type RegistryEntry

type RegistryEntry struct {
	Title        string   `yaml:"title"`
	RegistryType string   `yaml:"registryType"`
	Language     string   `yaml:"language"`
	Tags         []string `yaml:"tags"`
	Description  string   `yaml:"description"`
	License      string   `yaml:"license"`
	Authors      []struct {
		Name string `yaml:"name"`
	} `yaml:"authors"`
	URLs struct {
		Repo string `yaml:"repo"`
	} `yaml:"urls"`
	CreatedAt    string `yaml:"createdAt"`
	IsFirstParty bool   `yaml:"isFirstParty"`
}

RegistryEntry represents the YAML structure from the OpenTelemetry registry

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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