You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I briefly skimmed the code, and I'm not yet 100% following. Sending multiple events should invoke Send, i.e., makeRequest every single time (per event), thus creating a new http.Request for each call:
Hey @embano1, yeah a new request is made, but if you look at the second snippet, is initialises Request.Header with a call to HeaderFrom(ctx). This passes the same value on each invocation. Since http.Header is just a map[string][]string, it's passing the same map each time, and modifications to that map are retained.
I believe cloning the headers each time should fix this issue. I don't mind providing a PR, just it was late Friday evening when I finally spotted the bug (it's affecting us in production) so we just made a local fix on our own codebase for now.
FYI, a temporary workaround is to override the context value with a cloned copy before calling Send(). i.e:
These functions enable users to customise the base set of headers to send to a CE consumer:
sdk-go/v2/protocol/http/headers.go
Lines 49 to 55 in a9224ad
Then it's used in
Protocol.makeRequest(context.Context)
to create our new HTTP request:sdk-go/v2/protocol/http/protocol.go
Lines 199 to 203 in a9224ad
Then when writing the event to the request,
httpRequestWriter.SetAttribute(Attribute, interface{})
appends the attribute to the request.Header:sdk-go/v2/protocol/http/write_request.go
Line 121 in a9224ad
Sending multiple events with the same underlying
ctx
is causing these headers to be duplicated on each invocation.Can we change
newRequest
to clone the headers? i.e.The text was updated successfully, but these errors were encountered: