| 147 | }// function AddEvent |
| 148 | |
| 149 | void BufferedSpan::Submit() { |
| 150 | if (span_submitted_ || cancelled_) { |
| 151 | VLOG(2) << strings::Substitute("Not submitting span '$0', submitted='$1' " |
| 152 | "cancelled='$2'.", name_, span_submitted_, cancelled_); |
| 153 | return; |
| 154 | } |
| 155 | |
| 156 | VLOG(2) << "Submitting span '" << name_ << "'."; |
| 157 | |
| 158 | if (!span_) { |
| 159 | Start(); |
| 160 | } |
| 161 | |
| 162 | if (!end_time_set_) { |
| 163 | RecordEndTimeNow(); |
| 164 | } |
| 165 | |
| 166 | const int64_t end_time = chrono::duration_cast<chrono::milliseconds>( |
| 167 | end_steady_time_.time_since_epoch()).count(); |
| 168 | const int64_t start_time = chrono::duration_cast<chrono::milliseconds>( |
| 169 | start_steady_time_.time_since_epoch()).count(); |
| 170 | |
| 171 | span_->SetAttribute("EndTime", |
| 172 | static_cast<int64_t>(chrono::duration_cast<chrono::milliseconds>( |
| 173 | end_steady_time_.time_since_epoch()).count())); |
| 174 | span_->SetAttribute(duration_attribute_name_, (end_time - start_time)); |
| 175 | |
| 176 | for (const auto& a : attributes_) { |
| 177 | nostd::visit([&](const auto& value) { |
| 178 | span_->SetAttribute(a.first, value); |
| 179 | }, a.second); |
| 180 | } |
| 181 | |
| 182 | AddEventsToSpan(); |
| 183 | |
| 184 | trace::EndSpanOptions end_options; |
| 185 | end_options.end_steady_time = end_steady_time_; |
| 186 | span_->End(end_options); |
| 187 | span_submitted_ = true; |
| 188 | span_ = nullptr; |
| 189 | } // function Submit |
| 190 | |
| 191 | const trace::SpanContext BufferedSpan::GetContext() const { |
| 192 | if (span_) { |
no test coverage detected