[CSM O11y] Example logs (#37823)

Closes #37823

PiperOrigin-RevId: 681149244
pull/37820/head
Yash Tibrewal 2 months ago committed by Copybara-Service
parent c938a7b564
commit 74e640341d
  1. 2
      examples/cpp/csm/observability/BUILD
  2. 2
      examples/cpp/csm/observability/Dockerfile.server
  3. 5
      examples/cpp/csm/observability/csm_greeter_server.cc
  4. 4
      examples/cpp/otel/util.cc

@ -44,6 +44,8 @@ cc_binary(
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:globals",
"@com_google_absl//absl/log:initialize",
"@io_opentelemetry_cpp//exporters/prometheus:prometheus_exporter",
"@io_opentelemetry_cpp//sdk/src/metrics",
],

@ -27,6 +27,8 @@ RUN cp -rL /workdir/bazel-bin/examples/cpp/csm/observability/csm_greeter_server
FROM python:3.9-slim-bookworm
ENV GRPC_TRACE="xds_client,xds_resolver,xds_cluster_manager_lb,cds_lb,xds_cluster_resolver_lb,priority_lb,xds_cluster_impl_lb,weighted_target_lb,xds_server_config_fetcher,ring_hash_lb,outlier_detection_lb,xds_wrr_locality_lb,xds_override_host_lb"
RUN apt-get update \
&& apt-get -y upgrade \
&& apt-get -y autoremove \

@ -22,6 +22,8 @@
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "absl/log/log.h"
#include "absl/strings/str_cat.h"
#include "examples/cpp/otel/util.h"
@ -42,6 +44,9 @@ ABSL_FLAG(std::string, prometheus_endpoint, "localhost:9464",
int main(int argc, char** argv) {
absl::ParseCommandLine(argc, argv);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
absl::SetGlobalVLogLevel(2);
absl::InitializeLog();
opentelemetry::exporter::metrics::PrometheusExporterOptions opts;
// default was "localhost:9464" which causes connection issue across GKE pods
opts.url = "0.0.0.0:9464";

@ -169,10 +169,10 @@ void RunClient(const std::string& target_str) {
// are created. This channel models a connection to an endpoint specified by
// the argument "--target=" which is the only expected argument.
grpc::ChannelArguments args;
GreeterClient greeter(grpc::CreateCustomChannel(
target_str, grpc::InsecureChannelCredentials(), args));
// Continuously send RPCs every second.
while (true) {
GreeterClient greeter(grpc::CreateCustomChannel(
target_str, grpc::InsecureChannelCredentials(), args));
std::string user("world");
std::string reply = greeter.SayHello(user);
std::cout << "Greeter received: " << reply << std::endl;

Loading…
Cancel
Save