7
7
#include < codecvt>
8
8
#include < memory>
9
9
#include < chrono>
10
+ #include < tuple>
10
11
11
12
#include < thrift/protocol/TProtocol.h>
12
13
@@ -854,16 +855,21 @@ namespace __impl
854
855
{
855
856
856
857
template <typename K, typename V>
857
- struct Annotation
858
+ struct __annotation
858
859
{
859
860
static void apply (Span &span, const std::pair<K, V> &value)
860
861
{
861
862
span.annotate (value.first , value.second );
862
863
}
864
+
865
+ static void apply (Span &span, const std::tuple<K, V, Endpoint *> &value)
866
+ {
867
+ span.annotate (std::get<0 >(value), std::get<1 >(value), std::get<2 >(value));
868
+ }
863
869
};
864
870
865
871
template <>
866
- struct Annotation <const char *, Endpoint *>
872
+ struct __annotation <const char *, Endpoint *>
867
873
{
868
874
static void apply (Span &span, const std::pair<const char *, Endpoint *> &value)
869
875
{
@@ -881,12 +887,48 @@ struct Annotation<const char *, Endpoint *>
881
887
}
882
888
};
883
889
890
+ template <typename K>
891
+ struct __annotation <K, const char *>
892
+ {
893
+ static void apply (Span &span, const std::pair<K, const char *> &value)
894
+ {
895
+ span.annotate (value.first , value.second );
896
+ }
897
+
898
+ static void apply (Span &span, const std::tuple<K, const char *, Endpoint *> &value)
899
+ {
900
+ span.annotate (std::get<0 >(value), std::get<1 >(value), -1 , std::get<2 >(value));
901
+ }
902
+ };
903
+
904
+ template <typename K>
905
+ struct __annotation <K, const wchar_t *>
906
+ {
907
+ static void apply (Span &span, const std::pair<K, const wchar_t *> &value)
908
+ {
909
+ span.annotate (value.first , value.second );
910
+ }
911
+
912
+ static void apply (Span &span, const std::tuple<K, const wchar_t *, Endpoint *> &value)
913
+ {
914
+ span.annotate (std::get<0 >(value), std::get<1 >(value), -1 , std::get<2 >(value));
915
+ }
916
+ };
917
+
884
918
} // namespace __impl
885
919
886
920
template <typename K, typename V>
887
921
Span &operator <<(Span &span, const std::pair<K, V> &value)
888
922
{
889
- __impl::Annotation<K, V>::apply (span, value);
923
+ __impl::__annotation<K, V>::apply (span, value);
924
+
925
+ return span;
926
+ }
927
+
928
+ template <typename K, typename V>
929
+ Span &operator <<(Span &span, const std::tuple<K, V, Endpoint *> &value)
930
+ {
931
+ __impl::__annotation<K, V>::apply (span, value);
890
932
891
933
return span;
892
934
}
@@ -959,32 +1001,31 @@ Endpoint &Endpoint::with_ipv6(const std::string &ip)
959
1001
namespace __impl
960
1002
{
961
1003
template <typename T>
962
- struct __annotation
1004
+ struct __binary_annotation
963
1005
{
964
- static size_t size_of (bool *) { return sizeof (T); }
965
1006
};
966
1007
template <>
967
- struct __annotation <bool >
1008
+ struct __binary_annotation <bool >
968
1009
{
969
1010
static const AnnotationType type = AnnotationType::BOOL;
970
1011
};
971
1012
template <>
972
- struct __annotation <int16_t >
1013
+ struct __binary_annotation <int16_t >
973
1014
{
974
1015
static const AnnotationType type = AnnotationType::I16;
975
1016
};
976
1017
template <>
977
- struct __annotation <int32_t >
1018
+ struct __binary_annotation <int32_t >
978
1019
{
979
1020
static const AnnotationType type = AnnotationType::I32;
980
1021
};
981
1022
template <>
982
- struct __annotation <int64_t >
1023
+ struct __binary_annotation <int64_t >
983
1024
{
984
1025
static const AnnotationType type = AnnotationType::I64;
985
1026
};
986
1027
template <>
987
- struct __annotation <double >
1028
+ struct __binary_annotation <double >
988
1029
{
989
1030
static const AnnotationType type = AnnotationType::DOUBLE;
990
1031
};
@@ -1007,7 +1048,7 @@ inline BinaryAnnotation Span::annotate(const std::string &key, const T &value, c
1007
1048
1008
1049
annotation.__set_key (key);
1009
1050
annotation.__set_value (std::string (reinterpret_cast <const char *>(&value), sizeof (T)));
1010
- annotation.__set_annotation_type (__impl::__annotation <T>::type);
1051
+ annotation.__set_annotation_type (__impl::__binary_annotation <T>::type);
1011
1052
1012
1053
if (endpoint)
1013
1054
{
0 commit comments