|
| 1 | +from sentry_sdk import capture_exception |
| 2 | +from sentry_sdk.integrations.gnu_backtrace import GnuBacktraceIntegration |
| 3 | + |
| 4 | +EXC_VALUE = r""" |
| 5 | +DB::Exception: Cannot parse datetime. Stack trace: |
| 6 | +
|
| 7 | +0. clickhouse-server(StackTrace::StackTrace()+0x16) [0x99d31a6] |
| 8 | +1. clickhouse-server(DB::Exception::Exception(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)+0x22) [0x3089bb2] |
| 9 | +2. clickhouse-server(void DB::readDateTimeTextFallback<void>(long&, DB::ReadBuffer&, DateLUTImpl const&)+0x318) [0x99ffed8] |
| 10 | +3. clickhouse-server(DB::FunctionComparison<DB::NotEqualsOp, DB::NameNotEquals>::executeDateOrDateTimeOrEnumOrUUIDWithConstString(DB::Block&, unsigned long, DB::IColumn const*, DB::IColumn const*, std::shared_ptr<DB::IDataType const> const&, std::shared_ptr<DB::IDataType const> const&, bool, unsigned long)+0xbb3) [0x411dee3] |
| 11 | +4. clickhouse-server(DB::FunctionComparison<DB::NotEqualsOp, DB::NameNotEquals>::executeImpl(DB::Block&, std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, unsigned long)+0x576) [0x41ab006] |
| 12 | +5. clickhouse-server(DB::PreparedFunctionImpl::execute(DB::Block&, std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, unsigned long)+0x3e2) [0x7933492] |
| 13 | +6. clickhouse-server(DB::ExpressionAction::execute(DB::Block&, std::unordered_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned long, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, unsigned long> > >&) const+0x61a) [0x7ae093a] |
| 14 | +7. clickhouse-server(DB::ExpressionActions::execute(DB::Block&) const+0xe6) [0x7ae1e06] |
| 15 | +8. clickhouse-server(DB::FilterBlockInputStream::FilterBlockInputStream(std::shared_ptr<DB::IBlockInputStream> const&, std::shared_ptr<DB::ExpressionActions> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)+0x711) [0x79970d1] |
| 16 | +9. clickhouse-server() [0x75bd5a3] |
| 17 | +10. clickhouse-server(DB::InterpreterSelectQuery::executeImpl(DB::InterpreterSelectQuery::Pipeline&, std::shared_ptr<DB::IBlockInputStream> const&, bool)+0x11af) [0x75c68ff] |
| 18 | +11. clickhouse-server(DB::InterpreterSelectQuery::InterpreterSelectQuery(std::shared_ptr<DB::IAST> const&, DB::Context const&, std::shared_ptr<DB::IBlockInputStream> const&, std::shared_ptr<DB::IStorage> const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, DB::QueryProcessingStage::Enum, unsigned long, bool)+0x5e6) [0x75c7516] |
| 19 | +12. clickhouse-server(DB::InterpreterSelectQuery::InterpreterSelectQuery(std::shared_ptr<DB::IAST> const&, DB::Context const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, DB::QueryProcessingStage::Enum, unsigned long, bool)+0x56) [0x75c8276] |
| 20 | +13. clickhouse-server(DB::InterpreterSelectWithUnionQuery::InterpreterSelectWithUnionQuery(std::shared_ptr<DB::IAST> const&, DB::Context const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, DB::QueryProcessingStage::Enum, unsigned long, bool)+0x7e7) [0x75d4067] |
| 21 | +14. clickhouse-server(DB::InterpreterFactory::get(std::shared_ptr<DB::IAST>&, DB::Context&, DB::QueryProcessingStage::Enum)+0x3a8) [0x75b0298] |
| 22 | +15. clickhouse-server() [0x7664c79] |
| 23 | +16. clickhouse-server(DB::executeQuery(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, DB::Context&, bool, DB::QueryProcessingStage::Enum)+0x8a) [0x76669fa] |
| 24 | +17. clickhouse-server(DB::TCPHandler::runImpl()+0x4b9) [0x30973c9] |
| 25 | +18. clickhouse-server(DB::TCPHandler::run()+0x2b) [0x30985ab] |
| 26 | +19. clickhouse-server(Poco::Net::TCPServerConnection::start()+0xf) [0x9b53e4f] |
| 27 | +20. clickhouse-server(Poco::Net::TCPServerDispatcher::run()+0x16a) [0x9b5422a] |
| 28 | +21. clickhouse-server(Poco::PooledThread::run()+0x77) [0x9c70f37] |
| 29 | +22. clickhouse-server(Poco::ThreadImpl::runnableEntry(void*)+0x38) [0x9c6caa8] |
| 30 | +23. clickhouse-server() [0xa3c68cf] |
| 31 | +24. /lib/x86_64-linux-gnu/libpthread.so.0(+0x8184) [0x7fe839d2d184] |
| 32 | +25. /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7fe83934803d] |
| 33 | +""" |
| 34 | + |
| 35 | + |
| 36 | +def test_basic(sentry_init, capture_events): |
| 37 | + sentry_init(integrations=[GnuBacktraceIntegration()]) |
| 38 | + events = capture_events() |
| 39 | + |
| 40 | + try: |
| 41 | + raise ValueError(EXC_VALUE) |
| 42 | + except ValueError: |
| 43 | + capture_exception() |
| 44 | + |
| 45 | + event, = events |
| 46 | + import pdb |
| 47 | + |
| 48 | + pdb.set_trace() |
| 49 | + exception, = event["exception"]["values"] |
| 50 | + |
| 51 | + assert exception["value"] == ( |
| 52 | + "\n" |
| 53 | + "DB::Exception: Cannot parse datetime. Stack trace:\n" |
| 54 | + "\n" |
| 55 | + "<stacktrace parsed and removed by GnuBacktraceIntegration>" |
| 56 | + ) |
| 57 | + |
| 58 | + assert exception["stacktrace"]["frames"][1:] == [ |
| 59 | + { |
| 60 | + "function": "clone", |
| 61 | + "in_app": True, |
| 62 | + "package": "/lib/x86_64-linux-gnu/libc.so.6", |
| 63 | + "platform": "native", |
| 64 | + }, |
| 65 | + { |
| 66 | + "in_app": True, |
| 67 | + "package": "/lib/x86_64-linux-gnu/libpthread.so.0", |
| 68 | + "platform": "native", |
| 69 | + }, |
| 70 | + {"in_app": True, "package": "clickhouse-server", "platform": "native"}, |
| 71 | + { |
| 72 | + "function": "Poco::ThreadImpl::runnableEntry", |
| 73 | + "in_app": True, |
| 74 | + "package": "clickhouse-server", |
| 75 | + "platform": "native", |
| 76 | + }, |
| 77 | + { |
| 78 | + "function": "Poco::PooledThread::run", |
| 79 | + "in_app": True, |
| 80 | + "package": "clickhouse-server", |
| 81 | + "platform": "native", |
| 82 | + }, |
| 83 | + { |
| 84 | + "function": "Poco::Net::TCPServerDispatcher::run", |
| 85 | + "in_app": True, |
| 86 | + "package": "clickhouse-server", |
| 87 | + "platform": "native", |
| 88 | + }, |
| 89 | + { |
| 90 | + "function": "Poco::Net::TCPServerConnection::start", |
| 91 | + "in_app": True, |
| 92 | + "package": "clickhouse-server", |
| 93 | + "platform": "native", |
| 94 | + }, |
| 95 | + { |
| 96 | + "function": "DB::TCPHandler::run", |
| 97 | + "in_app": True, |
| 98 | + "package": "clickhouse-server", |
| 99 | + "platform": "native", |
| 100 | + }, |
| 101 | + { |
| 102 | + "function": "DB::TCPHandler::runImpl", |
| 103 | + "in_app": True, |
| 104 | + "package": "clickhouse-server", |
| 105 | + "platform": "native", |
| 106 | + }, |
| 107 | + { |
| 108 | + "function": "DB::executeQuery", |
| 109 | + "in_app": True, |
| 110 | + "package": "clickhouse-server", |
| 111 | + "platform": "native", |
| 112 | + }, |
| 113 | + {"in_app": True, "package": "clickhouse-server", "platform": "native"}, |
| 114 | + { |
| 115 | + "function": "DB::InterpreterFactory::get", |
| 116 | + "in_app": True, |
| 117 | + "package": "clickhouse-server", |
| 118 | + "platform": "native", |
| 119 | + }, |
| 120 | + { |
| 121 | + "function": "DB::InterpreterSelectWithUnionQuery::InterpreterSelectWithUnionQuery", |
| 122 | + "in_app": True, |
| 123 | + "package": "clickhouse-server", |
| 124 | + "platform": "native", |
| 125 | + }, |
| 126 | + { |
| 127 | + "function": "DB::InterpreterSelectQuery::InterpreterSelectQuery", |
| 128 | + "in_app": True, |
| 129 | + "package": "clickhouse-server", |
| 130 | + "platform": "native", |
| 131 | + }, |
| 132 | + { |
| 133 | + "function": "DB::InterpreterSelectQuery::InterpreterSelectQuery", |
| 134 | + "in_app": True, |
| 135 | + "package": "clickhouse-server", |
| 136 | + "platform": "native", |
| 137 | + }, |
| 138 | + { |
| 139 | + "function": "DB::InterpreterSelectQuery::executeImpl", |
| 140 | + "in_app": True, |
| 141 | + "package": "clickhouse-server", |
| 142 | + "platform": "native", |
| 143 | + }, |
| 144 | + {"in_app": True, "package": "clickhouse-server", "platform": "native"}, |
| 145 | + { |
| 146 | + "function": "DB::FilterBlockInputStream::FilterBlockInputStream", |
| 147 | + "in_app": True, |
| 148 | + "package": "clickhouse-server", |
| 149 | + "platform": "native", |
| 150 | + }, |
| 151 | + { |
| 152 | + "function": "DB::ExpressionActions::execute", |
| 153 | + "in_app": True, |
| 154 | + "package": "clickhouse-server", |
| 155 | + "platform": "native", |
| 156 | + }, |
| 157 | + { |
| 158 | + "function": "DB::ExpressionAction::execute", |
| 159 | + "in_app": True, |
| 160 | + "package": "clickhouse-server", |
| 161 | + "platform": "native", |
| 162 | + }, |
| 163 | + { |
| 164 | + "function": "DB::PreparedFunctionImpl::execute", |
| 165 | + "in_app": True, |
| 166 | + "package": "clickhouse-server", |
| 167 | + "platform": "native", |
| 168 | + }, |
| 169 | + { |
| 170 | + "function": "DB::NameNotEquals>::executeImpl", |
| 171 | + "in_app": True, |
| 172 | + "package": "clickhouse-server", |
| 173 | + "platform": "native", |
| 174 | + }, |
| 175 | + { |
| 176 | + "function": "DB::NameNotEquals>::executeDateOrDateTimeOrEnumOrUUIDWithConstString", |
| 177 | + "in_app": True, |
| 178 | + "package": "clickhouse-server", |
| 179 | + "platform": "native", |
| 180 | + }, |
| 181 | + { |
| 182 | + "function": "DB::readDateTimeTextFallback<void>", |
| 183 | + "in_app": True, |
| 184 | + "package": "clickhouse-server", |
| 185 | + "platform": "native", |
| 186 | + }, |
| 187 | + { |
| 188 | + "function": "DB::Exception::Exception", |
| 189 | + "in_app": True, |
| 190 | + "package": "clickhouse-server", |
| 191 | + "platform": "native", |
| 192 | + }, |
| 193 | + { |
| 194 | + "function": "StackTrace::StackTrace", |
| 195 | + "in_app": True, |
| 196 | + "package": "clickhouse-server", |
| 197 | + "platform": "native", |
| 198 | + }, |
| 199 | + ] |
0 commit comments