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

Add logfire.exception() to logfire-api #358

Merged
merged 3 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions logfire-api/logfire_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def warn(self, *args, **kwargs) -> None: ...

def error(self, *args, **kwargs) -> None: ...

def exception(self, *args, **kwargs) -> None: ...

def fatal(self, *args, **kwargs) -> None: ...

def with_tags(self, *args, **kwargs) -> Logfire:
Expand Down Expand Up @@ -132,6 +134,7 @@ def shutdown(self, *args, **kwargs) -> None: ...
info = DEFAULT_LOGFIRE_INSTANCE.info
warn = DEFAULT_LOGFIRE_INSTANCE.warn
error = DEFAULT_LOGFIRE_INSTANCE.error
exception = DEFAULT_LOGFIRE_INSTANCE.exception
fatal = DEFAULT_LOGFIRE_INSTANCE.fatal
with_tags = DEFAULT_LOGFIRE_INSTANCE.with_tags
with_settings = DEFAULT_LOGFIRE_INSTANCE.with_settings
Expand Down
60 changes: 3 additions & 57 deletions logfire-api/logfire_api/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
from ._internal.auto_trace import AutoTraceModule as AutoTraceModule
from ._internal.auto_trace.rewrite_ast import no_auto_trace as no_auto_trace
from ._internal.config import (
ConsoleOptions as ConsoleOptions,
METRICS_PREFERRED_TEMPORALITY as METRICS_PREFERRED_TEMPORALITY,
PydanticPlugin as PydanticPlugin,
configure as configure,
)
from ._internal.config import ConsoleOptions as ConsoleOptions, METRICS_PREFERRED_TEMPORALITY as METRICS_PREFERRED_TEMPORALITY, PydanticPlugin as PydanticPlugin, configure as configure
from ._internal.constants import LevelName as LevelName
from ._internal.exporters.file import load_file as load_spans_from_file
from ._internal.exporters.tail_sampling import TailSamplingOptions as TailSamplingOptions
Expand All @@ -16,57 +11,7 @@ from .integrations.logging import LogfireLoggingHandler as LogfireLoggingHandler
from .integrations.structlog import LogfireProcessor as StructlogProcessor
from .version import VERSION as VERSION

__all__ = [
'Logfire',
'LogfireSpan',
'LevelName',
'ConsoleOptions',
'PydanticPlugin',
'configure',
'span',
'instrument',
'log',
'trace',
'debug',
'notice',
'info',
'warn',
'error',
'fatal',
'force_flush',
'log_slow_async_callbacks',
'install_auto_tracing',
'instrument_fastapi',
'instrument_openai',
'instrument_anthropic',
'instrument_asyncpg',
'instrument_httpx',
'instrument_celery',
'instrument_requests',
'instrument_psycopg',
'instrument_django',
'instrument_flask',
'instrument_starlette',
'instrument_aiohttp_client',
'instrument_sqlalchemy',
'instrument_redis',
'instrument_pymongo',
'instrument_mysql',
'AutoTraceModule',
'with_tags',
'with_settings',
'shutdown',
'load_spans_from_file',
'no_auto_trace',
'METRICS_PREFERRED_TEMPORALITY',
'ScrubMatch',
'ScrubbingOptions',
'VERSION',
'suppress_instrumentation',
'StructlogProcessor',
'LogfireLoggingHandler',
'TailSamplingOptions',
]
__all__ = ['Logfire', 'LogfireSpan', 'LevelName', 'ConsoleOptions', 'PydanticPlugin', 'configure', 'span', 'instrument', 'log', 'trace', 'debug', 'notice', 'info', 'warn', 'error', 'exception', 'fatal', 'force_flush', 'log_slow_async_callbacks', 'install_auto_tracing', 'instrument_fastapi', 'instrument_openai', 'instrument_anthropic', 'instrument_asyncpg', 'instrument_httpx', 'instrument_celery', 'instrument_requests', 'instrument_psycopg', 'instrument_django', 'instrument_flask', 'instrument_starlette', 'instrument_aiohttp_client', 'instrument_sqlalchemy', 'instrument_redis', 'instrument_pymongo', 'instrument_mysql', 'AutoTraceModule', 'with_tags', 'with_settings', 'shutdown', 'load_spans_from_file', 'no_auto_trace', 'METRICS_PREFERRED_TEMPORALITY', 'ScrubMatch', 'ScrubbingOptions', 'VERSION', 'suppress_instrumentation', 'StructlogProcessor', 'LogfireLoggingHandler', 'TailSamplingOptions']

DEFAULT_LOGFIRE_INSTANCE = Logfire()
span = DEFAULT_LOGFIRE_INSTANCE.span
Expand Down Expand Up @@ -101,4 +46,5 @@ notice = DEFAULT_LOGFIRE_INSTANCE.notice
warn = DEFAULT_LOGFIRE_INSTANCE.warn
error = DEFAULT_LOGFIRE_INSTANCE.error
fatal = DEFAULT_LOGFIRE_INSTANCE.fatal
exception = DEFAULT_LOGFIRE_INSTANCE.exception
__version__ = VERSION
2 changes: 0 additions & 2 deletions logfire-api/logfire_api/_internal/constants.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ LOGGING_TO_OTEL_LEVEL_NUMBERS: Incomplete
ATTRIBUTES_LOG_LEVEL_NAME_KEY: Incomplete
ATTRIBUTES_LOG_LEVEL_NUM_KEY: Incomplete


def log_level_attributes(level: LevelName | int) -> dict[str, otel_types.AttributeValue]: ...


SpanTypeType: Incomplete
ATTRIBUTES_SPAN_TYPE_KEY: Incomplete
ATTRIBUTES_PENDING_SPAN_REAL_PARENT_KEY: Incomplete
Expand Down
1 change: 1 addition & 0 deletions logfire/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def loguru_handler() -> dict[str, Any]:
'info',
'warn',
'error',
'exception',
'fatal',
'force_flush',
'log_slow_async_callbacks',
Expand Down
2 changes: 1 addition & 1 deletion tests/test_logfire_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_runtime(logfire_api_factory: Callable[[], ModuleType], module_name: str
logfire_api.log('info', 'test log')
logfire__all__.remove('log')

for log_method in ['trace', 'debug', 'info', 'notice', 'warn', 'error', 'fatal']:
for log_method in ['trace', 'debug', 'info', 'notice', 'warn', 'error', 'exception', 'fatal']:
assert hasattr(logfire_api, log_method)
getattr(logfire_api, log_method)('test log')
logfire__all__.remove(log_method)
Expand Down