OpenCensus: Move metadata storage to arena (#27948)

pull/27920/head
Yash Tibrewal 3 years ago committed by GitHub
parent e602169fa0
commit 296f596a96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      src/cpp/ext/filters/census/client_filter.cc
  2. 6
      src/cpp/ext/filters/census/open_census_call_tracer.h

@ -91,35 +91,28 @@ OpenCensusCallTracer::OpenCensusCallAttemptTracer::OpenCensusCallAttemptTracer(
start_time_(absl::Now()) {
context_.AddSpanAttribute("previous-rpc-attempts", attempt_num);
context_.AddSpanAttribute("transparent-retry", is_transparent_retry);
memset(&stats_bin_, 0, sizeof(grpc_linked_mdelem));
memset(&tracing_bin_, 0, sizeof(grpc_linked_mdelem));
}
void OpenCensusCallTracer::OpenCensusCallAttemptTracer::
RecordSendInitialMetadata(grpc_metadata_batch* send_initial_metadata,
uint32_t /* flags */) {
size_t tracing_len = TraceContextSerialize(context_.Context(), tracing_buf_,
char tracing_buf[kMaxTraceContextLen];
size_t tracing_len = TraceContextSerialize(context_.Context(), tracing_buf,
kMaxTraceContextLen);
if (tracing_len > 0) {
GRPC_LOG_IF_ERROR(
"census grpc_filter",
grpc_metadata_batch_add_tail(
send_initial_metadata, &tracing_bin_,
grpc_mdelem_from_slices(
send_initial_metadata->Append(grpc_mdelem_from_slices(
GRPC_MDSTR_GRPC_TRACE_BIN,
grpc_core::UnmanagedMemorySlice(tracing_buf_, tracing_len)),
GRPC_BATCH_GRPC_TRACE_BIN));
grpc_core::UnmanagedMemorySlice(tracing_buf, tracing_len))));
}
grpc_slice tags = grpc_empty_slice();
// TODO(unknown): Add in tagging serialization.
size_t encoded_tags_len = StatsContextSerialize(kMaxTagsLen, &tags);
if (encoded_tags_len > 0) {
GRPC_LOG_IF_ERROR(
"census grpc_filter",
grpc_metadata_batch_add_tail(
send_initial_metadata, &stats_bin_,
grpc_mdelem_from_slices(GRPC_MDSTR_GRPC_TAGS_BIN, tags),
GRPC_BATCH_GRPC_TAGS_BIN));
GRPC_LOG_IF_ERROR("census grpc_filter",
send_initial_metadata->Append(grpc_mdelem_from_slices(
GRPC_MDSTR_GRPC_TAGS_BIN, tags)));
}
}

@ -63,9 +63,6 @@ class OpenCensusCallTracer : public grpc_core::CallTracer {
OpenCensusCallTracer* parent_;
const bool arena_allocated_;
CensusContext context_;
// Metadata elements for tracing and census stats data.
grpc_linked_mdelem stats_bin_;
grpc_linked_mdelem tracing_bin_;
// Start time (for measuring latency).
absl::Time start_time_;
// Server elapsed time in nanoseconds.
@ -75,9 +72,6 @@ class OpenCensusCallTracer : public grpc_core::CallTracer {
uint64_t sent_message_count_ = 0;
// End status code
absl::StatusCode status_code_;
// Buffer needed for grpc_slice to reference when adding trace context
// metatdata to outgoing message.
char tracing_buf_[kMaxTraceContextLen];
};
explicit OpenCensusCallTracer(const grpc_call_element_args* args);

Loading…
Cancel
Save