GCP Observability: Plumbing with logging filter (#32065)

* GCP Observability: Plumbing with logging filter

* Fix MacOS build

* IWYU

* IWYU again
pull/30954/head
Yash Tibrewal 2 years ago committed by GitHub
parent d5c1dc1667
commit 062afbd05d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      src/cpp/ext/filters/logging/logging_filter.cc
  2. 2
      src/cpp/ext/gcp/BUILD
  3. 10
      src/cpp/ext/gcp/observability.cc

@ -20,8 +20,8 @@
#include "src/cpp/ext/filters/logging/logging_filter.h"
#include <inttypes.h>
#include <limits.h>
#include <stdint.h>
#include <algorithm>
#include <cstddef>
@ -117,9 +117,10 @@ class MetadataEncoder {
}
uint64_t mdentry_len = key.length() + value.length();
if (mdentry_len > log_len_) {
gpr_log(GPR_DEBUG,
"Skipped metadata key because of max metadata logging bytes %lu "
"(current) vs %lu (max less already accounted metadata)",
gpr_log(
GPR_DEBUG,
"Skipped metadata key because of max metadata logging bytes %" PRIu64
" (current) vs %" PRIu64 " (max less already accounted metadata)",
mdentry_len, log_len_);
truncated_ = true;
return;

@ -51,9 +51,11 @@ grpc_cc_library(
visibility = ["//:__subpackages__"],
deps = [
"observability_config",
"observability_logging_sink",
"//:gpr",
"//:grpc++",
"//:grpc_opencensus_plugin",
"//src/cpp/ext/filters/logging:logging_filter",
],
)

@ -40,7 +40,9 @@
#include "src/cpp/ext/filters/census/grpc_plugin.h"
#include "src/cpp/ext/filters/census/open_census_call_tracer.h"
#include "src/cpp/ext/filters/logging/logging_filter.h"
#include "src/cpp/ext/gcp/observability_config.h"
#include "src/cpp/ext/gcp/observability_logging_sink.h"
namespace grpc {
namespace experimental {
@ -80,7 +82,8 @@ absl::Status GcpObservabilityInit() {
return config.status();
}
if (!config->cloud_trace.has_value() &&
!config->cloud_monitoring.has_value()) {
!config->cloud_monitoring.has_value() &&
!config->cloud_logging.has_value()) {
return absl::OkStatus();
}
grpc::RegisterOpenCensusPlugin();
@ -116,6 +119,11 @@ absl::Status GcpObservabilityInit() {
// Disable OpenCensus stats
EnableOpenCensusStats(false);
}
if (config->cloud_logging.has_value()) {
grpc::internal::RegisterLoggingFilter(
new grpc::internal::ObservabilityLoggingSink(
config->cloud_logging.value(), config->project_id));
}
return absl::OkStatus();
}

Loading…
Cancel
Save