|
14 | 14 |
|
15 | 15 | // Example RPC server using gRPC. |
16 | 16 |
|
| 17 | +#include <grpcpp/grpcpp.h> |
| 18 | +#include <grpcpp/opencensus.h> |
| 19 | + |
17 | 20 | #include <cstdlib> |
18 | 21 | #include <iostream> |
19 | 22 | #include <memory> |
20 | 23 | #include <string> |
21 | 24 |
|
22 | | -#include <grpcpp/grpcpp.h> |
23 | | -#include <grpcpp/opencensus.h> |
24 | | - |
25 | 25 | #include "absl/strings/escaping.h" |
26 | 26 | #include "absl/strings/numbers.h" |
27 | 27 | #include "absl/strings/str_cat.h" |
|
30 | 30 | #include "examples/grpc/hello.pb.h" |
31 | 31 | #include "opencensus/exporters/stats/prometheus/prometheus_exporter.h" |
32 | 32 | #include "opencensus/stats/stats.h" |
| 33 | +#include "opencensus/tags/context_util.h" |
| 34 | +#include "opencensus/tags/tag_map.h" |
| 35 | +#include "opencensus/trace/context_util.h" |
33 | 36 | #include "opencensus/trace/sampler.h" |
34 | 37 | #include "opencensus/trace/span.h" |
35 | 38 | #include "opencensus/trace/trace_config.h" |
@@ -89,8 +92,13 @@ class HelloServiceImpl final : public HelloService::Service { |
89 | 92 | {{LettersMeasure(), request->name().size()}}, |
90 | 93 | {{CaseKey(), isupper(request->name()[0]) ? "upper" : "lower"}}); |
91 | 94 | // Give feedback on stderr. |
92 | | - std::cerr << "SayHello RPC handled.\n"; |
93 | | - std::cerr << " Metadata:\n"; |
| 95 | + std::cerr << "SayHello RPC handler:\n"; |
| 96 | + std::cerr << " Current context: " |
| 97 | + << opencensus::trace::GetCurrentSpan().context().ToString() |
| 98 | + << "\n"; |
| 99 | + std::cerr << " Current tags: " |
| 100 | + << opencensus::tags::GetCurrentTagMap().DebugString() << "\n"; |
| 101 | + std::cerr << " gRPC metadata:\n"; |
94 | 102 | auto metadata = context->client_metadata(); |
95 | 103 | for (const auto &mdpair : metadata) { |
96 | 104 | std::cerr << " \"" << absl::CEscape(ToStringView(mdpair.first)) |
|
0 commit comments