|
| 1 | +import pytest |
| 2 | + |
1 | 3 | from sentry_sdk import capture_exception
|
2 | 4 | from sentry_sdk.integrations.gnu_backtrace import GnuBacktraceIntegration
|
3 | 5 |
|
4 |
| -EXC_VALUE = r""" |
5 |
| -DB::Exception: Cannot parse datetime. Stack trace: |
6 |
| -
|
| 6 | +LINES = r""" |
7 | 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] |
| 8 | +1. clickhouse-server(DB::Exception::Exception(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)+0x22) [0x372c822] |
| 9 | +10. clickhouse-server(DB::ActionsVisitor::visit(std::shared_ptr<DB::IAST> const&)+0x1a12) [0x6ae45d2] |
17 | 10 | 10. clickhouse-server(DB::InterpreterSelectQuery::executeImpl(DB::InterpreterSelectQuery::Pipeline&, std::shared_ptr<DB::IBlockInputStream> const&, bool)+0x11af) [0x75c68ff]
|
| 11 | +10. clickhouse-server(ThreadPoolImpl<std::thread>::worker(std::_List_iterator<std::thread>)+0x1ab) [0x6f90c1b] |
| 12 | +11. clickhouse-server() [0xae06ddf] |
| 13 | +11. clickhouse-server(DB::ExpressionAnalyzer::getRootActions(std::shared_ptr<DB::IAST> const&, bool, std::shared_ptr<DB::ExpressionActions>&, bool)+0xdb) [0x6a0a63b] |
18 | 14 | 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]
|
| 15 | +12. /lib/x86_64-linux-gnu/libpthread.so.0(+0x8184) [0x7f3bbc568184] |
| 16 | +12. clickhouse-server(DB::ExpressionAnalyzer::getConstActions()+0xc9) [0x6a0b059] |
19 | 17 | 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]
|
| 18 | +13. /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7f3bbbb8303d] |
20 | 19 | 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]
|
| 20 | +13. clickhouse-server(DB::evaluateConstantExpression(std::shared_ptr<DB::IAST> const&, DB::Context const&)+0x3ed) [0x656bfdd] |
21 | 21 | 14. clickhouse-server(DB::InterpreterFactory::get(std::shared_ptr<DB::IAST>&, DB::Context&, DB::QueryProcessingStage::Enum)+0x3a8) [0x75b0298]
|
| 22 | +14. clickhouse-server(DB::makeExplicitSet(DB::ASTFunction const*, DB::Block const&, bool, DB::Context const&, DB::SizeLimits const&, std::unordered_map<DB::PreparedSetKey, std::shared_ptr<DB::Set>, DB::PreparedSetKey::Hash, std::equal_to<DB::PreparedSetKey>, std::allocator<std::pair<DB::PreparedSetKey const, std::shared_ptr<DB::Set> > > >&)+0x382) [0x6adf692] |
22 | 23 | 15. clickhouse-server() [0x7664c79]
|
| 24 | +15. clickhouse-server(DB::ActionsVisitor::makeSet(DB::ASTFunction const*, DB::Block const&)+0x2a7) [0x6ae2227] |
| 25 | +16. clickhouse-server(DB::ActionsVisitor::visit(std::shared_ptr<DB::IAST> const&)+0x1973) [0x6ae4533] |
23 | 26 | 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]
|
| 27 | +17. clickhouse-server(DB::ActionsVisitor::visit(std::shared_ptr<DB::IAST> const&)+0x1324) [0x6ae3ee4] |
24 | 28 | 17. clickhouse-server(DB::TCPHandler::runImpl()+0x4b9) [0x30973c9]
|
| 29 | +18. clickhouse-server(DB::ExpressionAnalyzer::getRootActions(std::shared_ptr<DB::IAST> const&, bool, std::shared_ptr<DB::ExpressionActions>&, bool)+0xdb) [0x6a0a63b] |
25 | 30 | 18. clickhouse-server(DB::TCPHandler::run()+0x2b) [0x30985ab]
|
| 31 | +19. clickhouse-server(DB::ExpressionAnalyzer::appendGroupBy(DB::ExpressionActionsChain&, bool)+0x100) [0x6a0b4f0] |
26 | 32 | 19. clickhouse-server(Poco::Net::TCPServerConnection::start()+0xf) [0x9b53e4f]
|
| 33 | +2. clickhouse-server(DB::FunctionTuple::getReturnTypeImpl(std::vector<std::shared_ptr<DB::IDataType const>, std::allocator<std::shared_ptr<DB::IDataType const> > > const&) const+0x122) [0x3a2a0f2] |
| 34 | +2. clickhouse-server(DB::readException(DB::Exception&, DB::ReadBuffer&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)+0x21f) [0x6fb253f] |
| 35 | +2. clickhouse-server(void DB::readDateTimeTextFallback<void>(long&, DB::ReadBuffer&, DateLUTImpl const&)+0x318) [0x99ffed8] |
| 36 | +20. clickhouse-server(DB::InterpreterSelectQuery::analyzeExpressions(DB::QueryProcessingStage::Enum, bool)+0x364) [0x6437fa4] |
27 | 37 | 20. clickhouse-server(Poco::Net::TCPServerDispatcher::run()+0x16a) [0x9b5422a]
|
| 38 | +21. clickhouse-server(DB::InterpreterSelectQuery::executeImpl(DB::InterpreterSelectQuery::Pipeline&, std::shared_ptr<DB::IBlockInputStream> const&, bool)+0x36d) [0x643c28d] |
28 | 39 | 21. clickhouse-server(Poco::PooledThread::run()+0x77) [0x9c70f37]
|
| 40 | +22. clickhouse-server(DB::InterpreterSelectQuery::executeWithMultipleStreams()+0x50) [0x643ecd0] |
29 | 41 | 22. clickhouse-server(Poco::ThreadImpl::runnableEntry(void*)+0x38) [0x9c6caa8]
|
30 | 42 | 23. clickhouse-server() [0xa3c68cf]
|
| 43 | +23. clickhouse-server(DB::InterpreterSelectWithUnionQuery::executeWithMultipleStreams()+0x6c) [0x644805c] |
31 | 44 | 24. /lib/x86_64-linux-gnu/libpthread.so.0(+0x8184) [0x7fe839d2d184]
|
| 45 | +24. clickhouse-server(DB::InterpreterSelectWithUnionQuery::execute()+0x38) [0x6448658] |
32 | 46 | 25. /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7fe83934803d]
|
| 47 | +25. clickhouse-server() [0x65744ef] |
| 48 | +26. clickhouse-server(DB::executeQuery(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, DB::Context&, bool, DB::QueryProcessingStage::Enum, bool)+0x81) [0x6576141] |
| 49 | +27. clickhouse-server(DB::TCPHandler::runImpl()+0x752) [0x3739f82] |
| 50 | +28. clickhouse-server(DB::TCPHandler::run()+0x2b) [0x373a5cb] |
| 51 | +29. clickhouse-server(Poco::Net::TCPServerConnection::start()+0xf) [0x708e63f] |
| 52 | +3. clickhouse-server(DB::Connection::receiveException()+0x81) [0x67d3ad1] |
| 53 | +3. clickhouse-server(DB::DefaultFunctionBuilder::getReturnTypeImpl(std::vector<DB::ColumnWithTypeAndName, std::allocator<DB::ColumnWithTypeAndName> > const&) const+0x223) [0x38ac3b3] |
| 54 | +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] |
| 55 | +30. clickhouse-server(Poco::Net::TCPServerDispatcher::run()+0xe9) [0x708ed79] |
| 56 | +31. clickhouse-server(Poco::PooledThread::run()+0x81) [0x7142011] |
| 57 | +4. clickhouse-server(DB::Connection::receivePacket()+0x767) [0x67d9cd7] |
| 58 | +4. clickhouse-server(DB::FunctionBuilderImpl::getReturnTypeWithoutLowCardinality(std::vector<DB::ColumnWithTypeAndName, std::allocator<DB::ColumnWithTypeAndName> > const&) const+0x75) [0x6869635] |
| 59 | +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] |
| 60 | +5. clickhouse-server(DB::FunctionBuilderImpl::getReturnType(std::vector<DB::ColumnWithTypeAndName, std::allocator<DB::ColumnWithTypeAndName> > const&) const+0x350) [0x6869f10] |
| 61 | +5. clickhouse-server(DB::MultiplexedConnections::receivePacket()+0x7e) [0x67e7ede] |
| 62 | +5. clickhouse-server(DB::PreparedFunctionImpl::execute(DB::Block&, std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, unsigned long)+0x3e2) [0x7933492] |
| 63 | +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] |
| 64 | +6. clickhouse-server(DB::FunctionBuilderImpl::build(std::vector<DB::ColumnWithTypeAndName, std::allocator<DB::ColumnWithTypeAndName> > const&) const+0x3c) [0x38accfc] |
| 65 | +6. clickhouse-server(DB::RemoteBlockInputStream::readImpl()+0x87) [0x631da97] |
| 66 | +7. clickhouse-server(DB::ExpressionActions::addImpl(DB::ExpressionAction, 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> > > >&)+0x552) [0x6a00052] |
| 67 | +7. clickhouse-server(DB::ExpressionActions::execute(DB::Block&) const+0xe6) [0x7ae1e06] |
| 68 | +7. clickhouse-server(DB::IBlockInputStream::read()+0x178) [0x63075e8] |
| 69 | +8. clickhouse-server(DB::ExpressionActions::add(DB::ExpressionAction 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> > > >&)+0x42) [0x6a00422] |
| 70 | +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] |
| 71 | +8. clickhouse-server(DB::ParallelInputsProcessor<DB::UnionBlockInputStream::Handler>::thread(std::shared_ptr<DB::ThreadGroupStatus>, unsigned long)+0x2f1) [0x64467c1] |
| 72 | +9. clickhouse-server() [0x75bd5a3] |
| 73 | +9. clickhouse-server(DB::ScopeStack::addAction(DB::ExpressionAction const&)+0xd2) [0x6ae04d2] |
| 74 | +9. clickhouse-server(ThreadFromGlobalPool::ThreadFromGlobalPool<DB::ParallelInputsProcessor<DB::UnionBlockInputStream::Handler>::process()::{lambda()#1}>(DB::ParallelInputsProcessor<DB::UnionBlockInputStream::Handler>::process()::{lambda()#1}&&)::{lambda()#1}::operator()() const+0x6d) [0x644722d] |
33 | 75 | """
|
34 | 76 |
|
35 | 77 |
|
36 |
| -def test_basic(sentry_init, capture_events): |
| 78 | +@pytest.mark.parametrize("input", LINES.strip().splitlines()) |
| 79 | +def test_basic(sentry_init, capture_events, input): |
37 | 80 | sentry_init(integrations=[GnuBacktraceIntegration()])
|
38 | 81 | events = capture_events()
|
39 | 82 |
|
40 | 83 | try:
|
41 |
| - raise ValueError(EXC_VALUE) |
| 84 | + raise ValueError(input) |
42 | 85 | except ValueError:
|
43 | 86 | capture_exception()
|
44 | 87 |
|
45 | 88 | event, = events
|
46 | 89 | exception, = event["exception"]["values"]
|
47 | 90 |
|
48 |
| - assert exception["value"] == ( |
49 |
| - "\n" |
50 |
| - "DB::Exception: Cannot parse datetime. Stack trace:\n" |
51 |
| - "\n" |
52 |
| - "<stacktrace parsed and removed by GnuBacktraceIntegration>" |
| 91 | + assert ( |
| 92 | + exception["value"] |
| 93 | + == "<stacktrace parsed and removed by GnuBacktraceIntegration>" |
53 | 94 | )
|
| 95 | + frame, = exception["stacktrace"]["frames"][1:] |
54 | 96 |
|
55 |
| - assert exception["stacktrace"]["frames"][1:] == [ |
56 |
| - { |
57 |
| - "function": "clone", |
58 |
| - "in_app": True, |
59 |
| - "package": "/lib/x86_64-linux-gnu/libc.so.6", |
60 |
| - "platform": "native", |
61 |
| - }, |
62 |
| - { |
63 |
| - "in_app": True, |
64 |
| - "package": "/lib/x86_64-linux-gnu/libpthread.so.0", |
65 |
| - "platform": "native", |
66 |
| - }, |
67 |
| - {"in_app": True, "package": "clickhouse-server", "platform": "native"}, |
68 |
| - { |
69 |
| - "function": "Poco::ThreadImpl::runnableEntry", |
70 |
| - "in_app": True, |
71 |
| - "package": "clickhouse-server", |
72 |
| - "platform": "native", |
73 |
| - }, |
74 |
| - { |
75 |
| - "function": "Poco::PooledThread::run", |
76 |
| - "in_app": True, |
77 |
| - "package": "clickhouse-server", |
78 |
| - "platform": "native", |
79 |
| - }, |
80 |
| - { |
81 |
| - "function": "Poco::Net::TCPServerDispatcher::run", |
82 |
| - "in_app": True, |
83 |
| - "package": "clickhouse-server", |
84 |
| - "platform": "native", |
85 |
| - }, |
86 |
| - { |
87 |
| - "function": "Poco::Net::TCPServerConnection::start", |
88 |
| - "in_app": True, |
89 |
| - "package": "clickhouse-server", |
90 |
| - "platform": "native", |
91 |
| - }, |
92 |
| - { |
93 |
| - "function": "DB::TCPHandler::run", |
94 |
| - "in_app": True, |
95 |
| - "package": "clickhouse-server", |
96 |
| - "platform": "native", |
97 |
| - }, |
98 |
| - { |
99 |
| - "function": "DB::TCPHandler::runImpl", |
100 |
| - "in_app": True, |
101 |
| - "package": "clickhouse-server", |
102 |
| - "platform": "native", |
103 |
| - }, |
104 |
| - { |
105 |
| - "function": "DB::executeQuery", |
106 |
| - "in_app": True, |
107 |
| - "package": "clickhouse-server", |
108 |
| - "platform": "native", |
109 |
| - }, |
110 |
| - {"in_app": True, "package": "clickhouse-server", "platform": "native"}, |
111 |
| - { |
112 |
| - "function": "DB::InterpreterFactory::get", |
113 |
| - "in_app": True, |
114 |
| - "package": "clickhouse-server", |
115 |
| - "platform": "native", |
116 |
| - }, |
117 |
| - { |
118 |
| - "function": "DB::InterpreterSelectWithUnionQuery::InterpreterSelectWithUnionQuery", |
119 |
| - "in_app": True, |
120 |
| - "package": "clickhouse-server", |
121 |
| - "platform": "native", |
122 |
| - }, |
123 |
| - { |
124 |
| - "function": "DB::InterpreterSelectQuery::InterpreterSelectQuery", |
125 |
| - "in_app": True, |
126 |
| - "package": "clickhouse-server", |
127 |
| - "platform": "native", |
128 |
| - }, |
129 |
| - { |
130 |
| - "function": "DB::InterpreterSelectQuery::InterpreterSelectQuery", |
131 |
| - "in_app": True, |
132 |
| - "package": "clickhouse-server", |
133 |
| - "platform": "native", |
134 |
| - }, |
135 |
| - { |
136 |
| - "function": "DB::InterpreterSelectQuery::executeImpl", |
137 |
| - "in_app": True, |
138 |
| - "package": "clickhouse-server", |
139 |
| - "platform": "native", |
140 |
| - }, |
141 |
| - {"in_app": True, "package": "clickhouse-server", "platform": "native"}, |
142 |
| - { |
143 |
| - "function": "DB::FilterBlockInputStream::FilterBlockInputStream", |
144 |
| - "in_app": True, |
145 |
| - "package": "clickhouse-server", |
146 |
| - "platform": "native", |
147 |
| - }, |
148 |
| - { |
149 |
| - "function": "DB::ExpressionActions::execute", |
150 |
| - "in_app": True, |
151 |
| - "package": "clickhouse-server", |
152 |
| - "platform": "native", |
153 |
| - }, |
154 |
| - { |
155 |
| - "function": "DB::ExpressionAction::execute", |
156 |
| - "in_app": True, |
157 |
| - "package": "clickhouse-server", |
158 |
| - "platform": "native", |
159 |
| - }, |
160 |
| - { |
161 |
| - "function": "DB::PreparedFunctionImpl::execute", |
162 |
| - "in_app": True, |
163 |
| - "package": "clickhouse-server", |
164 |
| - "platform": "native", |
165 |
| - }, |
166 |
| - { |
167 |
| - "function": "DB::NameNotEquals>::executeImpl", |
168 |
| - "in_app": True, |
169 |
| - "package": "clickhouse-server", |
170 |
| - "platform": "native", |
171 |
| - }, |
172 |
| - { |
173 |
| - "function": "DB::NameNotEquals>::executeDateOrDateTimeOrEnumOrUUIDWithConstString", |
174 |
| - "in_app": True, |
175 |
| - "package": "clickhouse-server", |
176 |
| - "platform": "native", |
177 |
| - }, |
178 |
| - { |
179 |
| - "function": "DB::readDateTimeTextFallback<void>", |
180 |
| - "in_app": True, |
181 |
| - "package": "clickhouse-server", |
182 |
| - "platform": "native", |
183 |
| - }, |
184 |
| - { |
185 |
| - "function": "DB::Exception::Exception", |
186 |
| - "in_app": True, |
187 |
| - "package": "clickhouse-server", |
188 |
| - "platform": "native", |
189 |
| - }, |
190 |
| - { |
191 |
| - "function": "StackTrace::StackTrace", |
192 |
| - "in_app": True, |
193 |
| - "package": "clickhouse-server", |
194 |
| - "platform": "native", |
195 |
| - }, |
196 |
| - ] |
| 97 | + if "function" not in frame: |
| 98 | + assert "clickhouse-server()" in input or "pthread" in input |
| 99 | + else: |
| 100 | + assert frame["function"] |
| 101 | + assert ")" not in frame["function"] and "(" not in frame["function"] |
| 102 | + assert frame["function"] in input |
0 commit comments