aws / aws-xray-sdk-go

AWS X-Ray SDK for the Go programming language.
Apache License 2.0
275 stars 118 forks source link

Missing AddUser method for Segment #355

Open pm98zz-c opened 2 years ago

pm98zz-c commented 2 years ago

According to https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-go-segment.html#xray-sdk-go-segment-userid one should be able to add an userID to the trace. The doc states to use "segment.AddUser()", which does not seem to exist. The example just below simply directly set the segment.User string (which I suspect would actually need to be wrapped in a mutex lock).

Am I missing something obvious? Happy to submit a PR for the AddUser method, should be straightforward, but I prefer to check it's just not me overlooking something.

Additionally, the doc for annotations and metadata is also slightly wrong, in that it misses the first context argument (for context.AddMetadata and AddAnnotation).

bhautikpip commented 2 years ago

Yeah I couldn't find the segment.AddUser() API in the doc. Can you send me the link? Also, I think right now SDK still lets you set the User by retrieving the current segment from context. Are you suggesting to add a method to the SDK which sets the user and also should be thread-safe? If yes, I think it would be a good idea and happy to review PR! Can you also clarify which method are you pointing from SDK which is not align with documentation? Is it AddAnnotation method?