@@ -74,7 +74,7 @@ type exposureSubject struct {
7474
7575// exposureContext represents service context metadata for the exposure payload
7676type exposureContext struct {
77- ServiceName string `json:"service_name "`
77+ ServiceName string `json:"service "`
7878 Version string `json:"version,omitempty"`
7979 Env string `json:"env,omitempty"`
8080}
@@ -85,17 +85,10 @@ type exposurePayload struct {
8585 Exposures []exposureEvent `json:"exposures"`
8686}
8787
88- type bufferKey struct {
89- flagKey string
90- allocationKey string
91- variantKey string
92- subjectID string
93- }
94-
9588// exposureWriter manages buffering and flushing of exposure events to the Datadog Agent
9689type exposureWriter struct {
9790 mu sync.Mutex
98- buffer map [ bufferKey ]exposureEvent // Deduplicate by composite key
91+ buffer [ ]exposureEvent // Buffer for exposure events
9992 flushInterval time.Duration
10093 httpClient * http.Client
10194 agentURL * url.URL
@@ -143,7 +136,7 @@ func newExposureWriter(config ProviderConfig) *exposureWriter {
143136 }
144137
145138 return & exposureWriter {
146- buffer : make (map [ bufferKey ]exposureEvent ),
139+ buffer : make ([ ]exposureEvent , 0 ),
147140 flushInterval : flushInterval ,
148141 httpClient : httpClient ,
149142 agentURL : agentURL ,
@@ -167,7 +160,7 @@ func (w *exposureWriter) start() {
167160 }()
168161}
169162
170- // append adds an exposure event to the buffer with deduplication
163+ // append adds an exposure event to the buffer
171164func (w * exposureWriter ) append (event exposureEvent ) {
172165 w .mu .Lock ()
173166 defer w .mu .Unlock ()
@@ -176,17 +169,9 @@ func (w *exposureWriter) append(event exposureEvent) {
176169 return
177170 }
178171
179- // Create composite key for deduplication
180- // Deduplicate by flag, allocation, variant, and subject.id
181- key := bufferKey {
182- flagKey : event .Flag .Key ,
183- allocationKey : event .Allocation .Key ,
184- variantKey : event .Variant .Key ,
185- subjectID : event .Subject .ID ,
186- }
187-
188- // Store event (will overwrite if duplicate)
189- w .buffer [key ] = event
172+ // Append event to buffer
173+ // Each exposure event is tracked individually to maintain accurate analytics
174+ w .buffer = append (w .buffer , event )
190175}
191176
192177// flush sends all buffered exposure events to the agent
@@ -198,11 +183,8 @@ func (w *exposureWriter) flush() {
198183 }
199184
200185 // Move buffer to local variable and create new buffer
201- events := make ([]exposureEvent , 0 , len (w .buffer ))
202- for _ , event := range w .buffer {
203- events = append (events , event )
204- }
205- w .buffer = make (map [bufferKey ]exposureEvent )
186+ events := w .buffer
187+ w .buffer = make ([]exposureEvent , 0 )
206188 w .mu .Unlock ()
207189
208190 // Build payload
0 commit comments