mirror of https://github.com/grpc/grpc.git
parent
ad654aca5e
commit
9686dabd04
22 changed files with 527 additions and 804 deletions
@ -0,0 +1,91 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2015, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
/* RPC-internal Census API's. These are designed to be generic enough that
|
||||
* they can (ultimately) be used in many different RPC systems (with differing |
||||
* implementations). */ |
||||
|
||||
#ifndef CENSUS_CENSUS_H |
||||
#define CENSUS_CENSUS_H |
||||
|
||||
#include <grpc/grpc.h> |
||||
#include <grpc/support/slice_buffer.h> |
||||
|
||||
/* Identify census functionality that can be enabled via census_initialize(). */ |
||||
enum census_functions { |
||||
CENSUS_NONE = 0, /* Do not enable census. */ |
||||
CENSUS_TRACING = 1, /* Enable census tracing. */ |
||||
CENSUS_STATS = 2, /* Enable Census stats collection. */ |
||||
CENSUS_CPU = 4, /* Enable Census CPU usage collection. */ |
||||
CENSUS_ALL = CENSUS_TRACING | CENSUS_STATS | CENSUS_CPU |
||||
}; |
||||
|
||||
/* Shutdown and startup census subsystem. The 'functions' argument should be
|
||||
* the OR (|) of census_functions values. If census fails to initialize, then |
||||
* census_initialize() will return a non-zero value. */ |
||||
int census_initialize(int functions); |
||||
void census_shutdown(); |
||||
|
||||
/* Internally, Census relies on a context, which should be propagated across
|
||||
* RPC's. From the RPC subsystems viewpoint, this is an opaque data structure. |
||||
* A context must be used as the first argument to all other census |
||||
* functions. The context can be serialized for passing across the wire. */ |
||||
typedef struct census_context census_context; |
||||
|
||||
/* 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: |
||||
* 'buffer': pointer to memory into which serialized context will be placed |
||||
* 'buf_size': size of 'buffer' |
||||
* |
||||
* Returns: the number of bytes used in buffer if successful, or 0 if the |
||||
* buffer is of insufficient size. |
||||
* |
||||
* TODO(aveitch): determine how best to communicate required/max buffer size |
||||
* so caller doesn't have to guess. */ |
||||
size_t census_context_serialize(const census_context *context, char *buffer, |
||||
size_t buf_size); |
||||
|
||||
/* Create a new census context, possibly from a serialized buffer. If 'buffer'
|
||||
* is non-NULL, it is assumed that it is a buffer encoded by |
||||
* census_context_serialize(). If `buffer` is NULL, a new, empty context is |
||||
* created. |
||||
* |
||||
* Returns NULL on error (buffer is incorrectly formatted) */ |
||||
census_context *census_context_deserialize(char *buffer); |
||||
|
||||
/* The given context is destroyed. Once destroyed, using the context in
|
||||
* future census calls will result in undefined behavior. */ |
||||
void census_context_destroy(census_context *context); |
||||
|
||||
#endif /* CENSUS_CENSUS_H */ |
@ -0,0 +1,76 @@ |
||||
<!--- |
||||
* Copyright 2015, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
--> |
||||
|
||||
# Census - a resource measurement and tracing system |
||||
|
||||
This directory contains code for Census, which will ultimately provide the |
||||
following features for any gRPC-using system: |
||||
* A [dapper](http://research.google.com/pubs/pub36356.html)-like tracing |
||||
system, enabling tracing across a distributed infrastructure. |
||||
* RPC statistics and measurements for key metrics, such as latency, bytes |
||||
transferred, number of errors etc. |
||||
* Resource measurement framework which can be used for measuring custom |
||||
metrics. Through the use of [tags](#Tags), these can be broken down across |
||||
the entire distributed stack. |
||||
* Easy integration of the above with |
||||
[Google Cloud Trace](https://cloud.google.com/tools/cloud-trace) and |
||||
[Google Cloud Monitoring](https://cloud.google.com/monitoring/). |
||||
|
||||
## Concepts |
||||
|
||||
### Context |
||||
|
||||
### Operations |
||||
|
||||
### Tags |
||||
|
||||
### Metrics |
||||
|
||||
## API |
||||
|
||||
### Internal/RPC API |
||||
|
||||
### External/Client API |
||||
|
||||
### RPC API |
||||
|
||||
## Files in this directory |
||||
|
||||
Note that files and functions in this directory can be split into two |
||||
categories: |
||||
* Files that define core census library functions. Functions etc. in these |
||||
files are named census\_\*, and constitute the core census library |
||||
functionality. At some time in the future, these will become a standalone |
||||
library. |
||||
* Files that define functions etc. that provide a convenient interface between |
||||
grpc and the core census functionality. These files are all named |
||||
grpc\_\*.{c,h}, and define function names beginning with grpc\_census\_\*. |
||||
|
@ -0,0 +1,59 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2015, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
#include "context.h" |
||||
|
||||
#include <string.h> |
||||
#include <grpc/census.h> |
||||
#include <grpc/support/alloc.h> |
||||
|
||||
/* Placeholder implementation only. */ |
||||
|
||||
size_t census_context_serialize(const census_context *context, char *buffer, |
||||
size_t buf_size) { |
||||
/* TODO(aveitch): implement serialization */ |
||||
return 0; |
||||
} |
||||
|
||||
census_context *census_context_deserialize(char *buffer) { |
||||
census_context *ret; |
||||
if (buffer != NULL) { |
||||
/* TODO(aveitch): implement deserialization */ |
||||
return NULL; |
||||
} |
||||
ret = gpr_malloc(sizeof(census_context)); |
||||
memset(ret, 0, sizeof(census_context)); |
||||
return ret; |
||||
} |
||||
|
||||
void census_context_destroy(census_context *context) { gpr_free(context); } |
@ -0,0 +1,49 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2015, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GRPC_INTERNAL_CORE_CENSUS_CONTEXT_H |
||||
#define GRPC_INTERNAL_CORE_CENSUS_CONTEXT_H |
||||
|
||||
#include <grpc/census.h> |
||||
|
||||
/* 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 */ |
||||
/* TODO(aveitch) Add census tags:
|
||||
const census_tag_set *tags; |
||||
*/ |
||||
}; |
||||
|
||||
#endif /* GRPC_INTERNAL_CORE_CENSUS_CONTEXT_H */ |
@ -0,0 +1,41 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2015, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
#include <grpc/census.h> |
||||
#include "src/core/census/grpc_context.h" |
||||
|
||||
void *grpc_census_context_create() { return census_context_deserialize(NULL); } |
||||
|
||||
void grpc_census_context_destroy(void *context) { |
||||
census_context_destroy((census_context *)context); |
||||
} |
@ -0,0 +1,42 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2015, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
/* GRPC <--> CENSUS context interface */ |
||||
|
||||
#ifndef CENSUS_GRPC_CONTEXT_H |
||||
#define CENSUS_GRPC_CONTEXT_H |
||||
|
||||
void *grpc_census_context_create(); |
||||
void grpc_census_context_destroy(void *context); |
||||
|
||||
#endif /* CENSUS_GRPC_CONTEXT_H */ |
@ -0,0 +1,38 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2015, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
#include <grpc/census.h> |
||||
|
||||
int census_initialize(int functions) { return 0; } |
||||
|
||||
void census_shutdown() {} |
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue