From 2b939832d50fe6823df2658c53fd3fb9003fdfd0 Mon Sep 17 00:00:00 2001 From: Vizerai Date: Thu, 19 Jan 2017 13:12:11 -0800 Subject: [PATCH 1/8] update --- BUILD | 5 ++ build.yaml | 5 ++ src/core/ext/census/trace_label.h | 59 +++++++++++++ src/core/ext/census/trace_propagation.h | 62 +++++++++++++ src/core/ext/census/trace_status.h | 45 ++++++++++ src/core/ext/census/trace_string.h | 47 ++++++++++ src/core/ext/census/tracing.c | 43 ++++++--- src/core/ext/census/tracing.h | 113 ++++++++++++++++++++++++ 8 files changed, 367 insertions(+), 12 deletions(-) create mode 100644 src/core/ext/census/trace_label.h create mode 100644 src/core/ext/census/trace_propagation.h create mode 100644 src/core/ext/census/trace_status.h create mode 100644 src/core/ext/census/trace_string.h create mode 100644 src/core/ext/census/tracing.h diff --git a/BUILD b/BUILD index 54192514cc7..10d93d1f9cd 100644 --- a/BUILD +++ b/BUILD @@ -284,6 +284,11 @@ grpc_cc_library( "src/core/ext/census/resource.h", "src/core/ext/census/rpc_metric_id.h", "src/core/ext/census/trace_context.h", + "src/core/ext/census/trace_label.h", + "src/core/ext/census/trace_propagation.h", + "src/core/ext/census/trace_status.h", + "src/core/ext/census/trace_string.h", + "src/core/ext/census/tracing.h", ], external_deps = [ "nanopb", diff --git a/build.yaml b/build.yaml index eaf64e860f1..0b490268c69 100644 --- a/build.yaml +++ b/build.yaml @@ -31,6 +31,11 @@ filegroups: - src/core/ext/census/resource.h - src/core/ext/census/rpc_metric_id.h - src/core/ext/census/trace_context.h + - src/core/ext/census/trace_label.h + - src/core/ext/census/trace_propagation.h + - src/core/ext/census/trace_status.h + - src/core/ext/census/trace_string.h + - src/core/ext/census/tracing.h src: - src/core/ext/census/base_resources.c - src/core/ext/census/context.c diff --git a/src/core/ext/census/trace_label.h b/src/core/ext/census/trace_label.h new file mode 100644 index 00000000000..b58543b7d8c --- /dev/null +++ b/src/core/ext/census/trace_label.h @@ -0,0 +1,59 @@ +/* + * + * Copyright 2016, 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_CORE_EXT_CENSUS_TRACE_LABEL_H +#define GRPC_CORE_EXT_CENSUS_TRACE_LABEL_H + +#include "src/core/ext/census/trace_string.h" + +/* Trace label (key/value pair) stores a label name and the label value. */ +typedef struct trace_label { + trace_string key; + enum label_type { + /* A string value */ + LABEL_STRING = 1, + /* An integer value. */ + LABEL_INT = 2, + /* A boolean value. */ + LABEL_BOOL = 3, + } value_type; + + union value { + trace_string label_str; + int64_t label_int; + bool label_bool; + } value; + size_t val_len; +} trace_label; + +#endif diff --git a/src/core/ext/census/trace_propagation.h b/src/core/ext/census/trace_propagation.h new file mode 100644 index 00000000000..093492c3e8e --- /dev/null +++ b/src/core/ext/census/trace_propagation.h @@ -0,0 +1,62 @@ +/* + * + * Copyright 2016, 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_CORE_EXT_CENSUS_TRACE_PROPAGATION_H +#define GRPC_CORE_EXT_CENSUS_TRACE_PROPAGATION_H + +#include "src/core/ext/census/tracing.h" + +/* Encoding and decoding functions for receiving and sending propagating data + over the wire. Only RPC libraries should be calling these + functions. These functions return the number of bytes encoded/decoded + (0 if a failure has occurred). buf_size indicates the size of the + input/output buffer. trace_span_context is a struct that includes the + trace ID, span ID, and a set of option flags (is_sampled, etc.). */ + +/* Converts a span context to a binary byte buffer. */ +size_t trace_span_context_to_binary(const trace_span_context *ctxt, char *buf, + size_t buf_size); + +/* Reads a binary byte buffer and populates a span context structure. */ +size_t binary_to_trace_span_context(const char *buf, size_t buf_size, + trace_span_context *ctxt); + +/* Converts a span context to a http format buffer. */ +size_t trace_span_context_to_http_format(const trace_span_context *ctxt, + char *buf, size_t buf_size); + +/* Reads a http format buffer and populates a span context structure. */ +size_t http_format_to_trace_span_context(const char *buf, size_t buf_size, + trace_span_context *ctxt); + +#endif diff --git a/src/core/ext/census/trace_status.h b/src/core/ext/census/trace_status.h new file mode 100644 index 00000000000..a4bd4116c30 --- /dev/null +++ b/src/core/ext/census/trace_status.h @@ -0,0 +1,45 @@ +/* + * + * Copyright 2016, 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_CORE_EXT_CENSUS_TRACE_STATUS_H +#define GRPC_CORE_EXT_CENSUS_TRACE_STATUS_H + +#include "src/core/ext/census/trace_string.h" + +/* Stores a status code and status message for a trace. */ +typedef struct trace_status { + int errorCode; + trace_string errorMessage; +} trace_status; + +#endif diff --git a/src/core/ext/census/trace_string.h b/src/core/ext/census/trace_string.h new file mode 100644 index 00000000000..0f71056c3bc --- /dev/null +++ b/src/core/ext/census/trace_string.h @@ -0,0 +1,47 @@ +/* + * + * Copyright 2016, 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_CORE_EXT_CENSUS_TRACE_STRING_H +#define GRPC_CORE_EXT_CENSUS_TRACE_STRING_H + +#include + +/* String struct for tracing messages. Since this is a C API, we do not have + access to a string class. This is intended for use by higher level + languages which wrap around the C API, as most of them have a string class. + This will also be more efficient when copying, as we have an explicitly + specified length. Also, grpc_slice has reference counting which allows for + interning. */ +typedef struct trace_string { grpc_slice string_slice; } trace_string; + +#endif diff --git a/src/core/ext/census/tracing.c b/src/core/ext/census/tracing.c index 9371fffc8d7..8d22f43eed5 100644 --- a/src/core/ext/census/tracing.c +++ b/src/core/ext/census/tracing.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,21 +31,40 @@ * */ -//#include "src/core/ext/census/tracing.h" - +#include "src/core/ext/census/tracing.h" #include -#include +#include +#include +#include +#include "src/core/ext/census/mlog.h" -/* TODO(aveitch): These are all placeholder implementations. */ +void trace_start_span(const trace_span_context *span_ctxt, + const trace_string name, const start_span_options *opts, + trace_span_context *new_span_ctxt, + bool has_remote_parent) { + // Noop implementation. +} -int census_trace_mask(const census_context *context) { - abort(); - return CENSUS_TRACE_MASK_NONE; +void trace_add_span_annotation(const trace_string description, + const trace_label *labels, const size_t n_labels, + trace_span_context *span_ctxt) { + // Noop implementation. } -void census_set_trace_mask(int trace_mask) { abort(); } +void trace_add_span_network_event_annotation(const trace_string description, + const trace_label *labels, + const size_t n_labels, + const gpr_timespec timestamp, + bool sent, uint64_t id, + trace_span_context *span_ctxt) { + // Noop implementation. +} + +void trace_add_span_labels(const trace_label *labels, const size_t n_labels, + trace_span_context *span_ctxt) { + // Noop implementation. +} -void census_trace_print(census_context *context, uint32_t type, - const char *buffer, size_t n) { - abort(); +void trace_end_span(const trace_status *status, trace_span_context *span_ctxt) { + // Noop implementation. } diff --git a/src/core/ext/census/tracing.h b/src/core/ext/census/tracing.h new file mode 100644 index 00000000000..5be39e377ac --- /dev/null +++ b/src/core/ext/census/tracing.h @@ -0,0 +1,113 @@ +/* + * + * Copyright 2016, 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_CORE_EXT_CENSUS_TRACING_H +#define GRPC_CORE_EXT_CENSUS_TRACING_H + +#include +#include +#include "src/core/ext/census/trace_context.h" +#include "src/core/ext/census/trace_label.h" +#include "src/core/ext/census/trace_status.h" + +/* The tracing level. */ +public +enum TraceLevel { + /* Annotations on this context will be silently discarded. */ + NO_TRACING = 0, + /* Annotations will not be saved to a persistent store. They will be + available via local APIs only. It is not propagated to the child. */ + TRANSIENT_TRACING = 1, + /* Annotations are recorded for the entire distributed trace and they are + saved to a persistent store. It is propagated to the child. */ + PERSISTENT_TRACING = 2, +} + +typedef struct trace_span_context { + /* Trace span context stores Span ID, Trace ID, and option flags. */ + uint64_t trace_id_hi; + uint64_t trace_id_lo; + uint64_t span_id; + uint32_t span_options; +} trace_span_context; + +typedef struct start_span_options { + /* If set, this will override the Span.local_start_time for the Span. */ + gpr_timespec local_start_timestamp; + + /* If set, the Spans are linked to the created Span. */ + trace_span_context *linked_spans; + /* The number of linked spans. */ + size_t n_linked_spans; +} start_span_options; + +/* Create a new child Span (or root if parent is NULL), with parent being the + designated Span. The child span will have the provided name and starting + span options (optional). The bool has_remote_parent marks whether the + context refers to a remote parent span or not. */ +void trace_start_span(const trace_span_context *span_ctxt, + const trace_string name, const start_span_options *opts, + trace_span_context *new_span_ctxt, + bool has_remote_parent); + +/* Add a new Annotation to the Span. The description corresponds to + Span->annotations[].description. */ +void trace_add_span_annotation(const trace_string description, + const trace_label *labels, const size_t n_labels, + trace_span_context *span_ctxt); + +/* Add a new NetworkEvent annotation to a Span. This function is only intended + to be used by RPC systems (either client or server), not by higher level + applications. The timestamp type will be system-defined, the sent argument + designates whether this is a network send event (client request, server + reply)or receive (server request, client reply). The id argument corresponds + to Span.Annotation.NetworkEvent.id from the data model, and serves to uniquely + identify each network message. */ +void trace_add_span_network_event(const trace_string description, + const trace_label *labels, + const size_t n_labels, + const gpr_timespec timestamp, bool sent, + uint64_t id, trace_span_context *span_ctxt); + +/* Add a set of labels to the Span. These will correspond to the field +Span.labels in the data model. */ +void trace_add_span_labels(const trace_label *labels, const size_t n_labels, + trace_span_context *span_ctxt); + +/* Mark the end of Span Execution with the given status. Only the timing of the +first EndSpan call for a given Span will be recorded, and implementations are +free to ignore all further calls using the Span. EndSpanOptions can +optionally be NULL. */ +void trace_end_span(const trace_status *status, trace_span_context *span_ctxt); + +#endif From 548d59f305b43d22ca1ef03c5fa82576f32d469a Mon Sep 17 00:00:00 2001 From: Vizerai Date: Thu, 19 Jan 2017 16:41:37 -0800 Subject: [PATCH 2/8] update --- src/core/ext/census/tracing.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/ext/census/tracing.h b/src/core/ext/census/tracing.h index 5be39e377ac..0632b841bd1 100644 --- a/src/core/ext/census/tracing.h +++ b/src/core/ext/census/tracing.h @@ -41,7 +41,6 @@ #include "src/core/ext/census/trace_status.h" /* The tracing level. */ -public enum TraceLevel { /* Annotations on this context will be silently discarded. */ NO_TRACING = 0, @@ -51,7 +50,7 @@ enum TraceLevel { /* Annotations are recorded for the entire distributed trace and they are saved to a persistent store. It is propagated to the child. */ PERSISTENT_TRACING = 2, -} +}; typedef struct trace_span_context { /* Trace span context stores Span ID, Trace ID, and option flags. */ From 0e5b67f4a2405654a99cac5d5b54816f9339c4fa Mon Sep 17 00:00:00 2001 From: Vizerai Date: Fri, 20 Jan 2017 14:02:18 -0800 Subject: [PATCH 3/8] update --- gRPC-Core.podspec | 12 +++++++++++- grpc.gemspec | 5 +++++ package.xml | 5 +++++ third_party/gflags | 2 +- tools/doxygen/Doxyfile.core.internal | 5 +++++ .../run_tests/generated/sources_and_headers.json | 14 ++++++++++++-- vsprojects/vcxproj/grpc/grpc.vcxproj | 5 +++++ vsprojects/vcxproj/grpc/grpc.vcxproj.filters | 15 +++++++++++++++ .../vcxproj/grpc_unsecure/grpc_unsecure.vcxproj | 5 +++++ .../grpc_unsecure/grpc_unsecure.vcxproj.filters | 15 +++++++++++++++ 10 files changed, 79 insertions(+), 4 deletions(-) diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 1eb178931dc..1dd2ad46b22 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -432,6 +432,11 @@ Pod::Spec.new do |s| 'src/core/ext/census/resource.h', 'src/core/ext/census/rpc_metric_id.h', 'src/core/ext/census/trace_context.h', + 'src/core/ext/census/trace_label.h', + 'src/core/ext/census/trace_propagation.h', + 'src/core/ext/census/trace_status.h', + 'src/core/ext/census/trace_string.h', + 'src/core/ext/census/tracing.h', 'src/core/lib/surface/init.c', 'src/core/lib/channel/channel_args.c', 'src/core/lib/channel/channel_stack.c', @@ -843,7 +848,12 @@ Pod::Spec.new do |s| 'src/core/ext/census/mlog.h', 'src/core/ext/census/resource.h', 'src/core/ext/census/rpc_metric_id.h', - 'src/core/ext/census/trace_context.h' + 'src/core/ext/census/trace_context.h', + 'src/core/ext/census/trace_label.h', + 'src/core/ext/census/trace_propagation.h', + 'src/core/ext/census/trace_status.h', + 'src/core/ext/census/trace_string.h', + 'src/core/ext/census/tracing.h' end s.subspec 'Cronet-Interface' do |ss| diff --git a/grpc.gemspec b/grpc.gemspec index cfc0c35aa3e..ecc96bc2fea 100755 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -349,6 +349,11 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/census/resource.h ) s.files += %w( src/core/ext/census/rpc_metric_id.h ) s.files += %w( src/core/ext/census/trace_context.h ) + s.files += %w( src/core/ext/census/trace_label.h ) + s.files += %w( src/core/ext/census/trace_propagation.h ) + s.files += %w( src/core/ext/census/trace_status.h ) + s.files += %w( src/core/ext/census/trace_string.h ) + s.files += %w( src/core/ext/census/tracing.h ) s.files += %w( src/core/lib/surface/init.c ) s.files += %w( src/core/lib/channel/channel_args.c ) s.files += %w( src/core/lib/channel/channel_stack.c ) diff --git a/package.xml b/package.xml index aa1894f4086..cac087ad6c6 100644 --- a/package.xml +++ b/package.xml @@ -358,6 +358,11 @@ + + + + + diff --git a/third_party/gflags b/third_party/gflags index f8a0efe03aa..05b155ff591 160000 --- a/third_party/gflags +++ b/third_party/gflags @@ -1 +1 @@ -Subproject commit f8a0efe03aa69b3336d8e228b37d4ccb17324b88 +Subproject commit 05b155ff59114735ec8cd089f669c4c3d8f59029 diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index ffe83a2ddb3..019a0784b5b 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -884,7 +884,12 @@ src/core/ext/census/resource.h \ src/core/ext/census/rpc_metric_id.h \ src/core/ext/census/trace_context.c \ src/core/ext/census/trace_context.h \ +src/core/ext/census/trace_label.h \ +src/core/ext/census/trace_propagation.h \ +src/core/ext/census/trace_status.h \ +src/core/ext/census/trace_string.h \ src/core/ext/census/tracing.c \ +src/core/ext/census/tracing.h \ src/core/ext/client_channel/README.md \ src/core/ext/client_channel/channel_connectivity.c \ src/core/ext/client_channel/client_channel.c \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index c57b17611be..51946bf02f7 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -6551,7 +6551,12 @@ "src/core/ext/census/mlog.h", "src/core/ext/census/resource.h", "src/core/ext/census/rpc_metric_id.h", - "src/core/ext/census/trace_context.h" + "src/core/ext/census/trace_context.h", + "src/core/ext/census/trace_label.h", + "src/core/ext/census/trace_propagation.h", + "src/core/ext/census/trace_status.h", + "src/core/ext/census/trace_string.h", + "src/core/ext/census/tracing.h" ], "is_filegroup": true, "language": "c", @@ -6582,7 +6587,12 @@ "src/core/ext/census/rpc_metric_id.h", "src/core/ext/census/trace_context.c", "src/core/ext/census/trace_context.h", - "src/core/ext/census/tracing.c" + "src/core/ext/census/trace_label.h", + "src/core/ext/census/trace_propagation.h", + "src/core/ext/census/trace_status.h", + "src/core/ext/census/trace_string.h", + "src/core/ext/census/tracing.c", + "src/core/ext/census/tracing.h" ], "third_party": false, "type": "filegroup" diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj b/vsprojects/vcxproj/grpc/grpc.vcxproj index c159db63f55..15198621ca2 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj @@ -481,6 +481,11 @@ + + + + + diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters index 1e099f3285e..c7bdd43a4d7 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters @@ -1292,6 +1292,21 @@ src\core\ext\census + + src\core\ext\census + + + src\core\ext\census + + + src\core\ext\census + + + src\core\ext\census + + + src\core\ext\census + diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj index dcb943a3a11..5db67a1a4c2 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj @@ -447,6 +447,11 @@ + + + + + diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters index ac84e0188c8..d60461a2bb3 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters @@ -1133,6 +1133,21 @@ src\core\ext\census + + src\core\ext\census + + + src\core\ext\census + + + src\core\ext\census + + + src\core\ext\census + + + src\core\ext\census + From 9078535c0a8f2192a3c48362aa17fdba6c8951ab Mon Sep 17 00:00:00 2001 From: Vizerai Date: Tue, 24 Jan 2017 13:02:45 -0800 Subject: [PATCH 4/8] updated headers. --- src/core/ext/census/tracing.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/ext/census/tracing.c b/src/core/ext/census/tracing.c index 8d22f43eed5..566d539e6ef 100644 --- a/src/core/ext/census/tracing.c +++ b/src/core/ext/census/tracing.c @@ -32,10 +32,11 @@ */ #include "src/core/ext/census/tracing.h" + #include #include #include -#include +#include "third_party/boringssl/include/openssl/rand.h" #include "src/core/ext/census/mlog.h" void trace_start_span(const trace_span_context *span_ctxt, From c09e61bbda22d81e49e961a3af89bc9e4ad3c589 Mon Sep 17 00:00:00 2001 From: Vizerai Date: Tue, 24 Jan 2017 16:46:31 -0800 Subject: [PATCH 5/8] update --- BUILD | 1 + src/core/ext/census/tracing.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/BUILD b/BUILD index 10d93d1f9cd..507f7abfbb8 100644 --- a/BUILD +++ b/BUILD @@ -292,6 +292,7 @@ grpc_cc_library( ], external_deps = [ "nanopb", + "submodule_boringssl", ], language = "c", public_hdrs = [ diff --git a/src/core/ext/census/tracing.c b/src/core/ext/census/tracing.c index 566d539e6ef..f02aefc3d7d 100644 --- a/src/core/ext/census/tracing.c +++ b/src/core/ext/census/tracing.c @@ -36,7 +36,7 @@ #include #include #include -#include "third_party/boringssl/include/openssl/rand.h" +#include "third_party/boringssl-with-bazel/src/include/openssl/rand.h" #include "src/core/ext/census/mlog.h" void trace_start_span(const trace_span_context *span_ctxt, From b0b86d7504dc7cf25d2616927196203c8ee41373 Mon Sep 17 00:00:00 2001 From: Vizerai Date: Wed, 25 Jan 2017 13:45:54 -0800 Subject: [PATCH 6/8] updated to correctly build with Bazel. --- BUILD | 2 +- src/core/ext/census/tracing.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILD b/BUILD index 507f7abfbb8..b4835696324 100644 --- a/BUILD +++ b/BUILD @@ -292,7 +292,7 @@ grpc_cc_library( ], external_deps = [ "nanopb", - "submodule_boringssl", + "libssl", ], language = "c", public_hdrs = [ diff --git a/src/core/ext/census/tracing.c b/src/core/ext/census/tracing.c index f02aefc3d7d..8b74628f4fb 100644 --- a/src/core/ext/census/tracing.c +++ b/src/core/ext/census/tracing.c @@ -36,7 +36,7 @@ #include #include #include -#include "third_party/boringssl-with-bazel/src/include/openssl/rand.h" +#include #include "src/core/ext/census/mlog.h" void trace_start_span(const trace_span_context *span_ctxt, From 2685ffa738113a00c103525b6bc4bc91e8b4b7a2 Mon Sep 17 00:00:00 2001 From: Vizerai Date: Thu, 26 Jan 2017 18:41:14 -0800 Subject: [PATCH 7/8] update. --- src/core/ext/census/trace_label.h | 6 ++++-- src/core/ext/census/trace_propagation.h | 13 +++++++------ src/core/ext/census/trace_status.h | 2 +- src/core/ext/census/trace_string.h | 5 ++++- src/core/ext/census/tracing.h | 22 +++++++++++++++++----- 5 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/core/ext/census/trace_label.h b/src/core/ext/census/trace_label.h index b58543b7d8c..0e4a8d885f1 100644 --- a/src/core/ext/census/trace_label.h +++ b/src/core/ext/census/trace_label.h @@ -36,10 +36,13 @@ #include "src/core/ext/census/trace_string.h" -/* Trace label (key/value pair) stores a label name and the label value. */ +/* Trace label (key/value pair) stores a label name and the label value. The + value can be one of trace_string/int64_t/bool. */ typedef struct trace_label { trace_string key; enum label_type { + /* Unknown value for debugging/error purposes */ + LABEL_UNKNOWN = 0, /* A string value */ LABEL_STRING = 1, /* An integer value. */ @@ -53,7 +56,6 @@ typedef struct trace_label { int64_t label_int; bool label_bool; } value; - size_t val_len; } trace_label; #endif diff --git a/src/core/ext/census/trace_propagation.h b/src/core/ext/census/trace_propagation.h index 093492c3e8e..75c4ebaa398 100644 --- a/src/core/ext/census/trace_propagation.h +++ b/src/core/ext/census/trace_propagation.h @@ -36,7 +36,7 @@ #include "src/core/ext/census/tracing.h" -/* Encoding and decoding functions for receiving and sending propagating data +/* Encoding and decoding functions for receiving and sending trace contexts over the wire. Only RPC libraries should be calling these functions. These functions return the number of bytes encoded/decoded (0 if a failure has occurred). buf_size indicates the size of the @@ -44,18 +44,19 @@ trace ID, span ID, and a set of option flags (is_sampled, etc.). */ /* Converts a span context to a binary byte buffer. */ -size_t trace_span_context_to_binary(const trace_span_context *ctxt, char *buf, - size_t buf_size); +size_t trace_span_context_to_binary(const trace_span_context *ctxt, + uint8_t *buf, size_t buf_size); /* Reads a binary byte buffer and populates a span context structure. */ -size_t binary_to_trace_span_context(const char *buf, size_t buf_size, +size_t binary_to_trace_span_context(const uint8_t *buf, size_t buf_size, trace_span_context *ctxt); -/* Converts a span context to a http format buffer. */ +/* Converts a span context to an http metadata compatible string. */ size_t trace_span_context_to_http_format(const trace_span_context *ctxt, char *buf, size_t buf_size); -/* Reads a http format buffer and populates a span context structure. */ +/* Reads an http metadata compatible string and populates a span context + structure. */ size_t http_format_to_trace_span_context(const char *buf, size_t buf_size, trace_span_context *ctxt); diff --git a/src/core/ext/census/trace_status.h b/src/core/ext/census/trace_status.h index a4bd4116c30..adc0ebd0c02 100644 --- a/src/core/ext/census/trace_status.h +++ b/src/core/ext/census/trace_status.h @@ -38,7 +38,7 @@ /* Stores a status code and status message for a trace. */ typedef struct trace_status { - int errorCode; + int64_t errorCode; trace_string errorMessage; } trace_status; diff --git a/src/core/ext/census/trace_string.h b/src/core/ext/census/trace_string.h index 0f71056c3bc..8e77ee9f7ed 100644 --- a/src/core/ext/census/trace_string.h +++ b/src/core/ext/census/trace_string.h @@ -42,6 +42,9 @@ This will also be more efficient when copying, as we have an explicitly specified length. Also, grpc_slice has reference counting which allows for interning. */ -typedef struct trace_string { grpc_slice string_slice; } trace_string; +typedef struct trace_string { + char *string; + size_t length; +} trace_string; #endif diff --git a/src/core/ext/census/tracing.h b/src/core/ext/census/tracing.h index 0632b841bd1..c2b947ae407 100644 --- a/src/core/ext/census/tracing.h +++ b/src/core/ext/census/tracing.h @@ -40,23 +40,31 @@ #include "src/core/ext/census/trace_label.h" #include "src/core/ext/census/trace_status.h" +/* This is the low level tracing API that other languages will interface with. + This is not intended to be accessed by the end-user, therefore it has been + designed with performance in mind rather than ease of use. */ + /* The tracing level. */ enum TraceLevel { /* Annotations on this context will be silently discarded. */ NO_TRACING = 0, /* Annotations will not be saved to a persistent store. They will be - available via local APIs only. It is not propagated to the child. */ + available via local APIs only. This setting is not propagated to child + spans. */ TRANSIENT_TRACING = 1, /* Annotations are recorded for the entire distributed trace and they are - saved to a persistent store. It is propagated to the child. */ + saved to a persistent store. This setting is propagated to child spans. */ PERSISTENT_TRACING = 2, }; typedef struct trace_span_context { /* Trace span context stores Span ID, Trace ID, and option flags. */ + /* Trace ID is 128 bits split into 2 64-bit chunks (hi and lo). */ uint64_t trace_id_hi; uint64_t trace_id_lo; + /* Span ID is 64 bits. */ uint64_t span_id; + /* Span-options is 32-bit value which contains flag options. */ uint32_t span_options; } trace_span_context; @@ -64,7 +72,10 @@ typedef struct start_span_options { /* If set, this will override the Span.local_start_time for the Span. */ gpr_timespec local_start_timestamp; - /* If set, the Spans are linked to the created Span. */ + /* Linked spans can be used to identify spans that are linked to this span in + a different trace. This can be used (for example) in batching operations, + where a single batch handler processes multiple requests from different + traces. If set, points to a list of Spans are linked to the created Span.*/ trace_span_context *linked_spans; /* The number of linked spans. */ size_t n_linked_spans; @@ -79,8 +90,9 @@ void trace_start_span(const trace_span_context *span_ctxt, trace_span_context *new_span_ctxt, bool has_remote_parent); -/* Add a new Annotation to the Span. The description corresponds to - Span->annotations[].description. */ +/* Add a new Annotation to the Span. Annotations consist of a description + (trace_string) and a set of n labels (trace_label). This can be populated + with arbitrary user data. */ void trace_add_span_annotation(const trace_string description, const trace_label *labels, const size_t n_labels, trace_span_context *span_ctxt); From 7d5a560192da155e28181e1e67c4905a88ad8d65 Mon Sep 17 00:00:00 2001 From: Vizerai Date: Fri, 27 Jan 2017 14:12:57 -0800 Subject: [PATCH 8/8] gflags 2.2.0 --- third_party/gflags | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/gflags b/third_party/gflags index 05b155ff591..f8a0efe03aa 160000 --- a/third_party/gflags +++ b/third_party/gflags @@ -1 +1 @@ -Subproject commit 05b155ff59114735ec8cd089f669c4c3d8f59029 +Subproject commit f8a0efe03aa69b3336d8e228b37d4ccb17324b88