Address comments: revert all changes except adding two new metadata keys

"census" and "census-bin"
pull/4274/head
Hongyu Chen 9 years ago
parent 1fa931c374
commit 134cac2004
  1. 10
      include/grpc++/client_context.h
  2. 3
      include/grpc++/server_context.h
  3. 8
      include/grpc/census.h
  4. 4
      src/core/census/context.c
  5. 6
      src/core/census/context.h
  6. 21
      src/core/transport/static_metadata.c
  7. 136
      src/core/transport/static_metadata.h
  8. 3
      tools/codegen/core/gen_static_metadata.py

@ -37,6 +37,7 @@
/// side.
/// - Control call settings such as compression and authentication.
/// - Initial and trailing metadata coming from the server.
/// - Get performace metrics (ie, census).
///
/// Context settings are only relevant to the call they are invoked with, that
/// is to say, they aren't sticky. Some of these settings, such as the
@ -63,6 +64,8 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
struct census_context;
namespace grpc {
class Channel;
@ -265,6 +268,12 @@ class ClientContext {
/// \return The call's peer URI.
grpc::string peer() const;
/// Get and set census context.
void set_census_context(struct census_context* ccp) { census_context_ = ccp; }
struct census_context* census_context() const {
return census_context_;
}
/// Send a best-effort out-of-band cancel. The call could be in any stage.
/// e.g. if it is already finished, it may still return success.
///
@ -314,6 +323,7 @@ class ClientContext {
grpc::string authority_;
std::shared_ptr<CallCredentials> creds_;
mutable std::shared_ptr<const AuthContext> auth_context_;
struct census_context* census_context_;
std::multimap<grpc::string, grpc::string> send_initial_metadata_;
std::multimap<grpc::string_ref, grpc::string_ref> recv_initial_metadata_;
std::multimap<grpc::string_ref, grpc::string_ref> trailing_metadata_;

@ -47,6 +47,7 @@
struct gpr_timespec;
struct grpc_metadata;
struct grpc_call;
struct census_context;
namespace grpc {
@ -125,6 +126,8 @@ class ServerContext {
// functionality. Instead, use auth_context.
grpc::string peer() const;
const struct census_context* census_context() const;
// Async only. Has to be called before the rpc starts.
// Returns the tag in completion queue when the rpc finishes.
// IsCancelled() can then be called to check whether the rpc was cancelled.

@ -79,14 +79,6 @@ int census_enabled(void);
*/
typedef struct census_context census_context;
/**
Returns the census_context of the current thread, creating one if necessary.
The object pointed to by the returned pointer is thread local, and thus may
be read without concurrency concerns, but should not be shared with other
threads.
*/
census_context* census_context_current();
/* This function is called by the RPC subsystem whenever it needs to get a
* serialized form of the current census context (presumably to pass across
* the wire). Arguments:

@ -39,10 +39,6 @@
/* Placeholder implementation only. */
census_context* census_context_current(void) {
return NULL;
}
size_t census_context_serialize(const census_context *context, char *buffer,
size_t buf_size) {
/* TODO(aveitch): implement serialization */

@ -36,14 +36,12 @@
#include <grpc/census.h>
#define GRPC_CENSUS_MAX_ON_THE_WIRE_TAG_BYTES 8 * 1024
#define GRPC_CENSUS_MAX_ON_THE_WIRE_TAG_BYTES 4096
/* census_context is the in-memory representation of information needed to
* maintain tracing, RPC statistics and resource usage information. */
struct census_context {
gpr_uint64 op_id; /* Operation identifier - unique per-context */
gpr_uint64 trace_id; /* Globally unique trace identifier */
void* tags; /* Opaque data structure for Census tags. */
census_tag_set* tags; /* Opaque data structure for census tags. */
};
#endif /* GRPC_INTERNAL_CORE_CENSUS_CONTEXT_H */

@ -54,15 +54,15 @@ gpr_uintptr grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] = {
const gpr_uint8
grpc_static_metadata_elem_indices[GRPC_STATIC_MDELEM_COUNT * 2] = {
11, 34, 10, 34, 12, 34, 12, 48, 13, 34, 14, 34, 15, 34, 16, 34, 17, 34,
19, 34, 20, 34, 21, 34, 23, 34, 24, 34, 25, 34, 26, 34, 27, 34, 28, 34,
29, 18, 29, 34, 30, 34, 31, 34, 35, 34, 36, 34, 37, 34, 38, 34, 41, 32,
41, 33, 41, 47, 41, 52, 41, 53, 41, 54, 41, 55, 42, 32, 42, 47, 42, 52,
45, 0, 45, 1, 45, 2, 49, 34, 56, 34, 57, 34, 58, 34, 59, 34, 60, 34,
61, 34, 62, 34, 63, 34, 64, 34, 65, 39, 65, 67, 66, 77, 66, 78, 68, 34,
69, 34, 70, 34, 71, 34, 72, 34, 73, 34, 74, 40, 74, 50, 74, 51, 75, 34,
76, 34, 79, 3, 79, 4, 79, 5, 79, 6, 79, 7, 79, 8, 79, 9, 80, 34,
81, 82, 83, 34, 84, 34, 85, 34, 86, 34, 87, 34};
11, 35, 10, 35, 12, 35, 12, 49, 13, 35, 14, 35, 15, 35, 16, 35, 17, 35,
19, 35, 20, 35, 21, 35, 24, 35, 25, 35, 26, 35, 27, 35, 28, 35, 29, 35,
30, 18, 30, 35, 31, 35, 32, 35, 36, 35, 37, 35, 38, 35, 39, 35, 42, 33,
42, 34, 42, 48, 42, 53, 42, 54, 42, 55, 42, 56, 43, 33, 43, 48, 43, 53,
46, 0, 46, 1, 46, 2, 50, 35, 57, 35, 58, 35, 59, 35, 60, 35, 61, 35,
62, 35, 63, 35, 64, 35, 65, 35, 66, 40, 66, 68, 67, 78, 67, 79, 69, 35,
70, 35, 71, 35, 72, 35, 73, 35, 74, 35, 75, 41, 75, 51, 75, 52, 76, 35,
77, 35, 80, 3, 80, 4, 80, 5, 80, 6, 80, 7, 80, 8, 80, 9, 81, 35,
82, 83, 84, 35, 85, 35, 86, 35, 87, 35, 88, 35};
const char *const grpc_static_metadata_strings[GRPC_STATIC_MDSTR_COUNT] = {
"0",
@ -87,7 +87,8 @@ const char *const grpc_static_metadata_strings[GRPC_STATIC_MDSTR_COUNT] = {
":authority",
"authorization",
"cache-control",
":census",
"census",
"census-bin",
"content-disposition",
"content-encoding",
"content-language",

@ -46,7 +46,7 @@
#include "src/core/transport/metadata.h"
#define GRPC_STATIC_MDSTR_COUNT 88
#define GRPC_STATIC_MDSTR_COUNT 89
extern grpc_mdstr grpc_static_mdstr_table[GRPC_STATIC_MDSTR_COUNT];
/* "0" */
#define GRPC_MDSTR_0 (&grpc_static_mdstr_table[0])
@ -92,139 +92,141 @@ extern grpc_mdstr grpc_static_mdstr_table[GRPC_STATIC_MDSTR_COUNT];
#define GRPC_MDSTR_AUTHORIZATION (&grpc_static_mdstr_table[20])
/* "cache-control" */
#define GRPC_MDSTR_CACHE_CONTROL (&grpc_static_mdstr_table[21])
/* ":census" */
/* "census" */
#define GRPC_MDSTR_CENSUS (&grpc_static_mdstr_table[22])
/* "census-bin" */
#define GRPC_MDSTR_CENSUS_BIN (&grpc_static_mdstr_table[23])
/* "content-disposition" */
#define GRPC_MDSTR_CONTENT_DISPOSITION (&grpc_static_mdstr_table[23])
#define GRPC_MDSTR_CONTENT_DISPOSITION (&grpc_static_mdstr_table[24])
/* "content-encoding" */
#define GRPC_MDSTR_CONTENT_ENCODING (&grpc_static_mdstr_table[24])
#define GRPC_MDSTR_CONTENT_ENCODING (&grpc_static_mdstr_table[25])
/* "content-language" */
#define GRPC_MDSTR_CONTENT_LANGUAGE (&grpc_static_mdstr_table[25])
#define GRPC_MDSTR_CONTENT_LANGUAGE (&grpc_static_mdstr_table[26])
/* "content-length" */
#define GRPC_MDSTR_CONTENT_LENGTH (&grpc_static_mdstr_table[26])
#define GRPC_MDSTR_CONTENT_LENGTH (&grpc_static_mdstr_table[27])
/* "content-location" */
#define GRPC_MDSTR_CONTENT_LOCATION (&grpc_static_mdstr_table[27])
#define GRPC_MDSTR_CONTENT_LOCATION (&grpc_static_mdstr_table[28])
/* "content-range" */
#define GRPC_MDSTR_CONTENT_RANGE (&grpc_static_mdstr_table[28])
#define GRPC_MDSTR_CONTENT_RANGE (&grpc_static_mdstr_table[29])
/* "content-type" */
#define GRPC_MDSTR_CONTENT_TYPE (&grpc_static_mdstr_table[29])
#define GRPC_MDSTR_CONTENT_TYPE (&grpc_static_mdstr_table[30])
/* "cookie" */
#define GRPC_MDSTR_COOKIE (&grpc_static_mdstr_table[30])
#define GRPC_MDSTR_COOKIE (&grpc_static_mdstr_table[31])
/* "date" */
#define GRPC_MDSTR_DATE (&grpc_static_mdstr_table[31])
#define GRPC_MDSTR_DATE (&grpc_static_mdstr_table[32])
/* "deflate" */
#define GRPC_MDSTR_DEFLATE (&grpc_static_mdstr_table[32])
#define GRPC_MDSTR_DEFLATE (&grpc_static_mdstr_table[33])
/* "deflate,gzip" */
#define GRPC_MDSTR_DEFLATE_COMMA_GZIP (&grpc_static_mdstr_table[33])
#define GRPC_MDSTR_DEFLATE_COMMA_GZIP (&grpc_static_mdstr_table[34])
/* "" */
#define GRPC_MDSTR_EMPTY (&grpc_static_mdstr_table[34])
#define GRPC_MDSTR_EMPTY (&grpc_static_mdstr_table[35])
/* "etag" */
#define GRPC_MDSTR_ETAG (&grpc_static_mdstr_table[35])
#define GRPC_MDSTR_ETAG (&grpc_static_mdstr_table[36])
/* "expect" */
#define GRPC_MDSTR_EXPECT (&grpc_static_mdstr_table[36])
#define GRPC_MDSTR_EXPECT (&grpc_static_mdstr_table[37])
/* "expires" */
#define GRPC_MDSTR_EXPIRES (&grpc_static_mdstr_table[37])
#define GRPC_MDSTR_EXPIRES (&grpc_static_mdstr_table[38])
/* "from" */
#define GRPC_MDSTR_FROM (&grpc_static_mdstr_table[38])
#define GRPC_MDSTR_FROM (&grpc_static_mdstr_table[39])
/* "GET" */
#define GRPC_MDSTR_GET (&grpc_static_mdstr_table[39])
#define GRPC_MDSTR_GET (&grpc_static_mdstr_table[40])
/* "grpc" */
#define GRPC_MDSTR_GRPC (&grpc_static_mdstr_table[40])
#define GRPC_MDSTR_GRPC (&grpc_static_mdstr_table[41])
/* "grpc-accept-encoding" */
#define GRPC_MDSTR_GRPC_ACCEPT_ENCODING (&grpc_static_mdstr_table[41])
#define GRPC_MDSTR_GRPC_ACCEPT_ENCODING (&grpc_static_mdstr_table[42])
/* "grpc-encoding" */
#define GRPC_MDSTR_GRPC_ENCODING (&grpc_static_mdstr_table[42])
#define GRPC_MDSTR_GRPC_ENCODING (&grpc_static_mdstr_table[43])
/* "grpc-internal-encoding-request" */
#define GRPC_MDSTR_GRPC_INTERNAL_ENCODING_REQUEST (&grpc_static_mdstr_table[43])
#define GRPC_MDSTR_GRPC_INTERNAL_ENCODING_REQUEST (&grpc_static_mdstr_table[44])
/* "grpc-message" */
#define GRPC_MDSTR_GRPC_MESSAGE (&grpc_static_mdstr_table[44])
#define GRPC_MDSTR_GRPC_MESSAGE (&grpc_static_mdstr_table[45])
/* "grpc-status" */
#define GRPC_MDSTR_GRPC_STATUS (&grpc_static_mdstr_table[45])
#define GRPC_MDSTR_GRPC_STATUS (&grpc_static_mdstr_table[46])
/* "grpc-timeout" */
#define GRPC_MDSTR_GRPC_TIMEOUT (&grpc_static_mdstr_table[46])
#define GRPC_MDSTR_GRPC_TIMEOUT (&grpc_static_mdstr_table[47])
/* "gzip" */
#define GRPC_MDSTR_GZIP (&grpc_static_mdstr_table[47])
#define GRPC_MDSTR_GZIP (&grpc_static_mdstr_table[48])
/* "gzip, deflate" */
#define GRPC_MDSTR_GZIP_COMMA_DEFLATE (&grpc_static_mdstr_table[48])
#define GRPC_MDSTR_GZIP_COMMA_DEFLATE (&grpc_static_mdstr_table[49])
/* "host" */
#define GRPC_MDSTR_HOST (&grpc_static_mdstr_table[49])
#define GRPC_MDSTR_HOST (&grpc_static_mdstr_table[50])
/* "http" */
#define GRPC_MDSTR_HTTP (&grpc_static_mdstr_table[50])
#define GRPC_MDSTR_HTTP (&grpc_static_mdstr_table[51])
/* "https" */
#define GRPC_MDSTR_HTTPS (&grpc_static_mdstr_table[51])
#define GRPC_MDSTR_HTTPS (&grpc_static_mdstr_table[52])
/* "identity" */
#define GRPC_MDSTR_IDENTITY (&grpc_static_mdstr_table[52])
#define GRPC_MDSTR_IDENTITY (&grpc_static_mdstr_table[53])
/* "identity,deflate" */
#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE (&grpc_static_mdstr_table[53])
#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE (&grpc_static_mdstr_table[54])
/* "identity,deflate,gzip" */
#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE_COMMA_GZIP \
(&grpc_static_mdstr_table[54])
(&grpc_static_mdstr_table[55])
/* "identity,gzip" */
#define GRPC_MDSTR_IDENTITY_COMMA_GZIP (&grpc_static_mdstr_table[55])
#define GRPC_MDSTR_IDENTITY_COMMA_GZIP (&grpc_static_mdstr_table[56])
/* "if-match" */
#define GRPC_MDSTR_IF_MATCH (&grpc_static_mdstr_table[56])
#define GRPC_MDSTR_IF_MATCH (&grpc_static_mdstr_table[57])
/* "if-modified-since" */
#define GRPC_MDSTR_IF_MODIFIED_SINCE (&grpc_static_mdstr_table[57])
#define GRPC_MDSTR_IF_MODIFIED_SINCE (&grpc_static_mdstr_table[58])
/* "if-none-match" */
#define GRPC_MDSTR_IF_NONE_MATCH (&grpc_static_mdstr_table[58])
#define GRPC_MDSTR_IF_NONE_MATCH (&grpc_static_mdstr_table[59])
/* "if-range" */
#define GRPC_MDSTR_IF_RANGE (&grpc_static_mdstr_table[59])
#define GRPC_MDSTR_IF_RANGE (&grpc_static_mdstr_table[60])
/* "if-unmodified-since" */
#define GRPC_MDSTR_IF_UNMODIFIED_SINCE (&grpc_static_mdstr_table[60])
#define GRPC_MDSTR_IF_UNMODIFIED_SINCE (&grpc_static_mdstr_table[61])
/* "last-modified" */
#define GRPC_MDSTR_LAST_MODIFIED (&grpc_static_mdstr_table[61])
#define GRPC_MDSTR_LAST_MODIFIED (&grpc_static_mdstr_table[62])
/* "link" */
#define GRPC_MDSTR_LINK (&grpc_static_mdstr_table[62])
#define GRPC_MDSTR_LINK (&grpc_static_mdstr_table[63])
/* "location" */
#define GRPC_MDSTR_LOCATION (&grpc_static_mdstr_table[63])
#define GRPC_MDSTR_LOCATION (&grpc_static_mdstr_table[64])
/* "max-forwards" */
#define GRPC_MDSTR_MAX_FORWARDS (&grpc_static_mdstr_table[64])
#define GRPC_MDSTR_MAX_FORWARDS (&grpc_static_mdstr_table[65])
/* ":method" */
#define GRPC_MDSTR_METHOD (&grpc_static_mdstr_table[65])
#define GRPC_MDSTR_METHOD (&grpc_static_mdstr_table[66])
/* ":path" */
#define GRPC_MDSTR_PATH (&grpc_static_mdstr_table[66])
#define GRPC_MDSTR_PATH (&grpc_static_mdstr_table[67])
/* "POST" */
#define GRPC_MDSTR_POST (&grpc_static_mdstr_table[67])
#define GRPC_MDSTR_POST (&grpc_static_mdstr_table[68])
/* "proxy-authenticate" */
#define GRPC_MDSTR_PROXY_AUTHENTICATE (&grpc_static_mdstr_table[68])
#define GRPC_MDSTR_PROXY_AUTHENTICATE (&grpc_static_mdstr_table[69])
/* "proxy-authorization" */
#define GRPC_MDSTR_PROXY_AUTHORIZATION (&grpc_static_mdstr_table[69])
#define GRPC_MDSTR_PROXY_AUTHORIZATION (&grpc_static_mdstr_table[70])
/* "range" */
#define GRPC_MDSTR_RANGE (&grpc_static_mdstr_table[70])
#define GRPC_MDSTR_RANGE (&grpc_static_mdstr_table[71])
/* "referer" */
#define GRPC_MDSTR_REFERER (&grpc_static_mdstr_table[71])
#define GRPC_MDSTR_REFERER (&grpc_static_mdstr_table[72])
/* "refresh" */
#define GRPC_MDSTR_REFRESH (&grpc_static_mdstr_table[72])
#define GRPC_MDSTR_REFRESH (&grpc_static_mdstr_table[73])
/* "retry-after" */
#define GRPC_MDSTR_RETRY_AFTER (&grpc_static_mdstr_table[73])
#define GRPC_MDSTR_RETRY_AFTER (&grpc_static_mdstr_table[74])
/* ":scheme" */
#define GRPC_MDSTR_SCHEME (&grpc_static_mdstr_table[74])
#define GRPC_MDSTR_SCHEME (&grpc_static_mdstr_table[75])
/* "server" */
#define GRPC_MDSTR_SERVER (&grpc_static_mdstr_table[75])
#define GRPC_MDSTR_SERVER (&grpc_static_mdstr_table[76])
/* "set-cookie" */
#define GRPC_MDSTR_SET_COOKIE (&grpc_static_mdstr_table[76])
#define GRPC_MDSTR_SET_COOKIE (&grpc_static_mdstr_table[77])
/* "/" */
#define GRPC_MDSTR_SLASH (&grpc_static_mdstr_table[77])
#define GRPC_MDSTR_SLASH (&grpc_static_mdstr_table[78])
/* "/index.html" */
#define GRPC_MDSTR_SLASH_INDEX_DOT_HTML (&grpc_static_mdstr_table[78])
#define GRPC_MDSTR_SLASH_INDEX_DOT_HTML (&grpc_static_mdstr_table[79])
/* ":status" */
#define GRPC_MDSTR_STATUS (&grpc_static_mdstr_table[79])
#define GRPC_MDSTR_STATUS (&grpc_static_mdstr_table[80])
/* "strict-transport-security" */
#define GRPC_MDSTR_STRICT_TRANSPORT_SECURITY (&grpc_static_mdstr_table[80])
#define GRPC_MDSTR_STRICT_TRANSPORT_SECURITY (&grpc_static_mdstr_table[81])
/* "te" */
#define GRPC_MDSTR_TE (&grpc_static_mdstr_table[81])
#define GRPC_MDSTR_TE (&grpc_static_mdstr_table[82])
/* "trailers" */
#define GRPC_MDSTR_TRAILERS (&grpc_static_mdstr_table[82])
#define GRPC_MDSTR_TRAILERS (&grpc_static_mdstr_table[83])
/* "transfer-encoding" */
#define GRPC_MDSTR_TRANSFER_ENCODING (&grpc_static_mdstr_table[83])
#define GRPC_MDSTR_TRANSFER_ENCODING (&grpc_static_mdstr_table[84])
/* "user-agent" */
#define GRPC_MDSTR_USER_AGENT (&grpc_static_mdstr_table[84])
#define GRPC_MDSTR_USER_AGENT (&grpc_static_mdstr_table[85])
/* "vary" */
#define GRPC_MDSTR_VARY (&grpc_static_mdstr_table[85])
#define GRPC_MDSTR_VARY (&grpc_static_mdstr_table[86])
/* "via" */
#define GRPC_MDSTR_VIA (&grpc_static_mdstr_table[86])
#define GRPC_MDSTR_VIA (&grpc_static_mdstr_table[87])
/* "www-authenticate" */
#define GRPC_MDSTR_WWW_AUTHENTICATE (&grpc_static_mdstr_table[87])
#define GRPC_MDSTR_WWW_AUTHENTICATE (&grpc_static_mdstr_table[88])
#define GRPC_STATIC_MDELEM_COUNT 78
extern grpc_mdelem grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT];

@ -50,7 +50,8 @@ CONFIG = [
'host',
'grpc-message',
'grpc-status',
':census',
'census',
'census-bin',
'',
('grpc-status', '0'),
('grpc-status', '1'),

Loading…
Cancel
Save