wilson_span.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #include "wilson_span.h"
  2. #include "wilson_uploader.h"
  3. #include <library/cpp/actors/core/log.h>
  4. #include <google/protobuf/text_format.h>
  5. namespace NWilson {
  6. using namespace NActors;
  7. void SerializeValue(TAttributeValue value, NCommonProto::AnyValue *pb) {
  8. switch (value.index()) {
  9. case 0:
  10. pb->set_string_value(std::get<0>(std::move(value)));
  11. break;
  12. case 1:
  13. pb->set_bool_value(std::get<1>(value));
  14. break;
  15. case 2:
  16. pb->set_int_value(std::get<2>(value));
  17. break;
  18. case 3:
  19. pb->set_double_value(std::get<3>(std::move(value)));
  20. break;
  21. case 4: {
  22. auto *array = pb->mutable_array_value();
  23. for (auto&& item : std::get<4>(std::move(value))) {
  24. SerializeValue(std::move(item), array->add_values());
  25. }
  26. break;
  27. }
  28. case 5: {
  29. auto *kv = pb->mutable_kvlist_value();
  30. for (auto&& [key, value] : std::get<5>(std::move(value))) {
  31. SerializeKeyValue(std::move(key), std::move(value), kv->add_values());
  32. }
  33. break;
  34. }
  35. case 6:
  36. pb->set_bytes_value(std::get<6>(std::move(value)));
  37. break;
  38. }
  39. }
  40. void SerializeKeyValue(TString key, TAttributeValue value, NCommonProto::KeyValue *pb) {
  41. pb->set_key(std::move(key));
  42. SerializeValue(std::move(value), pb->mutable_value());
  43. }
  44. void TSpan::Send() {
  45. if (TlsActivationContext) {
  46. TActivationContext::Send(new IEventHandle(MakeWilsonUploaderId(), {}, new TEvWilson(&Data->Span)));
  47. }
  48. Data->Sent = true;
  49. }
  50. } // NWilson