|
25 | 25 | #include "examples/grpc/exporters.h" |
26 | 26 | #include "examples/grpc/hello.grpc.pb.h" |
27 | 27 | #include "examples/grpc/hello.pb.h" |
| 28 | +#include "opencensus/tags/context_util.h" |
| 29 | +#include "opencensus/tags/tag_key.h" |
| 30 | +#include "opencensus/tags/tag_map.h" |
| 31 | +#include "opencensus/tags/with_tag_map.h" |
28 | 32 | #include "opencensus/trace/context_util.h" |
29 | 33 | #include "opencensus/trace/sampler.h" |
30 | 34 | #include "opencensus/trace/trace_config.h" |
@@ -65,8 +69,19 @@ int main(int argc, char **argv) { |
65 | 69 | "HelloClient", /*parent=*/nullptr, {&sampler}); |
66 | 70 | std::cout << "HelloClient span context is " << span.context().ToString() |
67 | 71 | << "\n"; |
| 72 | + |
| 73 | + // Extend the current tag map. |
| 74 | + // (in this example, there are no tags currently present, but in real code we |
| 75 | + // wouldn't want to drop tags) |
| 76 | + static const auto key = opencensus::tags::TagKey::Register("my_key"); |
| 77 | + std::vector<std::pair<opencensus::tags::TagKey, std::string>> tags( |
| 78 | + opencensus::tags::GetCurrentTagMap().tags()); |
| 79 | + tags.emplace_back(key, "my_value"); |
| 80 | + opencensus::tags::TagMap tag_map(std::move(tags)); |
| 81 | + |
68 | 82 | { |
69 | 83 | opencensus::trace::WithSpan ws(span); |
| 84 | + opencensus::tags::WithTagMap wt(tag_map); |
70 | 85 |
|
71 | 86 | // The client Span ends when ctx falls out of scope. |
72 | 87 | grpc::ClientContext ctx; |
|
0 commit comments