#Sentry logs are not using proper format like loguru
16 messages · Page 1 of 1 (latest)
logger.add(
sys.stderr,
level="DEBUG",
format="<cyan>[{extra[conversation_id]}]</cyan> | <yellow>[{extra[elapsed_seconds]}]</yellow> | <level>{level: <8}</level> | <level>{message}</level>{exception}",
)
I want to pass extra information in sentry logs so i can query and filter in dashboard but i dont see and i can achieve this in docs
In every log i want to pass conversation id and elapsed time which is not possible by using before_send_log because its in global scope and i want to set conversation_id on per session basis
Following this https://docs.sentry.io/platforms/python/logs/
Structured logs allow you to send, view and query logs sent from your applications within Sentry.
That feels like something we need to improve in the sdk. @faint zephyr could you open a GH issue in github.com/getsentry/sentry-python ? The maintainers can help you there
I was hoping you could use logger.bind and set extras that the integration would forward as attributes, but reading the code we don't do that atm https://github.com/getsentry/sentry-python/blob/94a92d8b6475905a247472ced68911320a4126c4/sentry_sdk/integrations/loguru.py#L67
The official Python SDK for Sentry.io. Contribute to getsentry/sentry-python development by creating an account on GitHub.
if you use the stdlib logger you can add extra fields as extra as per https://docs.sentry.io/platforms/python/logs/#extra-fields-as-searchable-attributes
Structured logs allow you to send, view and query logs sent from your applications within Sentry.
unfortunately for now no workarounds with loguru, but we should totally make this better! I'll help raise the priority
Using normal logger would not be possible as internally we are using loguru everywhere
any other workaround i just want to be able to push the convo id alteast
you could vendor in the integration yourself and add the functionality, but beyond that we need to make sdk changes for this
Hey @faint zephyr i think this issue is related to the issue of yours: https://github.com/getsentry/sentry-python/issues/4475 Can you confirm this is the same issue you are describing here?
(cc @jaunty jasper )
@jade cedar https://github.com/getsentry/sentry-python/issues/4475#issuecomment-3279785209
Posted my comment here
PS: I think its a related issue but not the exact same thing