Gcp Observability Logging: Fix the log name and resource for the gcp logging API (#32148)

* Gcp Observability Logging: Fix the log name and resource for the gcp logging API

* iwyu

* Fix build

* Fix build - try 2
pull/31985/head
Yash Tibrewal 2 years ago committed by GitHub
parent d7193a28c4
commit e7f1e9d1d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      bazel/grpc_build_system.bzl
  2. 1
      src/cpp/ext/gcp/BUILD
  3. 5
      src/cpp/ext/gcp/observability_logging_sink.cc
  4. 4
      tools/distrib/fix_build_deps.py

@ -70,6 +70,8 @@ def _get_external_deps(external_deps):
ret.append("//third_party/objective_c/Cronet:cronet_c_for_grpc")
elif dep.startswith("absl/"):
ret.append("@com_google_absl//" + dep)
elif dep.startswith("google/"):
ret.append("@com_google_googleapis//" + dep)
else:
ret.append("//external:" + dep)
return ret

@ -104,6 +104,7 @@ grpc_cc_library(
"absl/strings",
"absl/strings:str_format",
"absl/types:optional",
"google/api:monitored_resource_cc_proto",
"googleapis_logging_cc_proto",
"googleapis_logging_grpc_service",
"protobuf_headers",

@ -29,6 +29,7 @@
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "absl/types/optional.h"
#include "google/api/monitored_resource.pb.h"
#include "google/logging/v2/log_entry.pb.h"
#include "google/logging/v2/logging.grpc.pb.h"
#include "google/logging/v2/logging.pb.h"
@ -249,10 +250,12 @@ void ObservabilityLoggingSink::LogEntry(Entry entry) {
CallContext* call = new CallContext;
call->context.set_authority(authority_);
call->request.set_log_name(
absl::StrFormat("projects/{%s}/logs/"
absl::StrFormat("projects/%s/logs/"
"microservices.googleapis.com%%2Fobservability%%2fgrpc",
project_id_));
(*call->request.mutable_labels()).insert(labels_.begin(), labels_.end());
// TODO(yashykt): Figure out the proper resource type and labels.
call->request.mutable_resource()->set_type("global");
auto* proto_entry = call->request.add_entries();
// Fill the current timestamp
gpr_timespec timespec =

@ -136,6 +136,8 @@ EXTERNAL_DEPS = {
'address_sorting',
'ares.h':
'cares',
'google/api/monitored_resource.pb.h':
'google/api:monitored_resource_cc_proto',
'google/devtools/cloudtrace/v2/tracing.grpc.pb.h':
'googleapis_trace_grpc_service',
'google/logging/v2/logging.grpc.pb.h':
@ -563,7 +565,7 @@ def make_library(library):
if hdr in INTERNAL_DEPS:
dep = INTERNAL_DEPS[hdr]
if not dep.startswith('//'):
if not ('//' in dep):
dep = '//:' + dep
deps.add(dep, hdr)
continue

Loading…
Cancel
Save