Skip to content

Commit

Permalink
refactor jsonl connector
Browse files Browse the repository at this point in the history
  • Loading branch information
ekneg54 committed Aug 12, 2024
1 parent 7afd24e commit 78d4476
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/exampledata/config/http_pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ metrics:
input:
httpinput:
type: http_input
message_backlog_size: 150
message_backlog_size: 15000000
collect_meta: True
metafield_name: "@metadata"
uvicorn_config:
Expand Down
8 changes: 2 additions & 6 deletions logprep/connector/http/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,9 @@ async def __call__(self, req, resp, **kwargs): # pylint: disable=arguments-diff
"""jsonl endpoint method"""
self.collect_metrics()
data = await self.get_data(req)
data = data.decode("utf8")
event = kwargs.get("metadata", {})
metadata = kwargs.get("metadata", {})
stripped_lines = map(str.strip, data.splitlines())
events = (self._decoder.decode(line) for line in stripped_lines if line)
for event in events:
self.messages.put({**event, **metadata}, block=False)
for event in self._decoder.decode_lines(data):
self.messages.put(event | metadata, block=False)


class PlaintextHttpEndpoint(HttpEndpoint):
Expand Down

0 comments on commit 78d4476

Please sign in to comment.