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

Check token in separate thread #274

Merged
merged 3 commits into from
Jun 21, 2024
Merged

Check token in separate thread #274

merged 3 commits into from
Jun 21, 2024

Conversation

alexmojaki
Copy link
Contributor

Closes #247

@alexmojaki alexmojaki requested a review from Kludex June 21, 2024 13:44
Copy link

codecov bot commented Jun 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

Copy link
Member

@adriangb adriangb left a comment

Choose a reason for hiding this comment

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

Generally looks good to me. Seems like we never join the thread right? Do have a lock on configure()? What happens if I do;

configure()
while True:
  info()

?

Copy link

cloudflare-pages bot commented Jun 21, 2024

Deploying logfire-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: b659ea0
Status: ✅  Deploy successful!
Preview URL: https://2460385f.logfire-docs.pages.dev
Branch Preview URL: https://alex-check-token-thread.logfire-docs.pages.dev

View logs

@alexmojaki
Copy link
Contributor Author

from logfire import configure, info

configure(token='...')
info('hi')
14:01:46.559 hi
/Users/alex/work/logfire/logfire/_internal/config.py:849: UserWarning: Invalid Logfire token.
  warnings.warn('Invalid Logfire token.')
Failed to export batch code: 401, reason: {"detail":"Invalid token"}
/Users/alex/work/logfire/logfire/_internal/exporters/file.py:58: WritingFallbackWarning: Failed to export spans, writing to fallback file: /Users/alex/Library/Application Support/JetBrains/PyCharm2024.1/scratches/.logfire/logfire_spans.bin
  warnings.warn(
Failed to export batch code: 401, reason: {"detail":"Invalid token"}

@adriangb
Copy link
Member

I mean what if it's a valid token. Does that info() call (1) warn if configure() hasn't actually finished, (2) wait for configure() to finish or (3) kick off another call to configure()?

@alexmojaki
Copy link
Contributor Author

The code inside check_token does nothing critical, it just prints the dashboard URL if the token is valid or warns (previously errored) if not. We already have the token and can start using it immediately to export without checking it.

@alexmojaki alexmojaki enabled auto-merge (squash) June 21, 2024 14:34
@alexmojaki alexmojaki merged commit 0829bee into main Jun 21, 2024
11 checks passed
@alexmojaki alexmojaki deleted the alex/check-token-thread branch June 21, 2024 14:36
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.

logfire.configure() makes a blocking HTTP request
2 participants