Merge pull request #23569 from sammyKhan/master

Return blank span if no call is active.
This commit is contained in:
donnadionne 2020-08-18 13:35:01 -07:00 committed by GitHub
commit 6b80f4d7f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -57,6 +57,8 @@ void RegisterOpenCensusPlugin() {
::opencensus::trace::Span GetSpanFromServerContext(
grpc::ServerContext* context) {
if (context == nullptr) return opencensus::trace::Span::BlankSpan();
return reinterpret_cast<const grpc::CensusContext*>(context->census_context())
->Span();
}

View File

@ -367,7 +367,7 @@ std::string ServerContextBase::peer() const {
}
const struct census_context* ServerContextBase::census_context() const {
return grpc_census_call_get_context(call_);
return call_ == nullptr ? nullptr : grpc_census_call_get_context(call_);
}
void ServerContextBase::SetLoadReportingCosts(