| 111 | } |
| 112 | |
| 113 | type Proxy struct { |
| 114 | logger *zap.Logger |
| 115 | |
| 116 | IP4 string |
| 117 | IP6 string |
| 118 | Port uint32 |
| 119 | IncomingProxyPort uint16 |
| 120 | DNSPort uint32 |
| 121 | |
| 122 | DestInfo agent.DestInfo |
| 123 | Integrations map[integrations.IntegrationType]integrations.Integrations |
| 124 | |
| 125 | integrationsPriority []ParserPriority |
| 126 | errChannel chan error |
| 127 | |
| 128 | // activeTestErrors accumulates mock-not-found errors during active test |
| 129 | // execution. The continuous drain goroutine routes errors here when non-nil. |
| 130 | // When nil (no window), mock-not-found errors fall to pendingMockErrors and |
| 131 | // only non-mock noise (OTel, health checks) is discarded — keeping the |
| 132 | // errChannel drained either way. |
| 133 | activeTestErrors atomic.Pointer[testErrorAccumulator] |
| 134 | // captureMu serializes the drain goroutine's routing decision (read |
| 135 | // activeTestErrors, then add) against BeginTestErrorCapture / GetMockErrors |
| 136 | // opening or closing the window. Without it, the goroutine could add a miss |
| 137 | // to an accumulator that GetMockErrors has just swapped away, losing it. |
| 138 | captureMu sync.Mutex |
| 139 | // errDrainActive is true while the StartErrorDrain goroutine is running. It |
| 140 | // gates the GetMockErrors flush-marker rendezvous (which needs that single |
| 141 | // owner to consume the marker); when false we use the legacy direct sweep. |
| 142 | errDrainActive atomic.Bool |
| 143 | errDrainOnce sync.Once |
| 144 | // pendingMockErrors retains mock-not-found errors that arrive while no test |
| 145 | // capture window is active (activeTestErrors is nil) — e.g. between tests, |
| 146 | // or when the replayer/agent predates the BeginTestErrorCapture wiring. The |
| 147 | // replayer normally opens a window per test (so misses route to |
| 148 | // activeTestErrors), but this remains the fallback so a miss is never |
| 149 | // silently dropped before GetMockErrors reads it. Only mock-not-found errors |
| 150 | // are retained (background noise — OTel, health checks — is still |
| 151 | // discarded), and the buffer is bounded so it can't grow unboundedly. |
| 152 | pendingMockErrors testErrorAccumulator |
| 153 | // session holds the single active session for this proxy. |
| 154 | // Previously this was a sync.Map keyed by appID (always 0), which is |
| 155 | // no longer needed since the proxy serves a single client-app. |
| 156 | sessionMu sync.RWMutex |
| 157 | session *agent.Session |
| 158 | mockManager *MockManager |
| 159 | |
| 160 | // sessionResolver, when set, maps a connection's owning TGID to the |
| 161 | // session that should handle it. It is the seam by which an external |
| 162 | // composer (the enterprise multi-app agent) routes per-app traffic |
| 163 | // without this package knowing what an "app" is. nil ⇒ single-session |
| 164 | // mode: GetSessionFor falls back to the single session field above. |
| 165 | // Guarded by sessionMu. |
| 166 | sessionResolver func(tgid uint32) *agent.Session |
| 167 | |
| 168 | synchronous bool |
| 169 | |
| 170 | connMutex *sync.Mutex |
nothing calls this directly
no outgoing calls
no test coverage detected