Documentation
¶
Index ¶
- Variables
- type CacheEntry
- type ContainerInfo
- type EBPFDetector
- type LanguageCache
- func (lc *LanguageCache) Get(image string, envVars map[string]string) (*ContainerInfo, bool)
- func (lc *LanguageCache) GetAllActiveContainers() []ContainerInfo
- func (lc *LanguageCache) GetAllActiveWorkloads() []WorkloadCacheEntry
- func (lc *LanguageCache) GetWorkload(namespace, workloadName string) (*WorkloadCacheEntry, bool)
- func (lc *LanguageCache) RemoveWorkload(namespace, workloadName string)
- func (lc *LanguageCache) Set(image string, envVars map[string]string, info ContainerInfo)
- func (lc *LanguageCache) SetWorkload(namespace, workloadName, workloadKind string, ...)
- func (lc *LanguageCache) UpdateWorkloadContainer(namespace, workloadName, workloadKind string, info ContainerInfo)
- type PolylangDetector
- func (pd *PolylangDetector) DetectLanguageWithProcInspection(namespace, podName string) ([]ContainerInfo, error)
- func (c *PolylangDetector) DialWithRetry(ctx context.Context, retryInterval time.Duration) error
- func (pd *PolylangDetector) SendBatch(batch []ContainerInfo)
- func (pd *PolylangDetector) ShouldMonitorNamespace(namespace string) bool
- func (pd *PolylangDetector) StartEBPFDetection(ctx context.Context) error
- type ProcBasedDetector
- type WorkloadCacheEntry
Constants ¶
This section is empty.
Variables ¶
var OtelSupportedLanguages = map[string]string{
"Go": "go",
"nodejs": "node",
"Python": "python",
"Java": "java",
".NET": "dotnet",
}
OtelSupportedLanguages lists languages supported for OpenTelemetry auto-instrumentation
Functions ¶
This section is empty.
Types ¶
type CacheEntry ¶
type CacheEntry struct {
Info ContainerInfo
}
CacheEntry represents a cached detection result (no expiration)
type ContainerInfo ¶
type ContainerInfo struct {
PodName string
Namespace string
ContainerName string
Image string
Kind string
EnvVars map[string]string
ProcessCommands []string
DetectedAt time.Time
Language string
Framework string
Enabled bool
Confidence string
DeploymentName string
Evidence []string
}
ContainerInfo holds the detected information for a single container.
type EBPFDetector ¶
type EBPFDetector struct {
Clientset *kubernetes.Clientset
LanguageDetector *inspectors.LanguageDetector
Cache *LanguageCache
Logger *zap.Logger
// contains filtered or unexported fields
}
EBPFDetector uses the pattern: watch pods, then inspect with eBPF
func NewEBPFDetector ¶
func NewEBPFDetector(clientset *kubernetes.Clientset, cache *LanguageCache, logger *zap.Logger, queue chan ContainerInfo) (*EBPFDetector, error)
NewEBPFDetector creates a new eBPF-based detector
type LanguageCache ¶
type LanguageCache struct {
// contains filtered or unexported fields
}
LanguageCache provides thread-safe caching of language detection results It maintains both image-based cache and workload-based cache for cluster state synchronization Cache entries persist until workload is explicitly deleted - no time-based expiration
func NewLanguageCache ¶
func NewLanguageCache(ttl time.Duration) *LanguageCache
NewLanguageCache creates a new cache (ttl parameter kept for compatibility but not used)
func (*LanguageCache) Get ¶
func (lc *LanguageCache) Get(image string, envVars map[string]string) (*ContainerInfo, bool)
Get retrieves a cached result if it exists (no expiration check)
func (*LanguageCache) GetAllActiveContainers ¶
func (lc *LanguageCache) GetAllActiveContainers() []ContainerInfo
GetAllActiveContainers returns all container infos from all workloads
func (*LanguageCache) GetAllActiveWorkloads ¶
func (lc *LanguageCache) GetAllActiveWorkloads() []WorkloadCacheEntry
GetAllActiveWorkloads returns all workloads in the cache
func (*LanguageCache) GetWorkload ¶
func (lc *LanguageCache) GetWorkload(namespace, workloadName string) (*WorkloadCacheEntry, bool)
GetWorkload retrieves cached detection results for a workload
func (*LanguageCache) RemoveWorkload ¶
func (lc *LanguageCache) RemoveWorkload(namespace, workloadName string)
RemoveWorkload completely removes a workload from the cache
func (*LanguageCache) Set ¶
func (lc *LanguageCache) Set(image string, envVars map[string]string, info ContainerInfo)
Set stores a detection result in the cache (persists until manually removed)
func (*LanguageCache) SetWorkload ¶
func (lc *LanguageCache) SetWorkload(namespace, workloadName, workloadKind string, containers map[string]ContainerInfo)
SetWorkload stores detection results for a specific workload
func (*LanguageCache) UpdateWorkloadContainer ¶
func (lc *LanguageCache) UpdateWorkloadContainer(namespace, workloadName, workloadKind string, info ContainerInfo)
UpdateWorkloadContainer updates a single container in a workload's cache
type PolylangDetector ¶
type PolylangDetector struct {
Clientset *kubernetes.Clientset
Config *rest.Config
RpcClient *rpc.Client
ServerAddr string
Logger *zap.Logger
DomainLogger interface {
LanguageDetectionStarted(namespace, podName, containerName string)
LanguageDetected(namespace, podName, containerName, image, language, framework, confidence string)
LanguageDetectionFailed(namespace, podName, containerName string, err error)
UnsupportedLanguage(language string)
CacheHit(image, language string)
CacheMiss(image string)
CacheStored(image, language string)
RPCBatchSent(count int, response string)
RPCBatchFailed(count int, err error)
DeploymentInfoRetrieved(namespace, podName, deploymentName, kind string)
DeploymentInfoFailed(namespace, podName string, err error)
}
IgnoredNamespaces []string
MonitoredNamespaces []string
Queue chan ContainerInfo
QueueSize int
BatchMutex sync.Mutex
Cache *LanguageCache
}
PolylangDetector contains the Kubernetes client to interact with the cluster.
func NewPolylangDetector ¶
func NewPolylangDetector(config *rest.Config, client *kubernetes.Clientset, domainLogger interface { LanguageDetectionStarted(namespace, podName, containerName string) LanguageDetected(namespace, podName, containerName, image, language, framework, confidence string) LanguageDetectionFailed(namespace, podName, containerName string, err error) UnsupportedLanguage(language string) CacheHit(image, language string) CacheMiss(image string) CacheStored(image, language string) RPCBatchSent(count int, response string) RPCBatchFailed(count int, err error) DeploymentInfoRetrieved(namespace, podName, deploymentName, kind string) DeploymentInfoFailed(namespace, podName string, err error) }) *PolylangDetector
NewPolylangDetector creates a new language detector
func (*PolylangDetector) DetectLanguageWithProcInspection ¶
func (pd *PolylangDetector) DetectLanguageWithProcInspection(namespace, podName string) ([]ContainerInfo, error)
DetectLanguageWithProcInspection detects language using /proc filesystem inspection (DaemonSet mode)
func (*PolylangDetector) DialWithRetry ¶
DialWithRetry attempts to connect to the RPC server with a backoff
func (*PolylangDetector) SendBatch ¶
func (pd *PolylangDetector) SendBatch(batch []ContainerInfo)
SendBatch sends a batch of container info to the RPC server
func (*PolylangDetector) ShouldMonitorNamespace ¶
func (pd *PolylangDetector) ShouldMonitorNamespace(namespace string) bool
ShouldMonitorNamespace determines if a namespace should be monitored based on configuration Priority: KM_K8S_MONITORED_NAMESPACES > KM_IGNORED_NS
func (*PolylangDetector) StartEBPFDetection ¶
func (pd *PolylangDetector) StartEBPFDetection(ctx context.Context) error
StartEBPFDetection starts eBPF-based real-time process detection (recommended mode)
type ProcBasedDetector ¶
type ProcBasedDetector struct {
Clientset *kubernetes.Clientset
LanguageDetector *inspectors.LanguageDetector
Cache *LanguageCache
Logger *zap.Logger
}
ProcBasedDetector uses /proc filesystem for language detection (DaemonSet mode)
func NewProcBasedDetector ¶
func NewProcBasedDetector(clientset *kubernetes.Clientset, cache *LanguageCache, logger *zap.Logger) *ProcBasedDetector
NewProcBasedDetector creates a new /proc-based language detector
func (*ProcBasedDetector) DetectLanguageForPod ¶
func (pd *ProcBasedDetector) DetectLanguageForPod(ctx context.Context, namespace, podName string) ([]ContainerInfo, error)
DetectLanguageForPod detects languages for all containers in a pod using /proc inspection
type WorkloadCacheEntry ¶
type WorkloadCacheEntry struct {
Namespace string
WorkloadName string
WorkloadKind string
Containers map[string]ContainerInfo // containerName -> ContainerInfo
}
WorkloadCacheEntry represents detection results for a specific workload (deployment/daemonset/replicaset)