@@ -22,7 +22,7 @@ namespace impl {
2222struct SpanWrapCall {
2323 enum class InheritVariables { kYes , kNo };
2424
25- explicit SpanWrapCall (std::string&& name, InheritVariables inherit_variables);
25+ explicit SpanWrapCall (std::string&& name, InheritVariables inherit_variables, const SourceLocation& location );
2626
2727 SpanWrapCall (const SpanWrapCall&) = delete ;
2828 SpanWrapCall (SpanWrapCall&&) = delete ;
@@ -41,14 +41,20 @@ struct SpanWrapCall {
4141
4242 struct Impl ;
4343
44- static constexpr std::size_t kImplSize = 4280 ;
44+ static constexpr std::size_t kImplSize = 4328 ;
4545 static constexpr std::size_t kImplAlign = 8 ;
4646 utils::FastPimpl<Impl, kImplSize , kImplAlign > pimpl_;
4747};
4848
49- // Note: 'name' must outlive the result of this function
50- inline auto SpanLazyPrvalue (std::string&& name) {
51- return utils::LazyPrvalue ([&name] { return SpanWrapCall (std::move (name), SpanWrapCall::InheritVariables::kYes ); });
49+ // Note: 'name' and 'location' must outlive the result of this function
50+ inline auto SpanLazyPrvalue (
51+ std::string&& name,
52+ SpanWrapCall::InheritVariables inherit_variables = SpanWrapCall::InheritVariables::kYes ,
53+ const SourceLocation& location = SourceLocation::Current()
54+ ) {
55+ return utils::LazyPrvalue ([&name, inherit_variables, &location] {
56+ return SpanWrapCall (std::move (name), inherit_variables, location);
57+ });
5258}
5359
5460} // namespace impl
@@ -366,9 +372,7 @@ template <typename Function, typename... Args>
366372AsyncBackground (std::string name, engine::TaskProcessor& task_processor, Function&& f, Args&&... args) {
367373 return engine::AsyncNoSpan (
368374 task_processor,
369- utils::LazyPrvalue ([&] {
370- return impl::SpanWrapCall (std::move (name), impl::SpanWrapCall::InheritVariables::kNo );
371- }),
375+ impl::SpanLazyPrvalue (std::move (name), impl::SpanWrapCall::InheritVariables::kNo ),
372376 std::forward<Function>(f),
373377 std::forward<Args>(args)...
374378 );
@@ -392,9 +396,7 @@ template <typename Function, typename... Args>
392396CriticalAsyncBackground (std::string name, engine::TaskProcessor& task_processor, Function&& f, Args&&... args) {
393397 return engine::CriticalAsyncNoSpan (
394398 task_processor,
395- utils::LazyPrvalue ([&] {
396- return impl::SpanWrapCall (std::move (name), impl::SpanWrapCall::InheritVariables::kNo );
397- }),
399+ impl::SpanLazyPrvalue (std::move (name), impl::SpanWrapCall::InheritVariables::kNo ),
398400 std::forward<Function>(f),
399401 std::forward<Args>(args)...
400402 );
0 commit comments