otelmetrics

package
v0.3.195 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterPodMemoryMetrics added in v0.3.170

func RegisterPodMemoryMetrics(meter metric.Meter, ownContainerID, ownPodUID string, hostCgroupMounted bool)

RegisterPodMemoryMetrics registers pod-scoped memory gauges covering every container in this pod, including sidecars with no instrumentation of their own. Called only from registerResourceMetrics (the main agent), never from the shared RegisterProcessMemoryMetrics — registering it per-container would double-count the pod under any aggregation.

ownContainerID == "" registers nothing at all, so no empty series is ever emitted. This is by-design and silent for topologies with no Kubernetes pod concept at all (the sbom-scanner sidecar, cmd/host, cmd/ecs) — but on the Kubernetes DaemonSet (hostCgroupMounted == true) an empty ownContainerID is always anomalous (a startup race in resolveOwnContainerID, never a legitimate state), so that specific combination is logged.

func RegisterProcessMemoryMetrics

func RegisterProcessMemoryMetrics(meter metric.Meter, ownContainerID string, hostCgroupMounted bool)

RegisterProcessMemoryMetrics registers the per-process/per-container memory gauges — rss_bytes, cgroup_bytes, cgroup_limit_bytes — on the given meter. Both the main agent and the sbom-scanner sidecar call this so each container reports its own memory usage and limit (distinguished downstream by service.name). ownContainerID, when non-empty, lets the cgroup resolver find the correct scope under a host-mounted cgroup tree (the main-agent topology).

hostCgroupMounted must be true only for callers that bind-mount the HOST's /sys/fs/cgroup over their own (the Kubernetes DaemonSet). It must be false for every caller that mounts its own namespaced /sys/fs/cgroup — the sbom-scanner sidecar, and any entrypoint (cmd/host, cmd/ecs) that isn't the Kubernetes DaemonSet — regardless of whether ownContainerID happens to be known for that call. This can't be inferred from ownContainerID alone: see resolveCgroupMemoryPathsUnder's doc comment for why.

MUST be called after otelsetup.InitProviders so the real MeterProvider is set.

Types

type OTELMetricsManager

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

func NewOTELMetricsManager

func NewOTELMetricsManager(ownContainerID, ownPodUID string, hostCgroupMounted bool) *OTELMetricsManager

NewOTELMetricsManager constructs a fully-initialised OTELMetricsManager. MUST be called after otelsetup.InitProviders() so that otelsetup.Meter() returns the real MeterProvider, not the SDK no-op.

ownContainerID is this agent's own container ID (from the k8s API); it lets the cgroup memory gauges resolve the correct container scope. Pass "" when unknown.

ownPodUID is this agent's own pod UID (from the same k8s API call); it verifies the pod-level cgroup slice the pod memory gauges read from. Pass "" when unknown — the pod slice is then accepted on its name shape alone.

hostCgroupMounted MUST be true only for the caller that bind-mounts the HOST's /sys/fs/cgroup over its own (the Kubernetes DaemonSet). It MUST be false for every other caller — the sbom-scanner sidecar, or any entrypoint (cmd/host, cmd/ecs) that mounts its own namespaced /sys/fs/cgroup — regardless of whether ownContainerID is known for that call. Getting this wrong on a host-mounted caller with an unresolved container ID would silently report the whole node's memory as this container's own; see resolveCgroupMemoryPathsUnder's doc comment for the full reasoning. When hostCgroupMounted is false, a resolution failure simply falls back to /proc-based resolution and reports 0 if that also fails.

func (*OTELMetricsManager) Destroy

func (m *OTELMetricsManager) Destroy()

Destroy is a no-op: provider shutdown is handled by the otelsetup shutdown func.

func (*OTELMetricsManager) IncHelperCall

func (m *OTELMetricsManager) IncHelperCall(helper string)

func (*OTELMetricsManager) IncMissingProfileDataRequired

func (m *OTELMetricsManager) IncMissingProfileDataRequired(ruleID string)

func (*OTELMetricsManager) IncProjectionReconcileTriggered

func (m *OTELMetricsManager) IncProjectionReconcileTriggered(trigger string)

func (*OTELMetricsManager) IncProjectionSpecCompile

func (m *OTELMetricsManager) IncProjectionSpecCompile()

func (*OTELMetricsManager) IncProjectionSpecHashChange

func (m *OTELMetricsManager) IncProjectionSpecHashChange()

func (*OTELMetricsManager) IncProjectionUndeclaredLiteral

func (m *OTELMetricsManager) IncProjectionUndeclaredLiteral(helper string)

func (*OTELMetricsManager) IncUserDefinedProfileAdopted added in v0.3.194

func (m *OTELMetricsManager) IncUserDefinedProfileAdopted(namespace string)

func (*OTELMetricsManager) IncUserDefinedProfileUnresolved added in v0.3.194

func (m *OTELMetricsManager) IncUserDefinedProfileUnresolved(namespace string)

func (*OTELMetricsManager) ObserveProfileEntriesRaw

func (m *OTELMetricsManager) ObserveProfileEntriesRaw(field string, count float64)

func (*OTELMetricsManager) ObserveProfileEntriesRetained

func (m *OTELMetricsManager) ObserveProfileEntriesRetained(field string, count float64)

func (*OTELMetricsManager) ObserveProfileProjectedSize

func (m *OTELMetricsManager) ObserveProfileProjectedSize(bytes float64)

func (*OTELMetricsManager) ObserveProfileRawSize

func (m *OTELMetricsManager) ObserveProfileRawSize(bytes float64)

func (*OTELMetricsManager) ObserveProfileRetentionRatio

func (m *OTELMetricsManager) ObserveProfileRetentionRatio(field string, ratio float64)

func (*OTELMetricsManager) ObserveProjectionApplyDuration

func (m *OTELMetricsManager) ObserveProjectionApplyDuration(d time.Duration)

func (*OTELMetricsManager) ObserveSBOMScanDuration

func (m *OTELMetricsManager) ObserveSBOMScanDuration(status string, d time.Duration)

func (*OTELMetricsManager) ReportAlertSuppressed

func (m *OTELMetricsManager) ReportAlertSuppressed(ruleID, reason string)

func (*OTELMetricsManager) ReportContainerProfileCacheHit

func (m *OTELMetricsManager) ReportContainerProfileCacheHit(hit bool)

func (*OTELMetricsManager) ReportContainerProfileChunkDropped added in v0.3.166

func (m *OTELMetricsManager) ReportContainerProfileChunkDropped(reason string)

func (*OTELMetricsManager) ReportContainerProfileLegacyLoad

func (m *OTELMetricsManager) ReportContainerProfileLegacyLoad(kind, completeness string)

func (*OTELMetricsManager) ReportContainerProfileReconcilerDuration

func (m *OTELMetricsManager) ReportContainerProfileReconcilerDuration(phase string, duration time.Duration)

func (*OTELMetricsManager) ReportContainerProfileReconcilerEviction

func (m *OTELMetricsManager) ReportContainerProfileReconcilerEviction(reason string)

func (*OTELMetricsManager) ReportContainerProfileSplit added in v0.3.166

func (m *OTELMetricsManager) ReportContainerProfileSplit()

func (*OTELMetricsManager) ReportContainerStart

func (m *OTELMetricsManager) ReportContainerStart()

func (*OTELMetricsManager) ReportContainerStop

func (m *OTELMetricsManager) ReportContainerStop()

func (*OTELMetricsManager) ReportDedupEvent

func (m *OTELMetricsManager) ReportDedupEvent(eventType utils.EventType, duplicate bool)

func (*OTELMetricsManager) ReportEvent

func (m *OTELMetricsManager) ReportEvent(eventType utils.EventType)

func (*OTELMetricsManager) ReportFailedEvent

func (m *OTELMetricsManager) ReportFailedEvent()

func (*OTELMetricsManager) ReportRuleAlert

func (m *OTELMetricsManager) ReportRuleAlert(ruleID string)

func (*OTELMetricsManager) ReportRuleEvaluationTime

func (m *OTELMetricsManager) ReportRuleEvaluationTime(ctx context.Context, ruleID string, eventType utils.EventType, duration time.Duration)

func (*OTELMetricsManager) ReportRulePrefiltered

func (m *OTELMetricsManager) ReportRulePrefiltered(ruleID string)

func (*OTELMetricsManager) ReportRuleProcessed

func (m *OTELMetricsManager) ReportRuleProcessed(ruleID string)

func (*OTELMetricsManager) ReportSBOMScan

func (m *OTELMetricsManager) ReportSBOMScan(status string)

func (*OTELMetricsManager) ReportSBOMScannerRestart

func (m *OTELMetricsManager) ReportSBOMScannerRestart()

func (*OTELMetricsManager) SetContainerProfileCacheEntries

func (m *OTELMetricsManager) SetContainerProfileCacheEntries(kind string, count float64)

func (*OTELMetricsManager) SetProjectionSpecAllField

func (m *OTELMetricsManager) SetProjectionSpecAllField(field string, isAll bool)

func (*OTELMetricsManager) SetProjectionSpecPatterns

func (m *OTELMetricsManager) SetProjectionSpecPatterns(field, kind string, count float64)

func (*OTELMetricsManager) SetProjectionStaleEntries

func (m *OTELMetricsManager) SetProjectionStaleEntries(count float64)

func (*OTELMetricsManager) SetProjectionUndeclaredRules

func (m *OTELMetricsManager) SetProjectionUndeclaredRules(count float64)

func (*OTELMetricsManager) SetProjectionUndeclaredRulesDetail

func (m *OTELMetricsManager) SetProjectionUndeclaredRulesDetail(ruleIDs []string)

SetProjectionUndeclaredRulesDetail records 1 for each rule currently undeclared and 0 for rules that were in the previous call but are no longer undeclared. OTEL synchronous gauges have no Reset(); zeroing removed entries is the equivalent.

func (*OTELMetricsManager) SetSBOMScannerReady

func (m *OTELMetricsManager) SetSBOMScannerReady(ready bool)

func (*OTELMetricsManager) Start

func (m *OTELMetricsManager) Start()

Start is a no-op: the Prometheus HTTP listener (if configured) is started inside otelsetup.InitProviders when OTEL_METRICS_EXPORTER=prometheus.

Jump to

Keyboard shortcuts

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