-
Notifications
You must be signed in to change notification settings - Fork 699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ClientTrace struct for JS tracing #911
Conversation
If this is ok then will make the change for the natscli, it is a small change: https://github.com/nats-io/natscli/blob/6accd61459f59cbb26e6e14cc24b3606ffc7b426/cli/util.go#L448-L454 |
// ClientTrace can be used to trace API interactions for the JetStream Context. | ||
type ClientTrace struct { | ||
RequestSent func(subj string, payload []byte, hdr Header) | ||
ResponseReceived func(subj string, payload []byte, hdr Header) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could expand this to make them more granular for example, to only trace consumer lookups or for when adding retries make it possible to log an event for when there is a backoff, etc...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the approach, but of course this is again breaking changes (we had just one in previous PR for the KV purge options). I guess we mentioned that the JS/KV API may change, but hopefully we start to be more stable soon.
04aceb5
to
e422da2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
e422da2
to
f658a93
Compare
This one is ready to merge, follow up PR with the natscli changes here: https://github.com/nats-io/natscli/tree/with-client-trace |
Add ClientTrace struct for JS tracing Signed-off-by: Waldemar Quevedo <wally@nats.io>
This is an alternative implementation to enable tracing of requests in the JetStream context #849, using the same idiom of a struct with callbacks as the
httptrace
package (https://golang.google.cn/pkg/net/http/httptrace/#ClientTrace).Signed-off-by: Waldemar Quevedo wally@synadia.com