injector

package
v0.1.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2025 License: MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CodeInjector

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

func NewCodeInjector

func NewCodeInjector(logger logger.Logger) *CodeInjector

func (*CodeInjector) DetectEntryPoints

func (ci *CodeInjector) DetectEntryPoints(projectPath string, language string) ([]domain.EntryPoint, error)

DetectEntryPoints scans a project directory for entry points using language handlers. Returns at most one best entry point per directory.

func (*CodeInjector) InjectOtelInitialization

func (ci *CodeInjector) InjectOtelInitialization(ctx context.Context,
	entryPoint *domain.EntryPoint,
	operationsData *types.OperationsData,
	req types.GenerationRequest) ([]string, error)

type DotNetInjector

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

DotNetInjector implements LanguageInjector for C#/.NET

func NewDotNetInjector

func NewDotNetInjector() *DotNetInjector

func (*DotNetInjector) AnalyzeFunctionCapture

func (h *DotNetInjector) AnalyzeFunctionCapture(captureName string, node *sitter.Node, content []byte, analysis *types.FileAnalysis, config *types.LanguageConfig)

func (*DotNetInjector) AnalyzeImportCapture

func (h *DotNetInjector) AnalyzeImportCapture(captureName string, node *sitter.Node, content []byte, analysis *types.FileAnalysis)

func (*DotNetInjector) FallbackAnalyzeEntryPoints

func (h *DotNetInjector) FallbackAnalyzeEntryPoints(content []byte, analysis *types.FileAnalysis)

func (*DotNetInjector) FallbackAnalyzeImports

func (h *DotNetInjector) FallbackAnalyzeImports(content []byte, analysis *types.FileAnalysis)

func (*DotNetInjector) FormatFrameworkImports

func (h *DotNetInjector) FormatFrameworkImports(imports []string) string

FormatFrameworkImports formats framework-specific import statements for C#

func (*DotNetInjector) FormatImports

func (h *DotNetInjector) FormatImports(imports []string, hasExisting bool) string

func (*DotNetInjector) FormatSingleImport

func (h *DotNetInjector) FormatSingleImport(importPath string) string

func (*DotNetInjector) GenerateFrameworkModifications

func (h *DotNetInjector) GenerateFrameworkModifications(content []byte, operationsData *types.OperationsData) []types.CodeModification

GenerateFrameworkModifications generates framework-specific instrumentation modifications for C#

func (*DotNetInjector) GenerateImportModifications

func (h *DotNetInjector) GenerateImportModifications(content []byte, analysis *types.FileAnalysis) []types.CodeModification

GenerateImportModifications generates modifications to fix import statements

func (*DotNetInjector) GetConfig

func (h *DotNetInjector) GetConfig() *types.LanguageConfig

func (*DotNetInjector) GetFrameworkImports

func (h *DotNetInjector) GetFrameworkImports(content []byte) []string

GetFrameworkImports returns framework-specific imports based on detected frameworks

func (*DotNetInjector) GetInsertionPointPriority

func (h *DotNetInjector) GetInsertionPointPriority(captureName string) int

func (*DotNetInjector) GetLanguage

func (h *DotNetInjector) GetLanguage() *sitter.Language

func (*DotNetInjector) GetRequiredImports

func (h *DotNetInjector) GetRequiredImports() []string

GetRequiredImports returns the list of imports needed for OTEL in C#

type GoInjector

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

GoInjector implements LanguageHandler for Go

func NewGoInjector

func NewGoInjector() *GoInjector

NewGoInjector creates a new Go language handler

func (*GoInjector) AnalyzeFunctionCapture

func (h *GoInjector) AnalyzeFunctionCapture(captureName string, node *sitter.Node, content []byte, analysis *types.FileAnalysis, config *types.LanguageConfig)

AnalyzeFunctionCapture processes a function capture from tree-sitter query for Go

func (*GoInjector) AnalyzeImportCapture

func (h *GoInjector) AnalyzeImportCapture(captureName string, node *sitter.Node, content []byte, analysis *types.FileAnalysis)

AnalyzeImportCapture processes an import capture from tree-sitter query for Go

func (*GoInjector) FallbackAnalyzeEntryPoints

func (h *GoInjector) FallbackAnalyzeEntryPoints(content []byte, analysis *types.FileAnalysis)

FallbackAnalyzeEntryPoints: no-op for Go since tree-sitter captures main/init reliably

func (*GoInjector) FallbackAnalyzeImports

func (h *GoInjector) FallbackAnalyzeImports(content []byte, analysis *types.FileAnalysis)

FallbackAnalyzeImports provides Go-specific import analysis when tree-sitter yields no insertion points

func (*GoInjector) FormatFrameworkImports

func (h *GoInjector) FormatFrameworkImports(imports []string) string

FormatFrameworkImports formats framework-specific import statements for Go

func (*GoInjector) FormatImports

func (h *GoInjector) FormatImports(imports []string, hasExistingImports bool) string

FormatImports formats Go import statements

func (*GoInjector) FormatSingleImport

func (h *GoInjector) FormatSingleImport(importPath string) string

FormatSingleImport formats a single Go import statement

func (*GoInjector) GenerateFrameworkModifications

func (h *GoInjector) GenerateFrameworkModifications(content []byte, operationsData *types.OperationsData) []types.CodeModification

GenerateFrameworkModifications generates framework-specific instrumentation modifications for Go

func (*GoInjector) GenerateImportModifications

func (h *GoInjector) GenerateImportModifications(content []byte, analysis *types.FileAnalysis) []types.CodeModification

GenerateImportModifications generates modifications to fix import statements

func (*GoInjector) GetConfig

func (h *GoInjector) GetConfig() *types.LanguageConfig

GetConfig returns the language configuration for Go

func (*GoInjector) GetFrameworkImports

func (h *GoInjector) GetFrameworkImports(content []byte) []string

GetFrameworkImports returns framework-specific imports based on detected frameworks

func (*GoInjector) GetInsertionPointPriority

func (h *GoInjector) GetInsertionPointPriority(captureName string) int

GetInsertionPointPriority returns priority for Go insertion point types

func (*GoInjector) GetLanguage

func (h *GoInjector) GetLanguage() *sitter.Language

GetLanguage returns the tree-sitter language parser for Go

func (*GoInjector) GetRequiredImports

func (h *GoInjector) GetRequiredImports() []string

GetRequiredImports returns the list of imports needed for OTEL in Go

type JavaInjector

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

JavaInjector implements LanguageInjector for Java

func NewJavaInjector

func NewJavaInjector() *JavaInjector

NewJavaInjector creates a new Java language handler

func (*JavaInjector) AnalyzeFunctionCapture

func (h *JavaInjector) AnalyzeFunctionCapture(captureName string, node *sitter.Node, content []byte, analysis *types.FileAnalysis, config *types.LanguageConfig)

AnalyzeFunctionCapture processes a function capture from tree-sitter query for Java

func (*JavaInjector) AnalyzeImportCapture

func (h *JavaInjector) AnalyzeImportCapture(captureName string, node *sitter.Node, content []byte, analysis *types.FileAnalysis)

AnalyzeImportCapture processes an import capture from tree-sitter query for Java

func (*JavaInjector) FallbackAnalyzeEntryPoints

func (h *JavaInjector) FallbackAnalyzeEntryPoints(content []byte, analysis *types.FileAnalysis)

FallbackAnalyzeEntryPoints: no-op for Java; main method capture should be sufficient

func (*JavaInjector) FallbackAnalyzeImports

func (h *JavaInjector) FallbackAnalyzeImports(content []byte, analysis *types.FileAnalysis)

FallbackAnalyzeImports: no-op for Java

func (*JavaInjector) FormatFrameworkImports

func (h *JavaInjector) FormatFrameworkImports(imports []string) string

FormatFrameworkImports formats framework-specific import statements for Java

func (*JavaInjector) FormatImports

func (h *JavaInjector) FormatImports(imports []string, hasExistingImports bool) string

FormatImports formats Java import statements

func (*JavaInjector) FormatSingleImport

func (h *JavaInjector) FormatSingleImport(importPath string) string

FormatSingleImport formats a single Java import statement

func (*JavaInjector) GenerateFrameworkModifications

func (h *JavaInjector) GenerateFrameworkModifications(content []byte, operationsData *types.OperationsData) []types.CodeModification

GenerateFrameworkModifications generates framework-specific instrumentation modifications for Java

func (*JavaInjector) GenerateImportModifications

func (h *JavaInjector) GenerateImportModifications(content []byte, analysis *types.FileAnalysis) []types.CodeModification

GenerateImportModifications generates modifications to fix import statements

func (*JavaInjector) GetConfig

func (h *JavaInjector) GetConfig() *types.LanguageConfig

GetConfig returns the language configuration for Java

func (*JavaInjector) GetFrameworkImports

func (h *JavaInjector) GetFrameworkImports(content []byte) []string

GetFrameworkImports returns framework-specific imports based on detected frameworks

func (*JavaInjector) GetInsertionPointPriority

func (h *JavaInjector) GetInsertionPointPriority(captureName string) int

GetInsertionPointPriority returns priority for Java insertion point types

func (*JavaInjector) GetLanguage

func (h *JavaInjector) GetLanguage() *sitter.Language

GetLanguage returns the tree-sitter language parser for Java

func (*JavaInjector) GetMavenDependencies

func (h *JavaInjector) GetMavenDependencies() []string

GetMavenDependencies returns the list of Maven dependencies needed for OTEL in Java

func (*JavaInjector) GetRequiredImports

func (h *JavaInjector) GetRequiredImports() []string

GetRequiredImports returns the list of imports needed for OTEL in Java

type JavaScriptInjector

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

JavaScriptInjector implements LanguageInjector for JavaScript

func NewJavaScriptInjector

func NewJavaScriptInjector() *JavaScriptInjector

NewJavaScriptInjector creates a new handler

func (*JavaScriptInjector) AnalyzeFunctionCapture

func (h *JavaScriptInjector) AnalyzeFunctionCapture(captureName string, node *sitter.Node, content []byte, analysis *types.FileAnalysis, config *types.LanguageConfig)

AnalyzeFunctionCapture finds entry blocks

func (*JavaScriptInjector) AnalyzeImportCapture

func (h *JavaScriptInjector) AnalyzeImportCapture(captureName string, node *sitter.Node, content []byte, analysis *types.FileAnalysis)

AnalyzeImportCapture records imports

func (*JavaScriptInjector) FallbackAnalyzeEntryPoints

func (h *JavaScriptInjector) FallbackAnalyzeEntryPoints(content []byte, analysis *types.FileAnalysis)

FallbackAnalyzeEntryPoints: no-op for JavaScript; default program node is already considered

func (*JavaScriptInjector) FallbackAnalyzeImports

func (h *JavaScriptInjector) FallbackAnalyzeImports(content []byte, analysis *types.FileAnalysis)

FallbackAnalyzeImports: no-op for JS

func (*JavaScriptInjector) FormatFrameworkImports

func (h *JavaScriptInjector) FormatFrameworkImports(imports []string) string

FormatFrameworkImports formats framework-specific import statements for JavaScript

func (*JavaScriptInjector) FormatImports

func (h *JavaScriptInjector) FormatImports(imports []string, hasExisting bool) string

FormatImports formats JS import statements (ESM)

func (*JavaScriptInjector) FormatSingleImport

func (h *JavaScriptInjector) FormatSingleImport(importPath string) string

FormatSingleImport formats a single JS import

func (*JavaScriptInjector) GenerateFrameworkModifications

func (h *JavaScriptInjector) GenerateFrameworkModifications(content []byte, operationsData *types.OperationsData) []types.CodeModification

GenerateFrameworkModifications generates framework-specific instrumentation modifications for JavaScript

func (*JavaScriptInjector) GenerateImportModifications

func (h *JavaScriptInjector) GenerateImportModifications(content []byte, analysis *types.FileAnalysis) []types.CodeModification

GenerateImportModifications generates modifications to fix import statements

func (*JavaScriptInjector) GetConfig

func (h *JavaScriptInjector) GetConfig() *types.LanguageConfig

GetConfig returns the language configuration

func (*JavaScriptInjector) GetFrameworkImports

func (h *JavaScriptInjector) GetFrameworkImports(content []byte) []string

GetFrameworkImports returns framework-specific imports based on detected frameworks

func (*JavaScriptInjector) GetInsertionPointPriority

func (h *JavaScriptInjector) GetInsertionPointPriority(captureName string) int

GetInsertionPointPriority for JS

func (*JavaScriptInjector) GetLanguage

func (h *JavaScriptInjector) GetLanguage() *sitter.Language

GetLanguage returns the tree-sitter language for JavaScript

func (*JavaScriptInjector) GetRequiredImports

func (h *JavaScriptInjector) GetRequiredImports() []string

GetRequiredImports returns the list of imports needed for OTEL in JavaScript

type LanguageInjector

type LanguageInjector interface {
	// GetLanguage returns the tree-sitter language parser
	GetLanguage() *sitter.Language

	// GetConfig returns the language configuration
	GetConfig() *types.LanguageConfig

	// GetRequiredImports returns the list of imports needed for OTEL
	GetRequiredImports() []string

	// GetFrameworkImports returns framework-specific imports based on detected frameworks
	GetFrameworkImports(content []byte) []string

	// FormatImports formats import statements for this language
	FormatImports(imports []string, hasExistingImports bool) string

	// FormatSingleImport formats a single import statement
	FormatSingleImport(importPath string) string

	// FormatFrameworkImports formats framework-specific import statements
	FormatFrameworkImports(imports []string) string

	// AnalyzeImportCapture processes an import capture from tree-sitter query
	AnalyzeImportCapture(captureName string, node *sitter.Node, content []byte, analysis *types.FileAnalysis)

	// AnalyzeFunctionCapture processes a function capture from tree-sitter query
	AnalyzeFunctionCapture(captureName string, node *sitter.Node, content []byte, analysis *types.FileAnalysis, config *types.LanguageConfig)

	// GetInsertionPointPriority returns priority for insertion point types
	GetInsertionPointPriority(captureName string) int

	// GenerateFrameworkModifications generates framework-specific instrumentation modifications
	GenerateFrameworkModifications(content []byte, operationsData *types.OperationsData) []types.CodeModification

	// FallbackAnalyzeImports allows language-specific analysis if tree-sitter didn't find enough info
	FallbackAnalyzeImports(content []byte, analysis *types.FileAnalysis)

	// FallbackAnalyzeEntryPoints allows language-specific entrypoint discovery if tree-sitter didn't find any
	FallbackAnalyzeEntryPoints(content []byte, analysis *types.FileAnalysis)

	// GenerateImportModifications generates modifications to fix import statements
	GenerateImportModifications(content []byte, analysis *types.FileAnalysis) []types.CodeModification
}

LanguageHandler defines the interface for language-specific code injection operations

type PHPInjector

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

PHPInjector implements LanguageInjector for PHP

func NewPHPInjector

func NewPHPInjector() *PHPInjector

NewPHPInjector creates a new PHP handler

func (*PHPInjector) AnalyzeFunctionCapture

func (h *PHPInjector) AnalyzeFunctionCapture(captureName string, node *sitter.Node, content []byte, analysis *types.FileAnalysis, config *types.LanguageConfig)

func (*PHPInjector) AnalyzeImportCapture

func (h *PHPInjector) AnalyzeImportCapture(captureName string, node *sitter.Node, content []byte, analysis *types.FileAnalysis)

func (*PHPInjector) FallbackAnalyzeEntryPoints

func (h *PHPInjector) FallbackAnalyzeEntryPoints(content []byte, analysis *types.FileAnalysis)

FallbackAnalyzeEntryPoints: if none detected, treat file start as entry

func (*PHPInjector) FallbackAnalyzeImports

func (h *PHPInjector) FallbackAnalyzeImports(content []byte, analysis *types.FileAnalysis)

FallbackAnalyzeImports: try to place require after opening tag if no locations found

func (*PHPInjector) FormatFrameworkImports

func (h *PHPInjector) FormatFrameworkImports(imports []string) string

FormatFrameworkImports formats framework-specific import statements for PHP

func (*PHPInjector) FormatImports

func (h *PHPInjector) FormatImports(imports []string, hasExisting bool) string

func (*PHPInjector) FormatSingleImport

func (h *PHPInjector) FormatSingleImport(importPath string) string

func (*PHPInjector) GenerateFrameworkModifications

func (h *PHPInjector) GenerateFrameworkModifications(content []byte, operationsData *types.OperationsData) []types.CodeModification

GenerateFrameworkModifications generates framework-specific instrumentation modifications for PHP

func (*PHPInjector) GenerateImportModifications

func (h *PHPInjector) GenerateImportModifications(content []byte, analysis *types.FileAnalysis) []types.CodeModification

GenerateImportModifications generates modifications to fix import statements

func (*PHPInjector) GetConfig

func (h *PHPInjector) GetConfig() *types.LanguageConfig

func (*PHPInjector) GetFrameworkImports

func (h *PHPInjector) GetFrameworkImports(content []byte) []string

GetFrameworkImports returns framework-specific imports based on detected frameworks

func (*PHPInjector) GetInsertionPointPriority

func (h *PHPInjector) GetInsertionPointPriority(captureName string) int

func (*PHPInjector) GetLanguage

func (h *PHPInjector) GetLanguage() *sitter.Language

func (*PHPInjector) GetRequiredImports

func (h *PHPInjector) GetRequiredImports() []string

GetRequiredImports returns the list of imports needed for OTEL in PHP

type PythonInjector

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

PythonInjector implements LanguageHandler for Python

func NewPythonInjector

func NewPythonInjector() *PythonInjector

NewPythonInjector creates a new Python language handler

func (*PythonInjector) AnalyzeFunctionCapture

func (h *PythonInjector) AnalyzeFunctionCapture(captureName string, node *sitter.Node, content []byte, analysis *types.FileAnalysis, config *types.LanguageConfig)

AnalyzeFunctionCapture processes a function capture from tree-sitter query for Python

func (*PythonInjector) AnalyzeImportCapture

func (h *PythonInjector) AnalyzeImportCapture(captureName string, node *sitter.Node, content []byte, analysis *types.FileAnalysis)

AnalyzeImportCapture processes an import capture from tree-sitter query for Python

func (*PythonInjector) FallbackAnalyzeEntryPoints

func (h *PythonInjector) FallbackAnalyzeEntryPoints(content []byte, analysis *types.FileAnalysis)

FallbackAnalyzeEntryPoints uses regex to find the if __name__ == '__main__' block when tree-sitter misses it

func (*PythonInjector) FallbackAnalyzeImports

func (h *PythonInjector) FallbackAnalyzeImports(content []byte, analysis *types.FileAnalysis)

FallbackAnalyzeImports for Python: no-op since tree-sitter captures are sufficient

func (*PythonInjector) FormatFrameworkImports

func (h *PythonInjector) FormatFrameworkImports(imports []string) string

FormatFrameworkImports formats framework-specific import statements for Python

func (*PythonInjector) FormatImports

func (h *PythonInjector) FormatImports(imports []string, hasExistingImports bool) string

FormatImports formats Python import statements

func (*PythonInjector) FormatSingleImport

func (h *PythonInjector) FormatSingleImport(importPath string) string

FormatSingleImport formats a single Python import statement

func (*PythonInjector) GenerateFrameworkModifications

func (h *PythonInjector) GenerateFrameworkModifications(content []byte, operationsData *types.OperationsData) []types.CodeModification

GenerateFrameworkModifications generates framework-specific instrumentation modifications

func (*PythonInjector) GenerateImportModifications

func (h *PythonInjector) GenerateImportModifications(content []byte, analysis *types.FileAnalysis) []types.CodeModification

GenerateImportModifications generates modifications to fix import statements

func (*PythonInjector) GetConfig

func (h *PythonInjector) GetConfig() *types.LanguageConfig

GetConfig returns the language configuration for Python

func (*PythonInjector) GetFrameworkImports

func (h *PythonInjector) GetFrameworkImports(content []byte) []string

GetFrameworkImports returns framework-specific imports based on detected frameworks

func (*PythonInjector) GetInsertionPointPriority

func (h *PythonInjector) GetInsertionPointPriority(captureName string) int

GetInsertionPointPriority returns priority for Python insertion point types

func (*PythonInjector) GetLanguage

func (h *PythonInjector) GetLanguage() *sitter.Language

GetLanguage returns the tree-sitter language parser for Python

func (*PythonInjector) GetRequiredImports

func (h *PythonInjector) GetRequiredImports() []string

GetRequiredImports returns the list of imports needed for OTEL in Python

type RubyInjector

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

RubyInjector implements LanguageInjector for Ruby

func NewRubyInjector

func NewRubyInjector() *RubyInjector

NewRubyInjector creates a new Ruby language handler

func (*RubyInjector) AnalyzeFunctionCapture

func (h *RubyInjector) AnalyzeFunctionCapture(captureName string, node *sitter.Node, content []byte, analysis *types.FileAnalysis, config *types.LanguageConfig)

AnalyzeFunctionCapture marks the whole program as main block

func (*RubyInjector) AnalyzeImportCapture

func (h *RubyInjector) AnalyzeImportCapture(captureName string, node *sitter.Node, content []byte, analysis *types.FileAnalysis)

AnalyzeImportCapture processes import captures

func (*RubyInjector) FallbackAnalyzeEntryPoints

func (h *RubyInjector) FallbackAnalyzeEntryPoints(content []byte, analysis *types.FileAnalysis)

FallbackAnalyzeEntryPoints: no-op; treat entire file as main

func (*RubyInjector) FallbackAnalyzeImports

func (h *RubyInjector) FallbackAnalyzeImports(content []byte, analysis *types.FileAnalysis)

FallbackAnalyzeImports: no-op for now

func (*RubyInjector) FormatFrameworkImports

func (h *RubyInjector) FormatFrameworkImports(imports []string) string

FormatFrameworkImports formats framework-specific import statements for Ruby

func (*RubyInjector) FormatImports

func (h *RubyInjector) FormatImports(imports []string, hasExistingImports bool) string

FormatImports formats Ruby require statements

func (*RubyInjector) FormatSingleImport

func (h *RubyInjector) FormatSingleImport(importPath string) string

FormatSingleImport formats a single Ruby require

func (*RubyInjector) GenerateFrameworkModifications

func (h *RubyInjector) GenerateFrameworkModifications(content []byte, operationsData *types.OperationsData) []types.CodeModification

GenerateFrameworkModifications generates framework-specific instrumentation modifications for Ruby

func (*RubyInjector) GenerateImportModifications

func (h *RubyInjector) GenerateImportModifications(content []byte, analysis *types.FileAnalysis) []types.CodeModification

GenerateImportModifications generates modifications to fix import statements

func (*RubyInjector) GetConfig

func (h *RubyInjector) GetConfig() *types.LanguageConfig

GetConfig returns the language configuration

func (*RubyInjector) GetFrameworkImports

func (h *RubyInjector) GetFrameworkImports(content []byte) []string

GetFrameworkImports returns framework-specific imports based on detected frameworks

func (*RubyInjector) GetInsertionPointPriority

func (h *RubyInjector) GetInsertionPointPriority(captureName string) int

GetInsertionPointPriority returns priority for insertion types

func (*RubyInjector) GetLanguage

func (h *RubyInjector) GetLanguage() *sitter.Language

GetLanguage returns the tree-sitter language for Ruby

func (*RubyInjector) GetRequiredImports

func (h *RubyInjector) GetRequiredImports() []string

GetRequiredImports returns the list of imports needed for OTEL in Ruby

Jump to

Keyboard shortcuts

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