Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CodeGenerationStrategy ¶
type CodeGenerationStrategy interface { // GenerateCode generates instrumentation code for the given opportunities GenerateCode(ctx context.Context, opportunities []domain.Opportunity, req GenerationRequest) error // GetName returns the name of the strategy GetName() string // IsAvailable checks if this strategy can be used in the current environment IsAvailable() bool // GetRequiredFlags returns flags that are required for this strategy GetRequiredFlags() []string }
CodeGenerationStrategy defines the interface for different code generation approaches
type CodeModification ¶
type CodeModification struct { Type ModificationType `json:"type"` Language string `json:"language"` FilePath string `json:"file_path"` LineNumber uint32 `json:"line_number"` Column uint32 `json:"column"` InsertBefore bool `json:"insert_before"` InsertAfter bool `json:"insert_after"` Content string `json:"content"` Context string `json:"context"` // Surrounding code context for validation Framework string `json:"framework,omitempty"` // Framework name for framework-specific modifications }
CodeModification represents a modification to be applied to source code
type EntryPointInfo ¶
type EntryPointInfo struct { Name string `json:"name"` LineNumber uint32 `json:"line_number"` Column uint32 `json:"column"` BodyStart InsertionPoint `json:"body_start"` BodyEnd InsertionPoint `json:"body_end"` HasOTELSetup bool `json:"has_otel_setup"` }
EntryPointInfo contains information about an entry point in the file
type FileAnalysis ¶
type FileAnalysis struct { Language string `json:"language"` FilePath string `json:"file_path"` HasOTELImports bool `json:"has_otel_imports"` HasOTELSetup bool `json:"has_otel_setup"` EntryPoints []EntryPointInfo `json:"entry_points"` ImportLocations []InsertionPoint `json:"import_locations"` FunctionBodies map[string]InsertionPoint `json:"function_bodies"` ExistingImports map[string]bool `json:"existing_imports"` }
FileAnalysis contains the analysis results for a source file
type GenerationMode ¶
type GenerationMode string
GenerationMode represents different code generation approaches
const ( // AgentMode uses AI agents for code generation AgentMode GenerationMode = "agent" // TemplateMode uses templates for direct code generation TemplateMode GenerationMode = "template" )
type GenerationRequest ¶
type GenerationRequest struct { CodebasePath string `json:"codebase_path"` Language string `json:"language,omitempty"` Method string `json:"method"` // Changed from templates.InstallationMethod to string AgentType string `json:"agent_type"` // Changed from agents.AgentType to string Config StrategyConfig `json:"config"` // Advanced OpenTelemetry configuration loaded from YAML (optional) OTEL *OTELConfig `json:"otel,omitempty"` }
GenerationRequest contains parameters for code generation
type InsertionPoint ¶
type InsertionPoint struct { LineNumber uint32 `json:"line_number"` Column uint32 `json:"column"` Context string `json:"context"` Priority int `json:"priority"` // Higher priority = better insertion point }
InsertionPoint represents a location where code can be inserted
type LanguageConfig ¶
type LanguageConfig struct { Language string `json:"language"` FileExtensions []string `json:"file_extensions"` ImportQueries map[string]string `json:"import_queries"` // Query name -> Tree-sitter query FunctionQueries map[string]string `json:"function_queries"` // Query name -> Tree-sitter query InsertionQueries map[string]string `json:"insertion_queries"` // Query name -> Tree-sitter query CodeTemplates map[string]string `json:"code_templates"` // Template name -> code template ImportTemplate string `json:"import_template"` // How to format imports InitializationTemplate string `json:"initialization_template"` // How to format OTEL initialization CleanupTemplate string `json:"cleanup_template"` // How to format cleanup code FrameworkTemplates map[string]string `json:"framework_templates"` // Framework name -> instrumentation template // InitAtTop indicates the initialization snippet must be placed at the very top of the file // before any other imports/requires. Useful for languages/runtimes that require early bootstrap. InitAtTop bool `json:"init_at_top,omitempty"` }
LanguageConfig defines how to modify code for a specific language
type ModificationType ¶
type ModificationType string
ModificationType represents the type of code modification
const ( ModificationAddImport ModificationType = "add_import" ModificationAddInit ModificationType = "add_initialization" ModificationAddCleanup ModificationType = "add_cleanup" ModificationWrapFunction ModificationType = "wrap_function" ModificationAddMiddleware ModificationType = "add_middleware" ModificationAddFramework ModificationType = "add_framework" ModificationRemoveLine ModificationType = "remove_line" )
type OTELConfig ¶
type OTELConfig struct { // Service metadata ServiceName string `json:"service_name" yaml:"service_name"` ServiceVersion string `json:"service_version" yaml:"service_version"` Environment string `json:"environment" yaml:"environment"` ResourceAttrs map[string]string `json:"resource_attributes" yaml:"resource_attributes"` // Instrumentations to enable (per language these map to specific packages) Instrumentations []string `json:"instrumentations" yaml:"instrumentations"` // Context propagation Propagators []string `json:"propagators" yaml:"propagators"` // Sampling configuration Sampler struct { Type string `json:"type" yaml:"type"` // e.g., always_on, always_off, traceidratio, parentbased_traceidratio Ratio float64 `json:"ratio" yaml:"ratio"` // used for ratio-based samplers Parent string `json:"parent" yaml:"parent"` // for parentbased sub-type Rules []string `json:"rules" yaml:"rules"` // reserved for advanced/language-specific } `json:"sampler" yaml:"sampler"` // Exporters and endpoints Exporters struct { Traces struct { Type string `json:"type" yaml:"type"` // e.g., otlp, console, jaeger Protocol string `json:"protocol" yaml:"protocol"` // http/protobuf, grpc Endpoint string `json:"endpoint" yaml:"endpoint"` Headers map[string]string `json:"headers" yaml:"headers"` Insecure bool `json:"insecure" yaml:"insecure"` TimeoutMs int `json:"timeout_ms" yaml:"timeout_ms"` } `json:"traces" yaml:"traces"` Metrics struct { Type string `json:"type" yaml:"type"` Protocol string `json:"protocol" yaml:"protocol"` Endpoint string `json:"endpoint" yaml:"endpoint"` Insecure bool `json:"insecure" yaml:"insecure"` } `json:"metrics" yaml:"metrics"` Logs struct { Type string `json:"type" yaml:"type"` Protocol string `json:"protocol" yaml:"protocol"` Endpoint string `json:"endpoint" yaml:"endpoint"` Insecure bool `json:"insecure" yaml:"insecure"` } `json:"logs" yaml:"logs"` } `json:"exporters" yaml:"exporters"` // Span processors and additional SDK knobs SpanProcessors []string `json:"span_processors" yaml:"span_processors"` SDK map[string]string `json:"sdk" yaml:"sdk"` }
OTELConfig represents advanced OpenTelemetry configuration that can be provided via a YAML file and applied across languages. Deprecated: use internal/config.OTELConfig instead. Kept temporarily to avoid massive churn.
type OperationsData ¶
type OperationsData struct { InstallOTEL bool `json:"install_otel"` // Whether OTEL needs to be installed InstallInstrumentations []string `json:"install_instrumentations"` // Instrumentations to install InstallComponents map[string][]string `json:"install_components"` // Components to install by type (sdk, propagator, exporter) RemoveComponents map[string][]string `json:"remove_components"` // Components to remove by type }
OperationsData contains the analysis of opportunities organized by operation type
type StrategyConfig ¶
type StrategyConfig struct { Mode GenerationMode `json:"mode"` AgentType string `json:"agent_type,omitempty"` OutputDirectory string `json:"output_directory,omitempty"` DryRun bool `json:"dry_run,omitempty"` // AI mode options ShowPrompt bool `json:"show_prompt,omitempty"` SavePrompt string `json:"save_prompt,omitempty"` }
StrategyConfig contains configuration for generation strategies