-
Notifications
You must be signed in to change notification settings - Fork 28
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
'<' not supported between instances of 'str' and 'datetime.datetime' #159
Comments
Hey,
I tried to reproduce this with this example: import logging
import os
import sentry_sdk
import structlog
from structlog_sentry import SentryProcessor
def main():
sentry_sdk.init(
dsn=os.environ.get("SENTRY_DSN"),
traces_sample_rate=1.0,
debug=True,
)
structlog.configure(
processors=[
structlog.processors.TimeStamper(fmt="iso"),
structlog.stdlib.add_logger_name, # optional, must be placed before SentryProcessor()
structlog.stdlib.add_log_level, # required before SentryProcessor()
SentryProcessor(event_level=logging.ERROR),
],
logger_factory=structlog.stdlib.LoggerFactory(),
wrapper_class=structlog.stdlib.BoundLogger,
)
log = structlog.get_logger()
try:
1/0
except ZeroDivisionError:
log.error("zero division")
if __name__ == "__main__":
main() And I get a Can anyone show me what I am doing wrong? |
@antonpirker Try adding |
@dbowring thanks for the help, that did the trick! |
I have now this example app: But I do not get the |
@antonpirker , super appreciated you help create the example. It seems like the I am able to recreate the error by just reraise the exception:
|
Hey @dephiros ! Now I can reproduce! Thanks for your help! The errors happens because one breadcrumb has a datetime and the other one a string. But I think I fix this in the SDK to always parse the timestamp if it is a string. |
import logging
import os
import sentry_sdk
import structlog
from structlog_sentry import SentryProcessor
import datetime
def main():
sentry_sdk.init(
dsn="http://abc@localhost/1",
traces_sample_rate=1.0,
debug=True,
environment='debug'
)
structlog.configure(
processors=[
#structlog.processors.TimeStamper(fmt="iso", key='date'),
structlog.stdlib.add_logger_name,
structlog.stdlib.add_log_level,
SentryProcessor(event_level=logging.ERROR),
structlog.stdlib.ProcessorFormatter.wrap_for_formatter,
],
logger_factory=structlog.stdlib.LoggerFactory(),
wrapper_class=structlog.stdlib.BoundLogger,
)
log = structlog.get_logger()
try:
1/0
except ZeroDivisionError:
log.error("zero division", timestamp=datetime.datetime.now())
log.error("zero division", timestamp=datetime.datetime.now().isoformat())
if __name__ == "__main__":
main() |
Sentry SDK: 2.12.0
structlog-sentry: 2.1.0
Run into this error when trying to upgrade
sentry-sdk
andstructlog-sentry
'<' not supported between instances of 'str' and 'datetime.datetime'
I manage to track it down to getsentry/sentry-python#3307 which is included in
sentry-sdk
2.11 release.datetime
instead of string?structlog.processors.TimeStamper(fmt="iso"),
structlog
to Sentry breadcrumb which could be string. Maybe we can converttimestamp
first todatetime
?Appreciate your help
The text was updated successfully, but these errors were encountered: