Skip to content
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

Can't see logs due to 'flush' issue #139

Closed
FelipeLahti opened this issue Sep 21, 2024 · 4 comments
Closed

Can't see logs due to 'flush' issue #139

FelipeLahti opened this issue Sep 21, 2024 · 4 comments

Comments

@FelipeLahti
Copy link

FelipeLahti commented Sep 21, 2024

Issue

Logs aren't propagating to axiom.

How to reproduce:

  • Log ~900 in less than 1 sec
  • Don't send anything else after this
  • Logs won't show in axiom as it's not getting flushed

Possible solution:

  • Flush periodically after x seconds even if the buffer isn't full or the last log was less than 1 s ago.
@FelipeLahti
Copy link
Author

Workaround: Spin up a thread to flush it every 30s. It could be add as built in into the lib if that makes sense.

        client = axiom_py.Client()
        handler = AxiomHandler(client, "my-dataset")

        def flush_handler_periodically():
            while True:
                handler.flush()
                time.sleep(30)

        thread = threading.Thread(target=flush_handler_periodically)
        thread.daemon = True
        thread.start()

        logging.getLogger().addHandler(handler)

@bahlo
Copy link
Member

bahlo commented Sep 22, 2024

Hi @FelipeLahti, thanks! You’re right, we should fix this. Another option would be using a threading.Timer to flush logs at least every second—similarly to how we handle this situation in axiom-js. Will keep his open until that‘s implemented 😌

@bahlo
Copy link
Member

bahlo commented Sep 30, 2024

Fixed in #140, will be in the next release

@bahlo bahlo closed this as completed Sep 30, 2024
@subham1099
Copy link
Contributor

@bahlo Could we implement the same for structlog? Should I raise a PR with a similar change to the structlog module?

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

No branches or pull requests

3 participants