Skip to content

feat: trace httpapi.{Read,Write}#4134

Merged
coadler merged 8 commits into
mainfrom
colin/json-tracing
Sep 21, 2022
Merged

feat: trace httpapi.{Read,Write}#4134
coadler merged 8 commits into
mainfrom
colin/json-tracing

Conversation

@coadler
Copy link
Copy Markdown
Contributor

@coadler coadler commented Sep 20, 2022

No description provided.

@coadler coadler self-assigned this Sep 20, 2022
@coadler coadler marked this pull request as ready for review September 20, 2022 17:47
@coadler coadler requested a review from kylecarbs September 20, 2022 17:47
Comment thread coderd/httpapi/httpapi.go
Comment on lines +110 to +111
ctx, span := tracing.StartSpan(ctx)
defer span.End()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we care about tracing this? It seems like this function is so simple, that it's weird to trace.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For httpapi.Read I would agree, but that was mostly to make them consistent. I thought it would be weird if one was traced and the other wasn't.

httpapi.Write is a lot more useful. JSON marshaling can sometimes take a non-insignificant amount of time, and this could help us catch outliers. Additionally, we can enrich span data a bit more since we have access to the actual interface{} we're marshalling, such as the number of elements in an array, which could help us spot routes that need to be paginated.

Copy link
Copy Markdown
Member

@kylecarbs kylecarbs Sep 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Toss this gorgeous comment next to httpapi.Write and I'll approve!

@coadler coadler merged commit 5de6f86 into main Sep 21, 2022
@coadler coadler deleted the colin/json-tracing branch September 21, 2022 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants