Skip to content

Set send_to_logfire to False when running under Pytest - #154

Merged
Kludex merged 2 commits into
mainfrom
dont-send-to-logfire-under-pytest
May 8, 2024
Merged

Kludex merged 2 commits into
mainfrom
dont-send-to-logfire-under-pytest

Conversation

@Kludex

@Kludex Kludex commented May 8, 2024

Copy link
Copy Markdown
Member

No description provided.

Comment on lines +50 to +61
@dataclass
class _DefaultCallback:
"""A default value that is computed at runtime.

A good example is when we want to check if we are running under pytest and set a default value based on that.
"""

callback: Callable[[], Any]


_send_to_logfire_default = _DefaultCallback(lambda: 'PYTEST_CURRENT_TEST' not in os.environ)
"""When running under pytest, don't send spans to Logfire by default."""

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

If this can be avoided, suggestions are welcome.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 8, 2024 •

Copy link
Copy Markdown

Deploying logfire-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 53c1278
Status: ✅  Deploy successful!
Preview URL: https://d7a2e0d9.logfire-docs.pages.dev
Branch Preview URL: https://dont-send-to-logfire-under-p.logfire-docs.pages.dev

View logs

@Kludex
Kludex enabled auto-merge (squash) May 8, 2024 10:59
@Kludex
Kludex merged commit cd9b659 into main May 8, 2024
@Kludex
Kludex deleted the dont-send-to-logfire-under-pytest branch May 8, 2024 11:01
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.

2 participants