grpc 1.1.2 → 1.2.0.pre1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (255) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +1257 -404
  3. data/etc/roots.pem +189 -102
  4. data/include/grpc/census.h +7 -7
  5. data/include/grpc/compression.h +4 -4
  6. data/include/grpc/grpc.h +13 -7
  7. data/include/grpc/impl/codegen/atm_gcc_atomic.h +26 -9
  8. data/include/grpc/impl/codegen/grpc_types.h +39 -30
  9. data/include/grpc/impl/codegen/slice.h +24 -6
  10. data/include/grpc/impl/codegen/sync.h +8 -0
  11. data/include/grpc/load_reporting.h +63 -0
  12. data/include/grpc/slice.h +37 -1
  13. data/include/grpc/slice_buffer.h +7 -0
  14. data/include/grpc/support/alloc.h +3 -0
  15. data/include/grpc/support/useful.h +3 -0
  16. data/src/core/ext/census/gen/census.pb.h +1 -1
  17. data/src/core/ext/census/gen/trace_context.pb.c +9 -36
  18. data/src/core/ext/census/gen/trace_context.pb.h +20 -26
  19. data/src/core/ext/census/grpc_filter.c +3 -5
  20. data/src/core/ext/census/trace_context.c +1 -1
  21. data/src/core/ext/census/trace_context.h +3 -0
  22. data/src/core/ext/census/trace_label.h +61 -0
  23. data/src/core/ext/census/trace_propagation.h +63 -0
  24. data/src/core/ext/census/trace_status.h +45 -0
  25. data/src/core/ext/census/trace_string.h +50 -0
  26. data/src/core/ext/census/tracing.c +31 -11
  27. data/src/core/ext/census/tracing.h +124 -0
  28. data/src/core/ext/client_channel/client_channel.c +456 -368
  29. data/src/core/ext/client_channel/client_channel.h +4 -0
  30. data/src/core/ext/client_channel/client_channel_plugin.c +6 -1
  31. data/src/core/ext/client_channel/connector.c +3 -3
  32. data/src/core/ext/client_channel/connector.h +4 -3
  33. data/src/core/ext/client_channel/http_connect_handshaker.c +62 -72
  34. data/src/core/ext/client_channel/http_connect_handshaker.h +7 -10
  35. data/src/core/ext/client_channel/http_proxy.c +125 -0
  36. data/src/core/ext/client_channel/http_proxy.h +39 -0
  37. data/src/core/ext/client_channel/lb_policy.c +56 -35
  38. data/src/core/ext/client_channel/lb_policy.h +46 -39
  39. data/src/core/ext/client_channel/lb_policy_factory.h +1 -0
  40. data/src/core/ext/client_channel/parse_address.c +32 -6
  41. data/src/core/ext/client_channel/proxy_mapper.c +63 -0
  42. data/src/core/ext/client_channel/proxy_mapper.h +89 -0
  43. data/src/core/ext/client_channel/proxy_mapper_registry.c +133 -0
  44. data/src/core/ext/client_channel/proxy_mapper_registry.h +59 -0
  45. data/src/core/ext/client_channel/resolver.c +16 -9
  46. data/src/core/ext/client_channel/resolver.h +23 -12
  47. data/src/core/ext/client_channel/resolver_factory.h +1 -0
  48. data/src/core/ext/client_channel/resolver_registry.c +15 -11
  49. data/src/core/ext/client_channel/resolver_registry.h +5 -3
  50. data/src/core/ext/client_channel/subchannel.c +44 -27
  51. data/src/core/ext/client_channel/subchannel.h +6 -2
  52. data/src/core/ext/client_channel/uri_parser.c +26 -14
  53. data/src/core/ext/client_channel/uri_parser.h +3 -1
  54. data/src/core/ext/lb_policy/grpclb/grpclb.c +220 -209
  55. data/src/core/ext/lb_policy/grpclb/grpclb_channel.h +56 -0
  56. data/src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c +107 -0
  57. data/src/core/ext/lb_policy/grpclb/load_balancer_api.c +3 -6
  58. data/src/core/ext/lb_policy/pick_first/pick_first.c +71 -116
  59. data/src/core/ext/lb_policy/round_robin/round_robin.c +52 -67
  60. data/src/core/ext/load_reporting/load_reporting.c +20 -0
  61. data/src/core/ext/load_reporting/load_reporting.h +1 -16
  62. data/src/core/ext/load_reporting/load_reporting_filter.c +28 -54
  63. data/src/core/ext/resolver/dns/native/dns_resolver.c +31 -45
  64. data/src/core/ext/resolver/sockaddr/sockaddr_resolver.c +20 -29
  65. data/src/core/ext/transport/chttp2/client/chttp2_connector.c +11 -8
  66. data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +11 -2
  67. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +143 -46
  68. data/src/core/ext/transport/chttp2/server/chttp2_server.c +12 -50
  69. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +1 -1
  70. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +1 -1
  71. data/src/core/ext/transport/chttp2/transport/bin_decoder.c +7 -7
  72. data/src/core/ext/transport/chttp2/transport/bin_encoder.c +1 -2
  73. data/src/core/ext/transport/chttp2/transport/bin_encoder.h +1 -2
  74. data/src/core/ext/transport/chttp2/transport/chttp2_plugin.c +0 -3
  75. data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +606 -374
  76. data/src/core/ext/transport/chttp2/transport/frame_ping.c +17 -5
  77. data/src/core/ext/transport/chttp2/transport/frame_ping.h +2 -2
  78. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +9 -13
  79. data/src/core/ext/transport/chttp2/transport/frame_settings.c +12 -11
  80. data/src/core/ext/transport/chttp2/transport/frame_settings.h +1 -1
  81. data/src/core/ext/transport/chttp2/transport/frame_window_update.c +5 -6
  82. data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +100 -53
  83. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +2 -2
  84. data/src/core/ext/transport/chttp2/transport/hpack_parser.c +126 -70
  85. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +13 -7
  86. data/src/core/ext/transport/chttp2/transport/hpack_table.c +22 -19
  87. data/src/core/ext/transport/chttp2/transport/hpack_table.h +6 -6
  88. data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +23 -11
  89. data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +6 -2
  90. data/src/core/ext/transport/chttp2/transport/internal.h +169 -42
  91. data/src/core/ext/transport/chttp2/transport/parsing.c +98 -41
  92. data/src/core/ext/transport/chttp2/transport/stream_lists.c +29 -14
  93. data/src/core/ext/transport/chttp2/transport/writing.c +137 -15
  94. data/src/core/lib/channel/channel_stack.c +14 -44
  95. data/src/core/lib/channel/channel_stack.h +10 -17
  96. data/src/core/lib/channel/channel_stack_builder.c +2 -3
  97. data/src/core/lib/channel/compress_filter.c +54 -46
  98. data/src/core/lib/channel/connected_channel.c +4 -4
  99. data/src/core/lib/channel/connected_channel.h +5 -0
  100. data/src/core/lib/channel/context.h +3 -0
  101. data/src/core/lib/channel/deadline_filter.c +61 -61
  102. data/src/core/lib/channel/deadline_filter.h +8 -5
  103. data/src/core/lib/channel/handshaker.c +47 -7
  104. data/src/core/lib/channel/handshaker.h +21 -3
  105. data/src/core/lib/channel/http_client_filter.c +149 -99
  106. data/src/core/lib/channel/http_server_filter.c +163 -147
  107. data/src/core/lib/channel/message_size_filter.c +15 -10
  108. data/src/core/lib/compression/algorithm_metadata.h +4 -4
  109. data/src/core/lib/compression/compression.c +17 -23
  110. data/src/core/lib/http/httpcli.c +3 -2
  111. data/src/core/lib/http/httpcli.h +2 -1
  112. data/src/core/lib/http/httpcli_security_connector.c +2 -3
  113. data/src/core/lib/http/parser.c +2 -2
  114. data/src/core/lib/iomgr/closure.c +6 -3
  115. data/src/core/lib/iomgr/closure.h +4 -2
  116. data/src/core/lib/iomgr/combiner.c +35 -5
  117. data/src/core/lib/iomgr/combiner.h +21 -2
  118. data/src/core/lib/iomgr/endpoint.c +3 -2
  119. data/src/core/lib/iomgr/endpoint.h +3 -2
  120. data/src/core/lib/iomgr/error.c +60 -94
  121. data/src/core/lib/iomgr/error.h +7 -10
  122. data/src/core/lib/iomgr/error_internal.h +54 -0
  123. data/src/core/lib/iomgr/ev_epoll_linux.c +253 -109
  124. data/src/core/lib/iomgr/ev_poll_posix.c +61 -29
  125. data/src/core/lib/iomgr/ev_posix.c +7 -8
  126. data/src/core/lib/iomgr/ev_posix.h +4 -4
  127. data/src/core/lib/iomgr/exec_ctx.c +11 -6
  128. data/src/core/lib/iomgr/exec_ctx.h +11 -14
  129. data/src/core/lib/iomgr/executor.c +2 -2
  130. data/src/core/lib/iomgr/load_file.c +1 -1
  131. data/src/core/lib/iomgr/network_status_tracker.c +5 -81
  132. data/src/core/lib/iomgr/pollset.h +1 -3
  133. data/src/core/lib/iomgr/pollset_set.h +2 -1
  134. data/src/core/lib/iomgr/pollset_set_uv.c +2 -1
  135. data/src/core/lib/iomgr/pollset_set_windows.c +2 -1
  136. data/src/core/lib/iomgr/pollset_uv.c +25 -11
  137. data/src/core/lib/iomgr/pollset_windows.c +0 -11
  138. data/src/core/lib/iomgr/resolve_address_uv.c +50 -2
  139. data/src/core/lib/iomgr/resource_quota.c +41 -11
  140. data/src/core/lib/iomgr/resource_quota.h +6 -0
  141. data/src/core/lib/iomgr/sockaddr_utils.c +33 -17
  142. data/src/core/lib/iomgr/sockaddr_utils.h +4 -0
  143. data/src/core/lib/iomgr/tcp_client_posix.c +2 -3
  144. data/src/core/lib/iomgr/tcp_client_uv.c +1 -3
  145. data/src/core/lib/iomgr/tcp_client_windows.c +21 -6
  146. data/src/core/lib/iomgr/tcp_posix.c +4 -5
  147. data/src/core/lib/iomgr/tcp_server_posix.c +269 -94
  148. data/src/core/lib/iomgr/tcp_server_windows.c +1 -1
  149. data/src/core/lib/iomgr/tcp_uv.c +11 -5
  150. data/src/core/lib/iomgr/tcp_windows.c +20 -7
  151. data/src/core/lib/iomgr/timer_generic.c +15 -22
  152. data/src/core/lib/iomgr/timer_generic.h +1 -1
  153. data/src/core/lib/iomgr/timer_uv.c +10 -6
  154. data/src/core/lib/iomgr/timer_uv.h +1 -1
  155. data/src/core/lib/iomgr/udp_server.c +45 -6
  156. data/src/core/lib/iomgr/udp_server.h +7 -1
  157. data/src/core/lib/iomgr/unix_sockets_posix.c +11 -1
  158. data/src/core/lib/json/json.c +1 -2
  159. data/src/core/lib/profiling/basic_timers.c +17 -3
  160. data/src/core/lib/security/context/security_context.c +3 -10
  161. data/src/core/lib/security/credentials/composite/composite_credentials.c +4 -8
  162. data/src/core/lib/security/credentials/credentials.c +48 -2
  163. data/src/core/lib/security/credentials/credentials.h +13 -0
  164. data/src/core/lib/security/credentials/credentials_metadata.c +1 -2
  165. data/src/core/lib/security/credentials/fake/fake_credentials.c +6 -8
  166. data/src/core/lib/security/credentials/fake/fake_credentials.h +15 -0
  167. data/src/core/lib/security/credentials/google_default/google_default_credentials.c +3 -3
  168. data/src/core/lib/security/credentials/iam/iam_credentials.c +1 -2
  169. data/src/core/lib/security/credentials/jwt/jwt_credentials.c +1 -2
  170. data/src/core/lib/security/credentials/jwt/jwt_verifier.c +5 -8
  171. data/src/core/lib/security/credentials/jwt/jwt_verifier.h +2 -1
  172. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +3 -5
  173. data/src/core/lib/security/credentials/plugin/plugin_credentials.c +15 -13
  174. data/src/core/lib/security/credentials/ssl/ssl_credentials.c +2 -4
  175. data/src/core/lib/security/transport/client_auth_filter.c +72 -47
  176. data/src/core/lib/security/transport/lb_targets_info.c +70 -0
  177. data/src/core/lib/security/transport/lb_targets_info.h +47 -0
  178. data/src/core/lib/security/transport/secure_endpoint.c +3 -3
  179. data/src/core/lib/security/transport/security_connector.c +125 -28
  180. data/src/core/lib/security/transport/security_connector.h +4 -3
  181. data/src/core/lib/security/transport/security_handshaker.c +13 -9
  182. data/src/core/lib/security/transport/server_auth_filter.c +31 -40
  183. data/src/core/lib/security/util/b64.c +1 -1
  184. data/src/core/lib/slice/slice.c +110 -20
  185. data/src/core/lib/slice/slice_buffer.c +92 -39
  186. data/src/core/lib/{transport/mdstr_hash_table.c → slice/slice_hash_table.c} +40 -33
  187. data/src/core/lib/{transport/mdstr_hash_table.h → slice/slice_hash_table.h} +21 -21
  188. data/src/core/lib/slice/slice_intern.c +346 -0
  189. data/src/core/lib/slice/slice_internal.h +15 -0
  190. data/src/core/lib/slice/slice_string_helpers.c +5 -0
  191. data/src/core/lib/slice/slice_string_helpers.h +5 -0
  192. data/src/core/lib/support/alloc.c +26 -1
  193. data/src/core/lib/support/cmdline.c +2 -4
  194. data/src/core/lib/support/cpu_posix.c +2 -7
  195. data/src/core/lib/support/histogram.c +1 -2
  196. data/src/core/lib/support/log_posix.c +8 -4
  197. data/src/core/lib/support/spinlock.h +52 -0
  198. data/src/core/lib/support/subprocess_posix.c +1 -2
  199. data/src/core/lib/support/sync.c +7 -1
  200. data/src/core/lib/support/sync_posix.c +9 -0
  201. data/src/core/lib/support/time_windows.c +7 -1
  202. data/src/core/lib/surface/call.c +647 -629
  203. data/src/core/lib/surface/call.h +4 -1
  204. data/src/core/lib/surface/call_details.c +8 -2
  205. data/src/core/lib/surface/call_log_batch.c +17 -6
  206. data/src/core/lib/surface/channel.c +49 -59
  207. data/src/core/lib/surface/channel.h +5 -6
  208. data/src/core/lib/surface/completion_queue.c +16 -45
  209. data/src/core/lib/surface/completion_queue.h +0 -3
  210. data/src/core/lib/surface/init.c +6 -2
  211. data/src/core/lib/surface/init_secure.c +1 -1
  212. data/src/core/lib/surface/lame_client.c +14 -4
  213. data/src/core/lib/surface/server.c +79 -82
  214. data/src/core/lib/surface/validate_metadata.c +46 -15
  215. data/src/core/lib/surface/validate_metadata.h +43 -0
  216. data/src/core/lib/surface/version.c +2 -2
  217. data/src/core/lib/transport/bdp_estimator.c +104 -0
  218. data/src/core/lib/transport/bdp_estimator.h +76 -0
  219. data/src/core/lib/transport/connectivity_state.c +33 -13
  220. data/src/core/lib/transport/connectivity_state.h +15 -5
  221. data/src/core/lib/transport/error_utils.c +124 -0
  222. data/src/core/lib/transport/error_utils.h +56 -0
  223. data/src/core/{ext/transport/chttp2 → lib}/transport/http2_errors.h +18 -18
  224. data/src/core/lib/transport/metadata.c +259 -503
  225. data/src/core/lib/transport/metadata.h +69 -68
  226. data/src/core/lib/transport/metadata_batch.c +183 -63
  227. data/src/core/lib/transport/metadata_batch.h +50 -26
  228. data/src/core/lib/transport/pid_controller.c +28 -8
  229. data/src/core/lib/transport/pid_controller.h +15 -2
  230. data/src/core/lib/transport/service_config.c +21 -18
  231. data/src/core/lib/transport/service_config.h +5 -5
  232. data/src/core/lib/transport/static_metadata.c +753 -112
  233. data/src/core/lib/transport/static_metadata.h +403 -264
  234. data/src/core/{ext/transport/chttp2 → lib}/transport/status_conversion.c +18 -20
  235. data/src/core/{ext/transport/chttp2 → lib}/transport/status_conversion.h +9 -10
  236. data/src/core/lib/transport/timeout_encoding.c +11 -9
  237. data/src/core/lib/transport/timeout_encoding.h +3 -1
  238. data/src/core/lib/transport/transport.c +47 -87
  239. data/src/core/lib/transport/transport.h +20 -25
  240. data/src/core/lib/transport/transport_op_string.c +7 -19
  241. data/src/core/lib/tsi/fake_transport_security.c +2 -4
  242. data/src/core/lib/tsi/ssl_transport_security.c +7 -16
  243. data/src/core/lib/tsi/transport_security.c +2 -4
  244. data/src/ruby/ext/grpc/extconf.rb +4 -1
  245. data/src/ruby/ext/grpc/rb_byte_buffer.c +7 -0
  246. data/src/ruby/ext/grpc/rb_byte_buffer.h +3 -0
  247. data/src/ruby/ext/grpc/rb_call.c +47 -46
  248. data/src/ruby/ext/grpc/rb_channel.c +21 -6
  249. data/src/ruby/ext/grpc/rb_compression_options.c +9 -6
  250. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +36 -2
  251. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +59 -8
  252. data/src/ruby/ext/grpc/rb_server.c +6 -4
  253. data/src/ruby/lib/grpc/generic/client_stub.rb +1 -1
  254. data/src/ruby/lib/grpc/version.rb +1 -1
  255. metadata +33 -9
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  *
3
- * Copyright 2016, Google Inc.
3
+ * Copyright 2017, Google Inc.
4
4
  * All rights reserved.
5
5
  *
6
6
  * Redistribution and use in source and binary forms, with or without
@@ -31,11 +31,13 @@
31
31
  *
32
32
  */
33
33
  /* Automatically generated nanopb header */
34
- /* Generated by nanopb-0.3.5-dev */
34
+ /* Generated by nanopb-0.3.7-dev at Fri Jan 20 16:14:22 2017. */
35
35
 
36
36
  #ifndef GRPC_CORE_EXT_CENSUS_GEN_TRACE_CONTEXT_PB_H
37
37
  #define GRPC_CORE_EXT_CENSUS_GEN_TRACE_CONTEXT_PB_H
38
38
  #include "third_party/nanopb/pb.h"
39
+
40
+ /* @@protoc_insertion_point(includes) */
39
41
  #if PB_PROTO_HEADER_VERSION != 30
40
42
  #error Regenerate this file with the current version of nanopb generator.
41
43
  #endif
@@ -45,44 +47,35 @@ extern "C" {
45
47
  #endif
46
48
 
47
49
  /* Struct definitions */
48
- typedef struct _google_trace_TraceId {
49
- bool has_hi;
50
- uint64_t hi;
51
- bool has_lo;
52
- uint64_t lo;
53
- } google_trace_TraceId;
54
-
55
50
  typedef struct _google_trace_TraceContext {
56
- bool has_trace_id;
57
- google_trace_TraceId trace_id;
51
+ bool has_trace_id_hi;
52
+ uint64_t trace_id_hi;
53
+ bool has_trace_id_lo;
54
+ uint64_t trace_id_lo;
58
55
  bool has_span_id;
59
56
  uint64_t span_id;
60
- bool has_is_sampled;
61
- bool is_sampled;
57
+ bool has_span_options;
58
+ uint32_t span_options;
59
+ /* @@protoc_insertion_point(struct:google_trace_TraceContext) */
62
60
  } google_trace_TraceContext;
63
61
 
64
62
  /* Default values for struct fields */
65
63
 
66
64
  /* Initializer values for message structs */
67
- #define google_trace_TraceId_init_default {false, 0, false, 0}
68
- #define google_trace_TraceContext_init_default {false, google_trace_TraceId_init_default, false, 0, false, 0}
69
- #define google_trace_TraceId_init_zero {false, 0, false, 0}
70
- #define google_trace_TraceContext_init_zero {false, google_trace_TraceId_init_zero, false, 0, false, 0}
65
+ #define google_trace_TraceContext_init_default {false, 0, false, 0, false, 0, false, 0}
66
+ #define google_trace_TraceContext_init_zero {false, 0, false, 0, false, 0, false, 0}
71
67
 
72
68
  /* Field tags (for use in manual encoding/decoding) */
73
- #define google_trace_TraceId_hi_tag 1
74
- #define google_trace_TraceId_lo_tag 2
75
- #define google_trace_TraceContext_trace_id_tag 1
76
- #define google_trace_TraceContext_span_id_tag 2
77
- #define google_trace_TraceContext_is_sampled_tag 3
69
+ #define google_trace_TraceContext_trace_id_hi_tag 1
70
+ #define google_trace_TraceContext_trace_id_lo_tag 2
71
+ #define google_trace_TraceContext_span_id_tag 3
72
+ #define google_trace_TraceContext_span_options_tag 4
78
73
 
79
74
  /* Struct field encoding specification for nanopb */
80
- extern const pb_field_t google_trace_TraceId_fields[3];
81
- extern const pb_field_t google_trace_TraceContext_fields[4];
75
+ extern const pb_field_t google_trace_TraceContext_fields[5];
82
76
 
83
77
  /* Maximum encoded size of messages (where known) */
84
- #define google_trace_TraceId_size 18
85
- #define google_trace_TraceContext_size 31
78
+ #define google_trace_TraceContext_size 32
86
79
 
87
80
  /* Message IDs (where set with "msgid" option) */
88
81
  #ifdef PB_MSGID
@@ -95,5 +88,6 @@ extern const pb_field_t google_trace_TraceContext_fields[4];
95
88
  #ifdef __cplusplus
96
89
  } /* extern "C" */
97
90
  #endif
91
+ /* @@protoc_insertion_point(eof) */
98
92
 
99
93
  #endif
@@ -67,9 +67,7 @@ static void extract_and_annotate_method_tag(grpc_metadata_batch *md,
67
67
  channel_data *chand) {
68
68
  grpc_linked_mdelem *m;
69
69
  for (m = md->list.head; m != NULL; m = m->next) {
70
- if (m->md->key == GRPC_MDSTR_PATH) {
71
- gpr_log(GPR_DEBUG, "%s",
72
- (const char *)GRPC_SLICE_START_PTR(m->md->value->slice));
70
+ if (grpc_slice_eq(GRPC_MDKEY(m->md), GRPC_MDSTR_PATH)) {
73
71
  /* Add method tag here */
74
72
  }
75
73
  }
@@ -129,7 +127,7 @@ static void server_start_transport_op(grpc_exec_ctx *exec_ctx,
129
127
 
130
128
  static grpc_error *client_init_call_elem(grpc_exec_ctx *exec_ctx,
131
129
  grpc_call_element *elem,
132
- grpc_call_element_args *args) {
130
+ const grpc_call_element_args *args) {
133
131
  call_data *d = elem->call_data;
134
132
  GPR_ASSERT(d != NULL);
135
133
  memset(d, 0, sizeof(*d));
@@ -148,7 +146,7 @@ static void client_destroy_call_elem(grpc_exec_ctx *exec_ctx,
148
146
 
149
147
  static grpc_error *server_init_call_elem(grpc_exec_ctx *exec_ctx,
150
148
  grpc_call_element *elem,
151
- grpc_call_element_args *args) {
149
+ const grpc_call_element_args *args) {
152
150
  call_data *d = elem->call_data;
153
151
  GPR_ASSERT(d != NULL);
154
152
  memset(d, 0, sizeof(*d));
@@ -73,7 +73,7 @@ bool decode_trace_context(google_trace_TraceContext *ctxt, uint8_t *buffer,
73
73
  }
74
74
 
75
75
  // check fields
76
- if (!ctxt->has_trace_id) {
76
+ if (!ctxt->has_trace_id_hi || !ctxt->has_trace_id_lo) {
77
77
  gpr_log(GPR_DEBUG, "Invalid TraceContext: missing trace_id");
78
78
  return false;
79
79
  }
@@ -38,6 +38,9 @@
38
38
 
39
39
  #include "src/core/ext/census/gen/trace_context.pb.h"
40
40
 
41
+ /* Span option flags. */
42
+ #define SPAN_OPTIONS_IS_SAMPLED 0x01
43
+
41
44
  /* Maximum number of bytes required to encode a TraceContext (31)
42
45
  1 byte for trace_id field
43
46
  1 byte for trace_id length
@@ -0,0 +1,61 @@
1
+ /*
2
+ *
3
+ * Copyright 2016, Google Inc.
4
+ * All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions are
8
+ * met:
9
+ *
10
+ * * Redistributions of source code must retain the above copyright
11
+ * notice, this list of conditions and the following disclaimer.
12
+ * * Redistributions in binary form must reproduce the above
13
+ * copyright notice, this list of conditions and the following disclaimer
14
+ * in the documentation and/or other materials provided with the
15
+ * distribution.
16
+ * * Neither the name of Google Inc. nor the names of its
17
+ * contributors may be used to endorse or promote products derived from
18
+ * this software without specific prior written permission.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ *
32
+ */
33
+
34
+ #ifndef GRPC_CORE_EXT_CENSUS_TRACE_LABEL_H
35
+ #define GRPC_CORE_EXT_CENSUS_TRACE_LABEL_H
36
+
37
+ #include "src/core/ext/census/trace_string.h"
38
+
39
+ /* Trace label (key/value pair) stores a label name and the label value. The
40
+ value can be one of trace_string/int64_t/bool. */
41
+ typedef struct trace_label {
42
+ trace_string key;
43
+ enum label_type {
44
+ /* Unknown value for debugging/error purposes */
45
+ LABEL_UNKNOWN = 0,
46
+ /* A string value */
47
+ LABEL_STRING = 1,
48
+ /* An integer value. */
49
+ LABEL_INT = 2,
50
+ /* A boolean value. */
51
+ LABEL_BOOL = 3,
52
+ } value_type;
53
+
54
+ union value {
55
+ trace_string label_str;
56
+ int64_t label_int;
57
+ bool label_bool;
58
+ } value;
59
+ } trace_label;
60
+
61
+ #endif
@@ -0,0 +1,63 @@
1
+ /*
2
+ *
3
+ * Copyright 2016, Google Inc.
4
+ * All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions are
8
+ * met:
9
+ *
10
+ * * Redistributions of source code must retain the above copyright
11
+ * notice, this list of conditions and the following disclaimer.
12
+ * * Redistributions in binary form must reproduce the above
13
+ * copyright notice, this list of conditions and the following disclaimer
14
+ * in the documentation and/or other materials provided with the
15
+ * distribution.
16
+ * * Neither the name of Google Inc. nor the names of its
17
+ * contributors may be used to endorse or promote products derived from
18
+ * this software without specific prior written permission.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ *
32
+ */
33
+
34
+ #ifndef GRPC_CORE_EXT_CENSUS_TRACE_PROPAGATION_H
35
+ #define GRPC_CORE_EXT_CENSUS_TRACE_PROPAGATION_H
36
+
37
+ #include "src/core/ext/census/tracing.h"
38
+
39
+ /* Encoding and decoding functions for receiving and sending trace contexts
40
+ over the wire. Only RPC libraries should be calling these
41
+ functions. These functions return the number of bytes encoded/decoded
42
+ (0 if a failure has occurred). buf_size indicates the size of the
43
+ input/output buffer. trace_span_context is a struct that includes the
44
+ trace ID, span ID, and a set of option flags (is_sampled, etc.). */
45
+
46
+ /* Converts a span context to a binary byte buffer. */
47
+ size_t trace_span_context_to_binary(const trace_span_context *ctxt,
48
+ uint8_t *buf, size_t buf_size);
49
+
50
+ /* Reads a binary byte buffer and populates a span context structure. */
51
+ size_t binary_to_trace_span_context(const uint8_t *buf, size_t buf_size,
52
+ trace_span_context *ctxt);
53
+
54
+ /* Converts a span context to an http metadata compatible string. */
55
+ size_t trace_span_context_to_http_format(const trace_span_context *ctxt,
56
+ char *buf, size_t buf_size);
57
+
58
+ /* Reads an http metadata compatible string and populates a span context
59
+ structure. */
60
+ size_t http_format_to_trace_span_context(const char *buf, size_t buf_size,
61
+ trace_span_context *ctxt);
62
+
63
+ #endif
@@ -0,0 +1,45 @@
1
+ /*
2
+ *
3
+ * Copyright 2016, Google Inc.
4
+ * All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions are
8
+ * met:
9
+ *
10
+ * * Redistributions of source code must retain the above copyright
11
+ * notice, this list of conditions and the following disclaimer.
12
+ * * Redistributions in binary form must reproduce the above
13
+ * copyright notice, this list of conditions and the following disclaimer
14
+ * in the documentation and/or other materials provided with the
15
+ * distribution.
16
+ * * Neither the name of Google Inc. nor the names of its
17
+ * contributors may be used to endorse or promote products derived from
18
+ * this software without specific prior written permission.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ *
32
+ */
33
+
34
+ #ifndef GRPC_CORE_EXT_CENSUS_TRACE_STATUS_H
35
+ #define GRPC_CORE_EXT_CENSUS_TRACE_STATUS_H
36
+
37
+ #include "src/core/ext/census/trace_string.h"
38
+
39
+ /* Stores a status code and status message for a trace. */
40
+ typedef struct trace_status {
41
+ int64_t errorCode;
42
+ trace_string errorMessage;
43
+ } trace_status;
44
+
45
+ #endif
@@ -0,0 +1,50 @@
1
+ /*
2
+ *
3
+ * Copyright 2016, Google Inc.
4
+ * All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions are
8
+ * met:
9
+ *
10
+ * * Redistributions of source code must retain the above copyright
11
+ * notice, this list of conditions and the following disclaimer.
12
+ * * Redistributions in binary form must reproduce the above
13
+ * copyright notice, this list of conditions and the following disclaimer
14
+ * in the documentation and/or other materials provided with the
15
+ * distribution.
16
+ * * Neither the name of Google Inc. nor the names of its
17
+ * contributors may be used to endorse or promote products derived from
18
+ * this software without specific prior written permission.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ *
32
+ */
33
+
34
+ #ifndef GRPC_CORE_EXT_CENSUS_TRACE_STRING_H
35
+ #define GRPC_CORE_EXT_CENSUS_TRACE_STRING_H
36
+
37
+ #include <grpc/slice.h>
38
+
39
+ /* String struct for tracing messages. Since this is a C API, we do not have
40
+ access to a string class. This is intended for use by higher level
41
+ languages which wrap around the C API, as most of them have a string class.
42
+ This will also be more efficient when copying, as we have an explicitly
43
+ specified length. Also, grpc_slice has reference counting which allows for
44
+ interning. */
45
+ typedef struct trace_string {
46
+ char *string;
47
+ size_t length;
48
+ } trace_string;
49
+
50
+ #endif
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  *
3
- * Copyright 2015, Google Inc.
3
+ * Copyright 2016, Google Inc.
4
4
  * All rights reserved.
5
5
  *
6
6
  * Redistribution and use in source and binary forms, with or without
@@ -31,21 +31,41 @@
31
31
  *
32
32
  */
33
33
 
34
- //#include "src/core/ext/census/tracing.h"
34
+ #include "src/core/ext/census/tracing.h"
35
35
 
36
36
  #include <grpc/census.h>
37
- #include <stdlib.h>
37
+ #include <grpc/support/alloc.h>
38
+ #include <grpc/support/log.h>
39
+ #include <openssl/rand.h>
40
+ #include "src/core/ext/census/mlog.h"
38
41
 
39
- /* TODO(aveitch): These are all placeholder implementations. */
42
+ void trace_start_span(const trace_span_context *span_ctxt,
43
+ const trace_string name, const start_span_options *opts,
44
+ trace_span_context *new_span_ctxt,
45
+ bool has_remote_parent) {
46
+ // Noop implementation.
47
+ }
48
+
49
+ void trace_add_span_annotation(const trace_string description,
50
+ const trace_label *labels, const size_t n_labels,
51
+ trace_span_context *span_ctxt) {
52
+ // Noop implementation.
53
+ }
40
54
 
41
- int census_trace_mask(const census_context *context) {
42
- abort();
43
- return CENSUS_TRACE_MASK_NONE;
55
+ void trace_add_span_network_event_annotation(const trace_string description,
56
+ const trace_label *labels,
57
+ const size_t n_labels,
58
+ const gpr_timespec timestamp,
59
+ bool sent, uint64_t id,
60
+ trace_span_context *span_ctxt) {
61
+ // Noop implementation.
44
62
  }
45
63
 
46
- void census_set_trace_mask(int trace_mask) { abort(); }
64
+ void trace_add_span_labels(const trace_label *labels, const size_t n_labels,
65
+ trace_span_context *span_ctxt) {
66
+ // Noop implementation.
67
+ }
47
68
 
48
- void census_trace_print(census_context *context, uint32_t type,
49
- const char *buffer, size_t n) {
50
- abort();
69
+ void trace_end_span(const trace_status *status, trace_span_context *span_ctxt) {
70
+ // Noop implementation.
51
71
  }
@@ -0,0 +1,124 @@
1
+ /*
2
+ *
3
+ * Copyright 2016, Google Inc.
4
+ * All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions are
8
+ * met:
9
+ *
10
+ * * Redistributions of source code must retain the above copyright
11
+ * notice, this list of conditions and the following disclaimer.
12
+ * * Redistributions in binary form must reproduce the above
13
+ * copyright notice, this list of conditions and the following disclaimer
14
+ * in the documentation and/or other materials provided with the
15
+ * distribution.
16
+ * * Neither the name of Google Inc. nor the names of its
17
+ * contributors may be used to endorse or promote products derived from
18
+ * this software without specific prior written permission.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ *
32
+ */
33
+
34
+ #ifndef GRPC_CORE_EXT_CENSUS_TRACING_H
35
+ #define GRPC_CORE_EXT_CENSUS_TRACING_H
36
+
37
+ #include <grpc/support/time.h>
38
+ #include <stdbool.h>
39
+ #include "src/core/ext/census/trace_context.h"
40
+ #include "src/core/ext/census/trace_label.h"
41
+ #include "src/core/ext/census/trace_status.h"
42
+
43
+ /* This is the low level tracing API that other languages will interface with.
44
+ This is not intended to be accessed by the end-user, therefore it has been
45
+ designed with performance in mind rather than ease of use. */
46
+
47
+ /* The tracing level. */
48
+ enum TraceLevel {
49
+ /* Annotations on this context will be silently discarded. */
50
+ NO_TRACING = 0,
51
+ /* Annotations will not be saved to a persistent store. They will be
52
+ available via local APIs only. This setting is not propagated to child
53
+ spans. */
54
+ TRANSIENT_TRACING = 1,
55
+ /* Annotations are recorded for the entire distributed trace and they are
56
+ saved to a persistent store. This setting is propagated to child spans. */
57
+ PERSISTENT_TRACING = 2,
58
+ };
59
+
60
+ typedef struct trace_span_context {
61
+ /* Trace span context stores Span ID, Trace ID, and option flags. */
62
+ /* Trace ID is 128 bits split into 2 64-bit chunks (hi and lo). */
63
+ uint64_t trace_id_hi;
64
+ uint64_t trace_id_lo;
65
+ /* Span ID is 64 bits. */
66
+ uint64_t span_id;
67
+ /* Span-options is 32-bit value which contains flag options. */
68
+ uint32_t span_options;
69
+ } trace_span_context;
70
+
71
+ typedef struct start_span_options {
72
+ /* If set, this will override the Span.local_start_time for the Span. */
73
+ gpr_timespec local_start_timestamp;
74
+
75
+ /* Linked spans can be used to identify spans that are linked to this span in
76
+ a different trace. This can be used (for example) in batching operations,
77
+ where a single batch handler processes multiple requests from different
78
+ traces. If set, points to a list of Spans are linked to the created Span.*/
79
+ trace_span_context *linked_spans;
80
+ /* The number of linked spans. */
81
+ size_t n_linked_spans;
82
+ } start_span_options;
83
+
84
+ /* Create a new child Span (or root if parent is NULL), with parent being the
85
+ designated Span. The child span will have the provided name and starting
86
+ span options (optional). The bool has_remote_parent marks whether the
87
+ context refers to a remote parent span or not. */
88
+ void trace_start_span(const trace_span_context *span_ctxt,
89
+ const trace_string name, const start_span_options *opts,
90
+ trace_span_context *new_span_ctxt,
91
+ bool has_remote_parent);
92
+
93
+ /* Add a new Annotation to the Span. Annotations consist of a description
94
+ (trace_string) and a set of n labels (trace_label). This can be populated
95
+ with arbitrary user data. */
96
+ void trace_add_span_annotation(const trace_string description,
97
+ const trace_label *labels, const size_t n_labels,
98
+ trace_span_context *span_ctxt);
99
+
100
+ /* Add a new NetworkEvent annotation to a Span. This function is only intended
101
+ to be used by RPC systems (either client or server), not by higher level
102
+ applications. The timestamp type will be system-defined, the sent argument
103
+ designates whether this is a network send event (client request, server
104
+ reply)or receive (server request, client reply). The id argument corresponds
105
+ to Span.Annotation.NetworkEvent.id from the data model, and serves to uniquely
106
+ identify each network message. */
107
+ void trace_add_span_network_event(const trace_string description,
108
+ const trace_label *labels,
109
+ const size_t n_labels,
110
+ const gpr_timespec timestamp, bool sent,
111
+ uint64_t id, trace_span_context *span_ctxt);
112
+
113
+ /* Add a set of labels to the Span. These will correspond to the field
114
+ Span.labels in the data model. */
115
+ void trace_add_span_labels(const trace_label *labels, const size_t n_labels,
116
+ trace_span_context *span_ctxt);
117
+
118
+ /* Mark the end of Span Execution with the given status. Only the timing of the
119
+ first EndSpan call for a given Span will be recorded, and implementations are
120
+ free to ignore all further calls using the Span. EndSpanOptions can
121
+ optionally be NULL. */
122
+ void trace_end_span(const trace_status *status, trace_span_context *span_ctxt);
123
+
124
+ #endif