Skip to content

Commit

Permalink
Simplify entity streaming metrics code
Browse files Browse the repository at this point in the history
There’s no need to do batched metric increments until this becomes a performance bottleneck.
  • Loading branch information
tillprochaska committed Nov 23, 2023
1 parent 2e7f61d commit 7aabc4f
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions aleph/views/stream_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,8 @@ def entities(collection_id=None):
STREAMS.inc()

def generator(entities):
count = 0

for entity in entities:
count += 1

if count == 1000:
STREAMED_ENTITIES.inc(count)
count = 0

STREAMED_ENTITIES.inc()
yield entity

STREAMED_ENTITIES.inc(count)

return stream_ijson(generator(entities))

0 comments on commit 7aabc4f

Please sign in to comment.