@@ -59,6 +59,8 @@ type ConnectionsCheck struct {
5959
6060 // Use this as the network relation cache to calculate rate metrics and drop short-lived network relations
6161 cache * NetworkRelationCache
62+
63+ podCorrelation * podCorrelationInfo
6264}
6365
6466// Name returns the name of the ConnectionsCheck.
@@ -146,6 +148,21 @@ func (c *ConnectionsCheck) Run(cfg *config.AgentConfig, groupID int32, currentTi
146148 protocolMap [k ] = config .PostgresProtocolName
147149 }
148150
151+ log .Debugf ("Protocol map: %v" , protocolMap )
152+ log .Debugf ("collected %d connection data" , len (connectionStats ))
153+ for key , metrics := range connectionStats {
154+ log .Debugf ("connection data for %s" , key )
155+ for _ , metric := range metrics {
156+ log .Debugf ("\t %v" , metric )
157+ }
158+ }
159+ // Here we have all we need to export OTEL metrics
160+ // We cannot filter short-lived connections because we need them for the security use case.
161+ if c .podCorrelation != nil {
162+ c .podCorrelation .processConnections (conns .Conns , connectionStats )
163+ // In the future we could return here and disable all the rest of the logic, also the process Check
164+ }
165+
149166 httpObservations := aggregateHTTPTraceObservations (conns .HTTPObservations )
150167
151168 dnsMap := map [string ][]dns.Hostname {}
@@ -160,15 +177,6 @@ func (c *ConnectionsCheck) Run(cfg *config.AgentConfig, groupID int32, currentTi
160177 containerToPod = c .podsCache .GetContainerToPodMap (context .TODO ())
161178 }
162179
163- log .Debugf ("Protocol map: %v" , protocolMap )
164- log .Debugf ("collected %d connection data" , len (connectionStats ))
165- for key , metrics := range connectionStats {
166- log .Debugf ("connection data for %s" , key )
167- for _ , metric := range metrics {
168- log .Debugf ("\t %v" , metric )
169- }
170- }
171-
172180 formattedConnections , connsPods := c .formatConnections (cfg , conns .Conns , connectionStats , httpObservations , containerToPod , protocolMap )
173181 c .prevCheckTime = currentTime
174182
0 commit comments