OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * |
| 3 * Copyright 2015, 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_INTERNAL_CORE_STATISTICS_CENSUS_INTERFACE_H |
| 35 #define GRPC_INTERNAL_CORE_STATISTICS_CENSUS_INTERFACE_H |
| 36 |
| 37 #include <grpc/support/port_platform.h> |
| 38 |
| 39 /* Maximum length of an individual census trace annotation. */ |
| 40 #define CENSUS_MAX_ANNOTATION_LENGTH 200 |
| 41 |
| 42 /* Structure of a census op id. Define as structure because 64bit integer is not |
| 43 available on every platform for C89. */ |
| 44 typedef struct census_op_id { |
| 45 uint32_t upper; |
| 46 uint32_t lower; |
| 47 } census_op_id; |
| 48 |
| 49 typedef struct census_rpc_stats census_rpc_stats; |
| 50 |
| 51 /* Initializes Census library. No-op if Census is already initialized. */ |
| 52 void census_init(void); |
| 53 |
| 54 /* Shutdown Census Library. */ |
| 55 void census_shutdown(void); |
| 56 |
| 57 /* Annotates grpc method name on a census_op_id. The method name has the format |
| 58 of <full quantified rpc service name>/<rpc function name>. Returns 0 iff |
| 59 op_id and method_name are all valid. op_id is valid after its creation and |
| 60 before calling census_tracing_end_op(). |
| 61 |
| 62 TODO(hongyu): Figure out valid characters set for service name and command |
| 63 name and document requirements here.*/ |
| 64 int census_add_method_tag(census_op_id op_id, const char *method_name); |
| 65 |
| 66 /* Annotates tracing information to a specific op_id. |
| 67 Up to CENSUS_MAX_ANNOTATION_LENGTH bytes are recorded. */ |
| 68 void census_tracing_print(census_op_id op_id, const char *annotation); |
| 69 |
| 70 /* Starts tracing for an RPC. Returns a locally unique census_op_id */ |
| 71 census_op_id census_tracing_start_op(void); |
| 72 |
| 73 /* Ends tracing. Calling this function will invalidate the input op_id. */ |
| 74 void census_tracing_end_op(census_op_id op_id); |
| 75 |
| 76 #endif /* GRPC_INTERNAL_CORE_STATISTICS_CENSUS_INTERFACE_H */ |
OLD | NEW |