-
Notifications
You must be signed in to change notification settings - Fork 1
Honeycomb doesn't correctly instrument the new /api/searchLocations streaming mechanism #390
Comments
Relevant code: Lines 64 to 94 in 885484e
|
Tweeted about this in the hope that someone has a suggestion: https://twitter.com/simonw/status/1385040013369298944 |
I also asked in the Honeycomb slack. |
Here's the relevant beeline middleware - it looks like it doesn't take the weirdness of streaming responses into account: https://github.com/honeycombio/beeline-python/blob/4bbbb9ae1279cab0a5a33c7533a783436e4d3916/beeline/middleware/django/__init__.py#L1 |
Maybe this could be as easy as decorating that |
That did at least give me a trace: https://ui.honeycomb.io/vaccinateca/datasets/vial-staging/result/cdvkXnwpYHa/trace/8VayW1fCoV2 It doesn't include the SQL queries that ran as part of the operation though, and it appears to be independent of the overall span for that HTTP request, which I think is this one: https://ui.honeycomb.io/vaccinateca/datasets/vial-staging/result/xnc9HP43C7g/trace/oy5gNzZYBaH |
def traced(self, name, trace_id=None, parent_id=None):
return traced_impl(tracer_fn=self.tracer, name=name, trace_id=trace_id, parent_id=parent_id) Maybe I can pass in an explicit |
With that fix: https://ui.honeycomb.io/vaccinateca/datasets/vial-staging/result/d9D96M3qpnM And a trace: https://ui.honeycomb.io/vaccinateca/datasets/vial-staging/result/d9D96M3qpnM/trace/qF9xrEWTGPs The trace still doesn't capture the database queries that were executed though. |
I don't think those database query spans are being recorded in Honeycomb at all. Here's a snapshot from when I loaded one of those endpoints: It has the queries for user and session, but there's nothing else there - which suggests that the queries executed as part of the |
class HoneyDBWrapper(object):
def __call__(self, execute, sql, params, many, context):
# if beeline has not been initialised, just execute query
if not beeline.get_beeline():
return execute(sql, params, many, context) My hunch is that |
Django docs have some clues here: https://docs.djangoproject.com/en/3.2/topics/http/middleware/#dealing-with-streaming-responses We would need to roll our own version of the beeline Django middleware, and maybe contribute that back upstream later on. |
I think the trick is to implement an alternative |
Fun bug this one. The new
/api/searchLocations?all=1
parameter added in #367 uses a DjangoStreamingHttpResponse
to efficiently paginate through all matching records and return all of them. But... in Honeycomb a trace for that looks like this:https://ui.honeycomb.io/vaccinateca/datasets/vial-staging/result/zMuwmKiKC8a/trace/7BpC1kJnKFN
This should have 20 SQL queries inside the
search_locations
section, since we are returning 10,000 results and the code works by keyset-paginating 500 at a time.My hunch is that this is because Honeycomb only instruments the Django view - but those SQL queries aren't executed during the view function, they are executed outside of it when the wrapping Django code starts iterating through the streaming response.
The text was updated successfully, but these errors were encountered: