From 10d989f32d75abe7751f087b1dcab0b9245bcaef Mon Sep 17 00:00:00 2001 From: Radu Berinde Date: Thu, 6 Feb 2020 07:42:25 -0500 Subject: [PATCH] sql: add infrastructure for tracing queries on demand This patch adds some infrastructure, to be hooked up to the AdminUI in the future. The system.statement_diagnostics_requests and system.statement_diagnostics tables are introduced. The idea is that all nodes poll the former for fingerprints of requests that need information collected and, when nodes then see a query with such a fingerprint, they race to write the requested info (initially, a trace) into the latter. system.statement_bundle_chunks is also introduced, to be used in the future for gatherig more generic data about a query. Release note: None --- .../protos/util/tracing/recorded_span.pb.cc | 793 ++++++++++++--- .../protos/util/tracing/recorded_span.pb.h | 786 ++++++++++---- docs/generated/settings/settings.html | 2 +- pkg/cli/zip_test.go | 30 +- pkg/gossip/keys.go | 7 + pkg/keys/constants.go | 4 + pkg/server/server.go | 2 +- pkg/server/status.go | 27 +- pkg/server/testserver.go | 5 + pkg/settings/cluster/cockroach_versions.go | 10 + pkg/settings/cluster/versionkey_string.go | 5 +- pkg/sql/conn_executor.go | 31 + pkg/sql/conn_executor_exec.go | 17 + pkg/sql/conn_executor_internal_test.go | 5 +- pkg/sql/exec_util.go | 19 +- .../logictest/testdata/logic_test/grant_table | 45 + .../testdata/logic_test/information_schema | 321 ++++-- .../logictest/testdata/logic_test/pg_catalog | 9 + pkg/sql/logictest/testdata/logic_test/ranges | 10 +- .../logictest/testdata/logic_test/show_source | 6 + pkg/sql/logictest/testdata/logic_test/system | 36 + .../testdata/logic_test/system_namespace | 3 + .../opt/exec/execbuilder/testdata/autocommit | 168 +-- .../exec/execbuilder/testdata/delete_range | 6 +- pkg/sql/opt/exec/execbuilder/testdata/upsert | 6 +- pkg/sql/pgwire/pgwire_test.go | 2 +- pkg/sql/sqlbase/system.go | 150 +++ pkg/sql/statement_diagnostics.go | 414 ++++++++ pkg/sql/statement_diagnostics_test.go | 115 +++ pkg/sql/tests/system_table_test.go | 5 + pkg/sqlmigrations/migrations.go | 35 +- pkg/testutils/serverutils/test_server_shim.go | 3 + pkg/util/tracing/recorded_span.pb.go | 958 +++++++++++++----- pkg/util/tracing/recorded_span.proto | 40 +- pkg/util/tracing/tracer_span.go | 6 +- 35 files changed, 3283 insertions(+), 798 deletions(-) create mode 100644 pkg/sql/statement_diagnostics.go create mode 100644 pkg/sql/statement_diagnostics_test.go diff --git a/c-deps/libroach/protos/util/tracing/recorded_span.pb.cc b/c-deps/libroach/protos/util/tracing/recorded_span.pb.cc index f9559daef2bf..3cdd25d9be36 100644 --- a/c-deps/libroach/protos/util/tracing/recorded_span.pb.cc +++ b/c-deps/libroach/protos/util/tracing/recorded_span.pb.cc @@ -26,14 +26,26 @@ namespace protobuf_google_2fprotobuf_2ftimestamp_2eproto { extern PROTOBUF_INTERNAL_EXPORT_protobuf_google_2fprotobuf_2ftimestamp_2eproto ::google::protobuf::internal::SCCInfo<0> scc_info_Timestamp; } // namespace protobuf_google_2fprotobuf_2ftimestamp_2eproto namespace protobuf_util_2ftracing_2frecorded_5fspan_2eproto { +extern PROTOBUF_INTERNAL_EXPORT_protobuf_util_2ftracing_2frecorded_5fspan_2eproto ::google::protobuf::internal::SCCInfo<0> scc_info_LogRecord_Field; +extern PROTOBUF_INTERNAL_EXPORT_protobuf_util_2ftracing_2frecorded_5fspan_2eproto ::google::protobuf::internal::SCCInfo<0> scc_info_NormalizedSpan_TagsEntry_DoNotUse; extern PROTOBUF_INTERNAL_EXPORT_protobuf_util_2ftracing_2frecorded_5fspan_2eproto ::google::protobuf::internal::SCCInfo<0> scc_info_RecordedSpan_BaggageEntry_DoNotUse; -extern PROTOBUF_INTERNAL_EXPORT_protobuf_util_2ftracing_2frecorded_5fspan_2eproto ::google::protobuf::internal::SCCInfo<0> scc_info_RecordedSpan_LogRecord_Field; extern PROTOBUF_INTERNAL_EXPORT_protobuf_util_2ftracing_2frecorded_5fspan_2eproto ::google::protobuf::internal::SCCInfo<0> scc_info_RecordedSpan_TagsEntry_DoNotUse; -extern PROTOBUF_INTERNAL_EXPORT_protobuf_util_2ftracing_2frecorded_5fspan_2eproto ::google::protobuf::internal::SCCInfo<2> scc_info_RecordedSpan_LogRecord; +extern PROTOBUF_INTERNAL_EXPORT_protobuf_util_2ftracing_2frecorded_5fspan_2eproto ::google::protobuf::internal::SCCInfo<2> scc_info_LogRecord; +extern PROTOBUF_INTERNAL_EXPORT_protobuf_util_2ftracing_2frecorded_5fspan_2eproto ::google::protobuf::internal::SCCInfo<4> scc_info_NormalizedSpan; } // namespace protobuf_util_2ftracing_2frecorded_5fspan_2eproto namespace cockroach { namespace util { namespace tracing { +class LogRecord_FieldDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed + _instance; +} _LogRecord_Field_default_instance_; +class LogRecordDefaultTypeInternal { + public: + ::google::protobuf::internal::ExplicitlyConstructed + _instance; +} _LogRecord_default_instance_; class RecordedSpan_BaggageEntry_DoNotUseDefaultTypeInternal { public: ::google::protobuf::internal::ExplicitlyConstructed @@ -44,25 +56,55 @@ class RecordedSpan_TagsEntry_DoNotUseDefaultTypeInternal { ::google::protobuf::internal::ExplicitlyConstructed _instance; } _RecordedSpan_TagsEntry_DoNotUse_default_instance_; -class RecordedSpan_LogRecord_FieldDefaultTypeInternal { +class RecordedSpanDefaultTypeInternal { public: - ::google::protobuf::internal::ExplicitlyConstructed + ::google::protobuf::internal::ExplicitlyConstructed _instance; -} _RecordedSpan_LogRecord_Field_default_instance_; -class RecordedSpan_LogRecordDefaultTypeInternal { +} _RecordedSpan_default_instance_; +class NormalizedSpan_TagsEntry_DoNotUseDefaultTypeInternal { public: - ::google::protobuf::internal::ExplicitlyConstructed + ::google::protobuf::internal::ExplicitlyConstructed _instance; -} _RecordedSpan_LogRecord_default_instance_; -class RecordedSpanDefaultTypeInternal { +} _NormalizedSpan_TagsEntry_DoNotUse_default_instance_; +class NormalizedSpanDefaultTypeInternal { public: - ::google::protobuf::internal::ExplicitlyConstructed + ::google::protobuf::internal::ExplicitlyConstructed _instance; -} _RecordedSpan_default_instance_; +} _NormalizedSpan_default_instance_; } // namespace tracing } // namespace util } // namespace cockroach namespace protobuf_util_2ftracing_2frecorded_5fspan_2eproto { +static void InitDefaultsLogRecord_Field() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::cockroach::util::tracing::_LogRecord_Field_default_instance_; + new (ptr) ::cockroach::util::tracing::LogRecord_Field(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::cockroach::util::tracing::LogRecord_Field::InitAsDefaultInstance(); +} + +::google::protobuf::internal::SCCInfo<0> scc_info_LogRecord_Field = + {{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsLogRecord_Field}, {}}; + +static void InitDefaultsLogRecord() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::cockroach::util::tracing::_LogRecord_default_instance_; + new (ptr) ::cockroach::util::tracing::LogRecord(); + ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + } + ::cockroach::util::tracing::LogRecord::InitAsDefaultInstance(); +} + +::google::protobuf::internal::SCCInfo<2> scc_info_LogRecord = + {{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 2, InitDefaultsLogRecord}, { + &protobuf_google_2fprotobuf_2ftimestamp_2eproto::scc_info_Timestamp.base, + &protobuf_util_2ftracing_2frecorded_5fspan_2eproto::scc_info_LogRecord_Field.base,}}; + static void InitDefaultsRecordedSpan_BaggageEntry_DoNotUse() { GOOGLE_PROTOBUF_VERIFY_VERSION; @@ -89,62 +131,65 @@ static void InitDefaultsRecordedSpan_TagsEntry_DoNotUse() { ::google::protobuf::internal::SCCInfo<0> scc_info_RecordedSpan_TagsEntry_DoNotUse = {{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsRecordedSpan_TagsEntry_DoNotUse}, {}}; -static void InitDefaultsRecordedSpan_LogRecord_Field() { +static void InitDefaultsRecordedSpan() { GOOGLE_PROTOBUF_VERIFY_VERSION; { - void* ptr = &::cockroach::util::tracing::_RecordedSpan_LogRecord_Field_default_instance_; - new (ptr) ::cockroach::util::tracing::RecordedSpan_LogRecord_Field(); + void* ptr = &::cockroach::util::tracing::_RecordedSpan_default_instance_; + new (ptr) ::cockroach::util::tracing::RecordedSpan(); ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); } - ::cockroach::util::tracing::RecordedSpan_LogRecord_Field::InitAsDefaultInstance(); + ::cockroach::util::tracing::RecordedSpan::InitAsDefaultInstance(); } -::google::protobuf::internal::SCCInfo<0> scc_info_RecordedSpan_LogRecord_Field = - {{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsRecordedSpan_LogRecord_Field}, {}}; +::google::protobuf::internal::SCCInfo<6> scc_info_RecordedSpan = + {{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 6, InitDefaultsRecordedSpan}, { + &protobuf_util_2ftracing_2frecorded_5fspan_2eproto::scc_info_RecordedSpan_BaggageEntry_DoNotUse.base, + &protobuf_util_2ftracing_2frecorded_5fspan_2eproto::scc_info_RecordedSpan_TagsEntry_DoNotUse.base, + &protobuf_google_2fprotobuf_2ftimestamp_2eproto::scc_info_Timestamp.base, + &protobuf_google_2fprotobuf_2fduration_2eproto::scc_info_Duration.base, + &protobuf_util_2ftracing_2frecorded_5fspan_2eproto::scc_info_LogRecord.base, + &protobuf_google_2fprotobuf_2fany_2eproto::scc_info_Any.base,}}; -static void InitDefaultsRecordedSpan_LogRecord() { +static void InitDefaultsNormalizedSpan_TagsEntry_DoNotUse() { GOOGLE_PROTOBUF_VERIFY_VERSION; { - void* ptr = &::cockroach::util::tracing::_RecordedSpan_LogRecord_default_instance_; - new (ptr) ::cockroach::util::tracing::RecordedSpan_LogRecord(); - ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); + void* ptr = &::cockroach::util::tracing::_NormalizedSpan_TagsEntry_DoNotUse_default_instance_; + new (ptr) ::cockroach::util::tracing::NormalizedSpan_TagsEntry_DoNotUse(); } - ::cockroach::util::tracing::RecordedSpan_LogRecord::InitAsDefaultInstance(); + ::cockroach::util::tracing::NormalizedSpan_TagsEntry_DoNotUse::InitAsDefaultInstance(); } -::google::protobuf::internal::SCCInfo<2> scc_info_RecordedSpan_LogRecord = - {{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 2, InitDefaultsRecordedSpan_LogRecord}, { - &protobuf_google_2fprotobuf_2ftimestamp_2eproto::scc_info_Timestamp.base, - &protobuf_util_2ftracing_2frecorded_5fspan_2eproto::scc_info_RecordedSpan_LogRecord_Field.base,}}; +::google::protobuf::internal::SCCInfo<0> scc_info_NormalizedSpan_TagsEntry_DoNotUse = + {{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsNormalizedSpan_TagsEntry_DoNotUse}, {}}; -static void InitDefaultsRecordedSpan() { +static void InitDefaultsNormalizedSpan() { GOOGLE_PROTOBUF_VERIFY_VERSION; { - void* ptr = &::cockroach::util::tracing::_RecordedSpan_default_instance_; - new (ptr) ::cockroach::util::tracing::RecordedSpan(); + void* ptr = &::cockroach::util::tracing::_NormalizedSpan_default_instance_; + new (ptr) ::cockroach::util::tracing::NormalizedSpan(); ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); } - ::cockroach::util::tracing::RecordedSpan::InitAsDefaultInstance(); + ::cockroach::util::tracing::NormalizedSpan::InitAsDefaultInstance(); } -::google::protobuf::internal::SCCInfo<6> scc_info_RecordedSpan = - {{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 6, InitDefaultsRecordedSpan}, { - &protobuf_util_2ftracing_2frecorded_5fspan_2eproto::scc_info_RecordedSpan_BaggageEntry_DoNotUse.base, - &protobuf_util_2ftracing_2frecorded_5fspan_2eproto::scc_info_RecordedSpan_TagsEntry_DoNotUse.base, +::google::protobuf::internal::SCCInfo<4> scc_info_NormalizedSpan = + {{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 4, InitDefaultsNormalizedSpan}, { + &protobuf_util_2ftracing_2frecorded_5fspan_2eproto::scc_info_NormalizedSpan_TagsEntry_DoNotUse.base, &protobuf_google_2fprotobuf_2ftimestamp_2eproto::scc_info_Timestamp.base, &protobuf_google_2fprotobuf_2fduration_2eproto::scc_info_Duration.base, - &protobuf_util_2ftracing_2frecorded_5fspan_2eproto::scc_info_RecordedSpan_LogRecord.base, - &protobuf_google_2fprotobuf_2fany_2eproto::scc_info_Any.base,}}; + &protobuf_util_2ftracing_2frecorded_5fspan_2eproto::scc_info_LogRecord.base,}}; void InitDefaults() { + ::google::protobuf::internal::InitSCC(&scc_info_LogRecord_Field.base); + ::google::protobuf::internal::InitSCC(&scc_info_LogRecord.base); ::google::protobuf::internal::InitSCC(&scc_info_RecordedSpan_BaggageEntry_DoNotUse.base); ::google::protobuf::internal::InitSCC(&scc_info_RecordedSpan_TagsEntry_DoNotUse.base); - ::google::protobuf::internal::InitSCC(&scc_info_RecordedSpan_LogRecord_Field.base); - ::google::protobuf::internal::InitSCC(&scc_info_RecordedSpan_LogRecord.base); ::google::protobuf::internal::InitSCC(&scc_info_RecordedSpan.base); + ::google::protobuf::internal::InitSCC(&scc_info_NormalizedSpan_TagsEntry_DoNotUse.base); + ::google::protobuf::internal::InitSCC(&scc_info_NormalizedSpan.base); } } // namespace protobuf_util_2ftracing_2frecorded_5fspan_2eproto @@ -154,37 +199,21 @@ namespace tracing { // =================================================================== -RecordedSpan_BaggageEntry_DoNotUse::RecordedSpan_BaggageEntry_DoNotUse() {} -RecordedSpan_BaggageEntry_DoNotUse::RecordedSpan_BaggageEntry_DoNotUse(::google::protobuf::Arena* arena) : SuperType(arena) {} -void RecordedSpan_BaggageEntry_DoNotUse::MergeFrom(const RecordedSpan_BaggageEntry_DoNotUse& other) { - MergeFromInternal(other); -} - -// =================================================================== - -RecordedSpan_TagsEntry_DoNotUse::RecordedSpan_TagsEntry_DoNotUse() {} -RecordedSpan_TagsEntry_DoNotUse::RecordedSpan_TagsEntry_DoNotUse(::google::protobuf::Arena* arena) : SuperType(arena) {} -void RecordedSpan_TagsEntry_DoNotUse::MergeFrom(const RecordedSpan_TagsEntry_DoNotUse& other) { - MergeFromInternal(other); -} - -// =================================================================== - -void RecordedSpan_LogRecord_Field::InitAsDefaultInstance() { +void LogRecord_Field::InitAsDefaultInstance() { } #if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int RecordedSpan_LogRecord_Field::kKeyFieldNumber; -const int RecordedSpan_LogRecord_Field::kValueFieldNumber; +const int LogRecord_Field::kKeyFieldNumber; +const int LogRecord_Field::kValueFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 -RecordedSpan_LogRecord_Field::RecordedSpan_LogRecord_Field() +LogRecord_Field::LogRecord_Field() : ::google::protobuf::MessageLite(), _internal_metadata_(NULL) { ::google::protobuf::internal::InitSCC( - &protobuf_util_2ftracing_2frecorded_5fspan_2eproto::scc_info_RecordedSpan_LogRecord_Field.base); + &protobuf_util_2ftracing_2frecorded_5fspan_2eproto::scc_info_LogRecord_Field.base); SharedCtor(); - // @@protoc_insertion_point(constructor:cockroach.util.tracing.RecordedSpan.LogRecord.Field) + // @@protoc_insertion_point(constructor:cockroach.util.tracing.LogRecord.Field) } -RecordedSpan_LogRecord_Field::RecordedSpan_LogRecord_Field(const RecordedSpan_LogRecord_Field& from) +LogRecord_Field::LogRecord_Field(const LogRecord_Field& from) : ::google::protobuf::MessageLite(), _internal_metadata_(NULL) { _internal_metadata_.MergeFrom(from._internal_metadata_); @@ -196,35 +225,35 @@ RecordedSpan_LogRecord_Field::RecordedSpan_LogRecord_Field(const RecordedSpan_Lo if (from.value().size() > 0) { value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.value_); } - // @@protoc_insertion_point(copy_constructor:cockroach.util.tracing.RecordedSpan.LogRecord.Field) + // @@protoc_insertion_point(copy_constructor:cockroach.util.tracing.LogRecord.Field) } -void RecordedSpan_LogRecord_Field::SharedCtor() { +void LogRecord_Field::SharedCtor() { key_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } -RecordedSpan_LogRecord_Field::~RecordedSpan_LogRecord_Field() { - // @@protoc_insertion_point(destructor:cockroach.util.tracing.RecordedSpan.LogRecord.Field) +LogRecord_Field::~LogRecord_Field() { + // @@protoc_insertion_point(destructor:cockroach.util.tracing.LogRecord.Field) SharedDtor(); } -void RecordedSpan_LogRecord_Field::SharedDtor() { +void LogRecord_Field::SharedDtor() { key_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } -void RecordedSpan_LogRecord_Field::SetCachedSize(int size) const { +void LogRecord_Field::SetCachedSize(int size) const { _cached_size_.Set(size); } -const RecordedSpan_LogRecord_Field& RecordedSpan_LogRecord_Field::default_instance() { - ::google::protobuf::internal::InitSCC(&protobuf_util_2ftracing_2frecorded_5fspan_2eproto::scc_info_RecordedSpan_LogRecord_Field.base); +const LogRecord_Field& LogRecord_Field::default_instance() { + ::google::protobuf::internal::InitSCC(&protobuf_util_2ftracing_2frecorded_5fspan_2eproto::scc_info_LogRecord_Field.base); return *internal_default_instance(); } -void RecordedSpan_LogRecord_Field::Clear() { -// @@protoc_insertion_point(message_clear_start:cockroach.util.tracing.RecordedSpan.LogRecord.Field) +void LogRecord_Field::Clear() { +// @@protoc_insertion_point(message_clear_start:cockroach.util.tracing.LogRecord.Field) ::google::protobuf::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; @@ -234,7 +263,7 @@ void RecordedSpan_LogRecord_Field::Clear() { _internal_metadata_.Clear(); } -bool RecordedSpan_LogRecord_Field::MergePartialFromCodedStream( +bool LogRecord_Field::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; @@ -244,7 +273,7 @@ bool RecordedSpan_LogRecord_Field::MergePartialFromCodedStream( unknown_fields_setter.buffer()); ::google::protobuf::io::CodedOutputStream unknown_fields_stream( &unknown_fields_output, false); - // @@protoc_insertion_point(parse_start:cockroach.util.tracing.RecordedSpan.LogRecord.Field) + // @@protoc_insertion_point(parse_start:cockroach.util.tracing.LogRecord.Field) for (;;) { ::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; @@ -259,7 +288,7 @@ bool RecordedSpan_LogRecord_Field::MergePartialFromCodedStream( DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->key().data(), static_cast(this->key().length()), ::google::protobuf::internal::WireFormatLite::PARSE, - "cockroach.util.tracing.RecordedSpan.LogRecord.Field.key")); + "cockroach.util.tracing.LogRecord.Field.key")); } else { goto handle_unusual; } @@ -275,7 +304,7 @@ bool RecordedSpan_LogRecord_Field::MergePartialFromCodedStream( DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->value().data(), static_cast(this->value().length()), ::google::protobuf::internal::WireFormatLite::PARSE, - "cockroach.util.tracing.RecordedSpan.LogRecord.Field.value")); + "cockroach.util.tracing.LogRecord.Field.value")); } else { goto handle_unusual; } @@ -294,17 +323,17 @@ bool RecordedSpan_LogRecord_Field::MergePartialFromCodedStream( } } success: - // @@protoc_insertion_point(parse_success:cockroach.util.tracing.RecordedSpan.LogRecord.Field) + // @@protoc_insertion_point(parse_success:cockroach.util.tracing.LogRecord.Field) return true; failure: - // @@protoc_insertion_point(parse_failure:cockroach.util.tracing.RecordedSpan.LogRecord.Field) + // @@protoc_insertion_point(parse_failure:cockroach.util.tracing.LogRecord.Field) return false; #undef DO_ } -void RecordedSpan_LogRecord_Field::SerializeWithCachedSizes( +void LogRecord_Field::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { - // @@protoc_insertion_point(serialize_start:cockroach.util.tracing.RecordedSpan.LogRecord.Field) + // @@protoc_insertion_point(serialize_start:cockroach.util.tracing.LogRecord.Field) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -313,7 +342,7 @@ void RecordedSpan_LogRecord_Field::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->key().data(), static_cast(this->key().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, - "cockroach.util.tracing.RecordedSpan.LogRecord.Field.key"); + "cockroach.util.tracing.LogRecord.Field.key"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 1, this->key(), output); } @@ -323,18 +352,18 @@ void RecordedSpan_LogRecord_Field::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->value().data(), static_cast(this->value().length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, - "cockroach.util.tracing.RecordedSpan.LogRecord.Field.value"); + "cockroach.util.tracing.LogRecord.Field.value"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 2, this->value(), output); } output->WriteRaw((::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()).data(), static_cast((::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()).size())); - // @@protoc_insertion_point(serialize_end:cockroach.util.tracing.RecordedSpan.LogRecord.Field) + // @@protoc_insertion_point(serialize_end:cockroach.util.tracing.LogRecord.Field) } -size_t RecordedSpan_LogRecord_Field::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:cockroach.util.tracing.RecordedSpan.LogRecord.Field) +size_t LogRecord_Field::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:cockroach.util.tracing.LogRecord.Field) size_t total_size = 0; total_size += (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()).size(); @@ -358,13 +387,13 @@ size_t RecordedSpan_LogRecord_Field::ByteSizeLong() const { return total_size; } -void RecordedSpan_LogRecord_Field::CheckTypeAndMergeFrom( +void LogRecord_Field::CheckTypeAndMergeFrom( const ::google::protobuf::MessageLite& from) { - MergeFrom(*::google::protobuf::down_cast(&from)); + MergeFrom(*::google::protobuf::down_cast(&from)); } -void RecordedSpan_LogRecord_Field::MergeFrom(const RecordedSpan_LogRecord_Field& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:cockroach.util.tracing.RecordedSpan.LogRecord.Field) +void LogRecord_Field::MergeFrom(const LogRecord_Field& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:cockroach.util.tracing.LogRecord.Field) GOOGLE_DCHECK_NE(&from, this); _internal_metadata_.MergeFrom(from._internal_metadata_); ::google::protobuf::uint32 cached_has_bits = 0; @@ -380,22 +409,22 @@ void RecordedSpan_LogRecord_Field::MergeFrom(const RecordedSpan_LogRecord_Field& } } -void RecordedSpan_LogRecord_Field::CopyFrom(const RecordedSpan_LogRecord_Field& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:cockroach.util.tracing.RecordedSpan.LogRecord.Field) +void LogRecord_Field::CopyFrom(const LogRecord_Field& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:cockroach.util.tracing.LogRecord.Field) if (&from == this) return; Clear(); MergeFrom(from); } -bool RecordedSpan_LogRecord_Field::IsInitialized() const { +bool LogRecord_Field::IsInitialized() const { return true; } -void RecordedSpan_LogRecord_Field::Swap(RecordedSpan_LogRecord_Field* other) { +void LogRecord_Field::Swap(LogRecord_Field* other) { if (other == this) return; InternalSwap(other); } -void RecordedSpan_LogRecord_Field::InternalSwap(RecordedSpan_LogRecord_Field* other) { +void LogRecord_Field::InternalSwap(LogRecord_Field* other) { using std::swap; key_.Swap(&other->key_, &::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); @@ -404,36 +433,36 @@ void RecordedSpan_LogRecord_Field::InternalSwap(RecordedSpan_LogRecord_Field* ot _internal_metadata_.Swap(&other->_internal_metadata_); } -::std::string RecordedSpan_LogRecord_Field::GetTypeName() const { - return "cockroach.util.tracing.RecordedSpan.LogRecord.Field"; +::std::string LogRecord_Field::GetTypeName() const { + return "cockroach.util.tracing.LogRecord.Field"; } // =================================================================== -void RecordedSpan_LogRecord::InitAsDefaultInstance() { - ::cockroach::util::tracing::_RecordedSpan_LogRecord_default_instance_._instance.get_mutable()->time_ = const_cast< ::google::protobuf::Timestamp*>( +void LogRecord::InitAsDefaultInstance() { + ::cockroach::util::tracing::_LogRecord_default_instance_._instance.get_mutable()->time_ = const_cast< ::google::protobuf::Timestamp*>( ::google::protobuf::Timestamp::internal_default_instance()); } -void RecordedSpan_LogRecord::clear_time() { +void LogRecord::clear_time() { if (GetArenaNoVirtual() == NULL && time_ != NULL) { delete time_; } time_ = NULL; } #if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int RecordedSpan_LogRecord::kTimeFieldNumber; -const int RecordedSpan_LogRecord::kFieldsFieldNumber; +const int LogRecord::kTimeFieldNumber; +const int LogRecord::kFieldsFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 -RecordedSpan_LogRecord::RecordedSpan_LogRecord() +LogRecord::LogRecord() : ::google::protobuf::MessageLite(), _internal_metadata_(NULL) { ::google::protobuf::internal::InitSCC( - &protobuf_util_2ftracing_2frecorded_5fspan_2eproto::scc_info_RecordedSpan_LogRecord.base); + &protobuf_util_2ftracing_2frecorded_5fspan_2eproto::scc_info_LogRecord.base); SharedCtor(); - // @@protoc_insertion_point(constructor:cockroach.util.tracing.RecordedSpan.LogRecord) + // @@protoc_insertion_point(constructor:cockroach.util.tracing.LogRecord) } -RecordedSpan_LogRecord::RecordedSpan_LogRecord(const RecordedSpan_LogRecord& from) +LogRecord::LogRecord(const LogRecord& from) : ::google::protobuf::MessageLite(), _internal_metadata_(NULL), fields_(from.fields_) { @@ -443,33 +472,33 @@ RecordedSpan_LogRecord::RecordedSpan_LogRecord(const RecordedSpan_LogRecord& fro } else { time_ = NULL; } - // @@protoc_insertion_point(copy_constructor:cockroach.util.tracing.RecordedSpan.LogRecord) + // @@protoc_insertion_point(copy_constructor:cockroach.util.tracing.LogRecord) } -void RecordedSpan_LogRecord::SharedCtor() { +void LogRecord::SharedCtor() { time_ = NULL; } -RecordedSpan_LogRecord::~RecordedSpan_LogRecord() { - // @@protoc_insertion_point(destructor:cockroach.util.tracing.RecordedSpan.LogRecord) +LogRecord::~LogRecord() { + // @@protoc_insertion_point(destructor:cockroach.util.tracing.LogRecord) SharedDtor(); } -void RecordedSpan_LogRecord::SharedDtor() { +void LogRecord::SharedDtor() { if (this != internal_default_instance()) delete time_; } -void RecordedSpan_LogRecord::SetCachedSize(int size) const { +void LogRecord::SetCachedSize(int size) const { _cached_size_.Set(size); } -const RecordedSpan_LogRecord& RecordedSpan_LogRecord::default_instance() { - ::google::protobuf::internal::InitSCC(&protobuf_util_2ftracing_2frecorded_5fspan_2eproto::scc_info_RecordedSpan_LogRecord.base); +const LogRecord& LogRecord::default_instance() { + ::google::protobuf::internal::InitSCC(&protobuf_util_2ftracing_2frecorded_5fspan_2eproto::scc_info_LogRecord.base); return *internal_default_instance(); } -void RecordedSpan_LogRecord::Clear() { -// @@protoc_insertion_point(message_clear_start:cockroach.util.tracing.RecordedSpan.LogRecord) +void LogRecord::Clear() { +// @@protoc_insertion_point(message_clear_start:cockroach.util.tracing.LogRecord) ::google::protobuf::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; @@ -482,7 +511,7 @@ void RecordedSpan_LogRecord::Clear() { _internal_metadata_.Clear(); } -bool RecordedSpan_LogRecord::MergePartialFromCodedStream( +bool LogRecord::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; @@ -492,7 +521,7 @@ bool RecordedSpan_LogRecord::MergePartialFromCodedStream( unknown_fields_setter.buffer()); ::google::protobuf::io::CodedOutputStream unknown_fields_stream( &unknown_fields_output, false); - // @@protoc_insertion_point(parse_start:cockroach.util.tracing.RecordedSpan.LogRecord) + // @@protoc_insertion_point(parse_start:cockroach.util.tracing.LogRecord) for (;;) { ::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; @@ -532,17 +561,17 @@ bool RecordedSpan_LogRecord::MergePartialFromCodedStream( } } success: - // @@protoc_insertion_point(parse_success:cockroach.util.tracing.RecordedSpan.LogRecord) + // @@protoc_insertion_point(parse_success:cockroach.util.tracing.LogRecord) return true; failure: - // @@protoc_insertion_point(parse_failure:cockroach.util.tracing.RecordedSpan.LogRecord) + // @@protoc_insertion_point(parse_failure:cockroach.util.tracing.LogRecord) return false; #undef DO_ } -void RecordedSpan_LogRecord::SerializeWithCachedSizes( +void LogRecord::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { - // @@protoc_insertion_point(serialize_start:cockroach.util.tracing.RecordedSpan.LogRecord) + // @@protoc_insertion_point(serialize_start:cockroach.util.tracing.LogRecord) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; @@ -561,11 +590,11 @@ void RecordedSpan_LogRecord::SerializeWithCachedSizes( output->WriteRaw((::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()).data(), static_cast((::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()).size())); - // @@protoc_insertion_point(serialize_end:cockroach.util.tracing.RecordedSpan.LogRecord) + // @@protoc_insertion_point(serialize_end:cockroach.util.tracing.LogRecord) } -size_t RecordedSpan_LogRecord::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:cockroach.util.tracing.RecordedSpan.LogRecord) +size_t LogRecord::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:cockroach.util.tracing.LogRecord) size_t total_size = 0; total_size += (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()).size(); @@ -591,13 +620,13 @@ size_t RecordedSpan_LogRecord::ByteSizeLong() const { return total_size; } -void RecordedSpan_LogRecord::CheckTypeAndMergeFrom( +void LogRecord::CheckTypeAndMergeFrom( const ::google::protobuf::MessageLite& from) { - MergeFrom(*::google::protobuf::down_cast(&from)); + MergeFrom(*::google::protobuf::down_cast(&from)); } -void RecordedSpan_LogRecord::MergeFrom(const RecordedSpan_LogRecord& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:cockroach.util.tracing.RecordedSpan.LogRecord) +void LogRecord::MergeFrom(const LogRecord& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:cockroach.util.tracing.LogRecord) GOOGLE_DCHECK_NE(&from, this); _internal_metadata_.MergeFrom(from._internal_metadata_); ::google::protobuf::uint32 cached_has_bits = 0; @@ -609,33 +638,49 @@ void RecordedSpan_LogRecord::MergeFrom(const RecordedSpan_LogRecord& from) { } } -void RecordedSpan_LogRecord::CopyFrom(const RecordedSpan_LogRecord& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:cockroach.util.tracing.RecordedSpan.LogRecord) +void LogRecord::CopyFrom(const LogRecord& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:cockroach.util.tracing.LogRecord) if (&from == this) return; Clear(); MergeFrom(from); } -bool RecordedSpan_LogRecord::IsInitialized() const { +bool LogRecord::IsInitialized() const { return true; } -void RecordedSpan_LogRecord::Swap(RecordedSpan_LogRecord* other) { +void LogRecord::Swap(LogRecord* other) { if (other == this) return; InternalSwap(other); } -void RecordedSpan_LogRecord::InternalSwap(RecordedSpan_LogRecord* other) { +void LogRecord::InternalSwap(LogRecord* other) { using std::swap; CastToBase(&fields_)->InternalSwap(CastToBase(&other->fields_)); swap(time_, other->time_); _internal_metadata_.Swap(&other->_internal_metadata_); } -::std::string RecordedSpan_LogRecord::GetTypeName() const { - return "cockroach.util.tracing.RecordedSpan.LogRecord"; +::std::string LogRecord::GetTypeName() const { + return "cockroach.util.tracing.LogRecord"; } +// =================================================================== + +RecordedSpan_BaggageEntry_DoNotUse::RecordedSpan_BaggageEntry_DoNotUse() {} +RecordedSpan_BaggageEntry_DoNotUse::RecordedSpan_BaggageEntry_DoNotUse(::google::protobuf::Arena* arena) : SuperType(arena) {} +void RecordedSpan_BaggageEntry_DoNotUse::MergeFrom(const RecordedSpan_BaggageEntry_DoNotUse& other) { + MergeFromInternal(other); +} + +// =================================================================== + +RecordedSpan_TagsEntry_DoNotUse::RecordedSpan_TagsEntry_DoNotUse() {} +RecordedSpan_TagsEntry_DoNotUse::RecordedSpan_TagsEntry_DoNotUse(::google::protobuf::Arena* arena) : SuperType(arena) {} +void RecordedSpan_TagsEntry_DoNotUse::MergeFrom(const RecordedSpan_TagsEntry_DoNotUse& other) { + MergeFromInternal(other); +} + // =================================================================== void RecordedSpan::InitAsDefaultInstance() { @@ -1293,27 +1338,495 @@ ::std::string RecordedSpan::GetTypeName() const { } +// =================================================================== + +NormalizedSpan_TagsEntry_DoNotUse::NormalizedSpan_TagsEntry_DoNotUse() {} +NormalizedSpan_TagsEntry_DoNotUse::NormalizedSpan_TagsEntry_DoNotUse(::google::protobuf::Arena* arena) : SuperType(arena) {} +void NormalizedSpan_TagsEntry_DoNotUse::MergeFrom(const NormalizedSpan_TagsEntry_DoNotUse& other) { + MergeFromInternal(other); +} + +// =================================================================== + +void NormalizedSpan::InitAsDefaultInstance() { + ::cockroach::util::tracing::_NormalizedSpan_default_instance_._instance.get_mutable()->start_time_ = const_cast< ::google::protobuf::Timestamp*>( + ::google::protobuf::Timestamp::internal_default_instance()); + ::cockroach::util::tracing::_NormalizedSpan_default_instance_._instance.get_mutable()->duration_ = const_cast< ::google::protobuf::Duration*>( + ::google::protobuf::Duration::internal_default_instance()); +} +void NormalizedSpan::clear_start_time() { + if (GetArenaNoVirtual() == NULL && start_time_ != NULL) { + delete start_time_; + } + start_time_ = NULL; +} +void NormalizedSpan::clear_duration() { + if (GetArenaNoVirtual() == NULL && duration_ != NULL) { + delete duration_; + } + duration_ = NULL; +} +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int NormalizedSpan::kOperationFieldNumber; +const int NormalizedSpan::kTagsFieldNumber; +const int NormalizedSpan::kStartTimeFieldNumber; +const int NormalizedSpan::kDurationFieldNumber; +const int NormalizedSpan::kLogsFieldNumber; +const int NormalizedSpan::kChildrenFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 + +NormalizedSpan::NormalizedSpan() + : ::google::protobuf::MessageLite(), _internal_metadata_(NULL) { + ::google::protobuf::internal::InitSCC( + &protobuf_util_2ftracing_2frecorded_5fspan_2eproto::scc_info_NormalizedSpan.base); + SharedCtor(); + // @@protoc_insertion_point(constructor:cockroach.util.tracing.NormalizedSpan) +} +NormalizedSpan::NormalizedSpan(const NormalizedSpan& from) + : ::google::protobuf::MessageLite(), + _internal_metadata_(NULL), + logs_(from.logs_), + children_(from.children_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + tags_.MergeFrom(from.tags_); + operation_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.operation().size() > 0) { + operation_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.operation_); + } + if (from.has_start_time()) { + start_time_ = new ::google::protobuf::Timestamp(*from.start_time_); + } else { + start_time_ = NULL; + } + if (from.has_duration()) { + duration_ = new ::google::protobuf::Duration(*from.duration_); + } else { + duration_ = NULL; + } + // @@protoc_insertion_point(copy_constructor:cockroach.util.tracing.NormalizedSpan) +} + +void NormalizedSpan::SharedCtor() { + operation_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + ::memset(&start_time_, 0, static_cast( + reinterpret_cast(&duration_) - + reinterpret_cast(&start_time_)) + sizeof(duration_)); +} + +NormalizedSpan::~NormalizedSpan() { + // @@protoc_insertion_point(destructor:cockroach.util.tracing.NormalizedSpan) + SharedDtor(); +} + +void NormalizedSpan::SharedDtor() { + operation_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (this != internal_default_instance()) delete start_time_; + if (this != internal_default_instance()) delete duration_; +} + +void NormalizedSpan::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const NormalizedSpan& NormalizedSpan::default_instance() { + ::google::protobuf::internal::InitSCC(&protobuf_util_2ftracing_2frecorded_5fspan_2eproto::scc_info_NormalizedSpan.base); + return *internal_default_instance(); +} + + +void NormalizedSpan::Clear() { +// @@protoc_insertion_point(message_clear_start:cockroach.util.tracing.NormalizedSpan) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + tags_.Clear(); + logs_.Clear(); + children_.Clear(); + operation_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (GetArenaNoVirtual() == NULL && start_time_ != NULL) { + delete start_time_; + } + start_time_ = NULL; + if (GetArenaNoVirtual() == NULL && duration_ != NULL) { + delete duration_; + } + duration_ = NULL; + _internal_metadata_.Clear(); +} + +bool NormalizedSpan::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + ::google::protobuf::internal::LiteUnknownFieldSetter unknown_fields_setter( + &_internal_metadata_); + ::google::protobuf::io::StringOutputStream unknown_fields_output( + unknown_fields_setter.buffer()); + ::google::protobuf::io::CodedOutputStream unknown_fields_stream( + &unknown_fields_output, false); + // @@protoc_insertion_point(parse_start:cockroach.util.tracing.NormalizedSpan) + for (;;) { + ::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // string operation = 1; + case 1: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_operation())); + DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->operation().data(), static_cast(this->operation().length()), + ::google::protobuf::internal::WireFormatLite::PARSE, + "cockroach.util.tracing.NormalizedSpan.operation")); + } else { + goto handle_unusual; + } + break; + } + + // map tags = 2; + case 2: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) { + NormalizedSpan_TagsEntry_DoNotUse::Parser< ::google::protobuf::internal::MapFieldLite< + NormalizedSpan_TagsEntry_DoNotUse, + ::std::string, ::std::string, + ::google::protobuf::internal::WireFormatLite::TYPE_STRING, + ::google::protobuf::internal::WireFormatLite::TYPE_STRING, + 0 >, + ::google::protobuf::Map< ::std::string, ::std::string > > parser(&tags_); + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + input, &parser)); + DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + parser.key().data(), static_cast(parser.key().length()), + ::google::protobuf::internal::WireFormatLite::PARSE, + "cockroach.util.tracing.NormalizedSpan.TagsEntry.key")); + DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + parser.value().data(), static_cast(parser.value().length()), + ::google::protobuf::internal::WireFormatLite::PARSE, + "cockroach.util.tracing.NormalizedSpan.TagsEntry.value")); + } else { + goto handle_unusual; + } + break; + } + + case 3: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( + input, mutable_start_time())); + } else { + goto handle_unusual; + } + break; + } + + case 4: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(34u /* 34 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( + input, mutable_duration())); + } else { + goto handle_unusual; + } + break; + } + + case 5: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(42u /* 42 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( + input, add_logs())); + } else { + goto handle_unusual; + } + break; + } + + case 6: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(50u /* 50 & 0xFF */)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( + input, add_children())); + } else { + goto handle_unusual; + } + break; + } + + default: { + handle_unusual: + if (tag == 0) { + goto success; + } + DO_(::google::protobuf::internal::WireFormatLite::SkipField( + input, tag, &unknown_fields_stream)); + break; + } + } + } +success: + // @@protoc_insertion_point(parse_success:cockroach.util.tracing.NormalizedSpan) + return true; +failure: + // @@protoc_insertion_point(parse_failure:cockroach.util.tracing.NormalizedSpan) + return false; +#undef DO_ +} + +void NormalizedSpan::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:cockroach.util.tracing.NormalizedSpan) + ::google::protobuf::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + // string operation = 1; + if (this->operation().size() > 0) { + ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + this->operation().data(), static_cast(this->operation().length()), + ::google::protobuf::internal::WireFormatLite::SERIALIZE, + "cockroach.util.tracing.NormalizedSpan.operation"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 1, this->operation(), output); + } + + // map tags = 2; + if (!this->tags().empty()) { + typedef ::google::protobuf::Map< ::std::string, ::std::string >::const_pointer + ConstPtr; + typedef ConstPtr SortItem; + typedef ::google::protobuf::internal::CompareByDerefFirst Less; + struct Utf8Check { + static void Check(ConstPtr p) { + ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + p->first.data(), static_cast(p->first.length()), + ::google::protobuf::internal::WireFormatLite::SERIALIZE, + "cockroach.util.tracing.NormalizedSpan.TagsEntry.key"); + ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( + p->second.data(), static_cast(p->second.length()), + ::google::protobuf::internal::WireFormatLite::SERIALIZE, + "cockroach.util.tracing.NormalizedSpan.TagsEntry.value"); + } + }; + + if (output->IsSerializationDeterministic() && + this->tags().size() > 1) { + ::std::unique_ptr items( + new SortItem[this->tags().size()]); + typedef ::google::protobuf::Map< ::std::string, ::std::string >::size_type size_type; + size_type n = 0; + for (::google::protobuf::Map< ::std::string, ::std::string >::const_iterator + it = this->tags().begin(); + it != this->tags().end(); ++it, ++n) { + items[static_cast(n)] = SortItem(&*it); + } + ::std::sort(&items[0], &items[static_cast(n)], Less()); + ::std::unique_ptr entry; + for (size_type i = 0; i < n; i++) { + entry.reset(tags_.NewEntryWrapper( + items[static_cast(i)]->first, items[static_cast(i)]->second)); + ::google::protobuf::internal::WireFormatLite::WriteMessage( + 2, *entry, output); + Utf8Check::Check(items[static_cast(i)]); + } + } else { + ::std::unique_ptr entry; + for (::google::protobuf::Map< ::std::string, ::std::string >::const_iterator + it = this->tags().begin(); + it != this->tags().end(); ++it) { + entry.reset(tags_.NewEntryWrapper( + it->first, it->second)); + ::google::protobuf::internal::WireFormatLite::WriteMessage( + 2, *entry, output); + Utf8Check::Check(&*it); + } + } + } + + if (this->has_start_time()) { + ::google::protobuf::internal::WireFormatLite::WriteMessage( + 3, this->_internal_start_time(), output); + } + + if (this->has_duration()) { + ::google::protobuf::internal::WireFormatLite::WriteMessage( + 4, this->_internal_duration(), output); + } + + for (unsigned int i = 0, + n = static_cast(this->logs_size()); i < n; i++) { + ::google::protobuf::internal::WireFormatLite::WriteMessage( + 5, + this->logs(static_cast(i)), + output); + } + + for (unsigned int i = 0, + n = static_cast(this->children_size()); i < n; i++) { + ::google::protobuf::internal::WireFormatLite::WriteMessage( + 6, + this->children(static_cast(i)), + output); + } + + output->WriteRaw((::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()).data(), + static_cast((::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()).size())); + // @@protoc_insertion_point(serialize_end:cockroach.util.tracing.NormalizedSpan) +} + +size_t NormalizedSpan::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:cockroach.util.tracing.NormalizedSpan) + size_t total_size = 0; + + total_size += (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()).size(); + + // map tags = 2; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->tags_size()); + { + ::std::unique_ptr entry; + for (::google::protobuf::Map< ::std::string, ::std::string >::const_iterator + it = this->tags().begin(); + it != this->tags().end(); ++it) { + entry.reset(tags_.NewEntryWrapper(it->first, it->second)); + total_size += ::google::protobuf::internal::WireFormatLite:: + MessageSizeNoVirtual(*entry); + } + } + + { + unsigned int count = static_cast(this->logs_size()); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->logs(static_cast(i))); + } + } + + { + unsigned int count = static_cast(this->children_size()); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSize( + this->children(static_cast(i))); + } + } + + // string operation = 1; + if (this->operation().size() > 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->operation()); + } + + if (this->has_start_time()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSize( + *start_time_); + } + + if (this->has_duration()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSize( + *duration_); + } + + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void NormalizedSpan::CheckTypeAndMergeFrom( + const ::google::protobuf::MessageLite& from) { + MergeFrom(*::google::protobuf::down_cast(&from)); +} + +void NormalizedSpan::MergeFrom(const NormalizedSpan& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:cockroach.util.tracing.NormalizedSpan) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + ::google::protobuf::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + tags_.MergeFrom(from.tags_); + logs_.MergeFrom(from.logs_); + children_.MergeFrom(from.children_); + if (from.operation().size() > 0) { + + operation_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.operation_); + } + if (from.has_start_time()) { + mutable_start_time()->::google::protobuf::Timestamp::MergeFrom(from.start_time()); + } + if (from.has_duration()) { + mutable_duration()->::google::protobuf::Duration::MergeFrom(from.duration()); + } +} + +void NormalizedSpan::CopyFrom(const NormalizedSpan& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:cockroach.util.tracing.NormalizedSpan) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool NormalizedSpan::IsInitialized() const { + return true; +} + +void NormalizedSpan::Swap(NormalizedSpan* other) { + if (other == this) return; + InternalSwap(other); +} +void NormalizedSpan::InternalSwap(NormalizedSpan* other) { + using std::swap; + tags_.Swap(&other->tags_); + CastToBase(&logs_)->InternalSwap(CastToBase(&other->logs_)); + CastToBase(&children_)->InternalSwap(CastToBase(&other->children_)); + operation_.Swap(&other->operation_, &::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); + swap(start_time_, other->start_time_); + swap(duration_, other->duration_); + _internal_metadata_.Swap(&other->_internal_metadata_); +} + +::std::string NormalizedSpan::GetTypeName() const { + return "cockroach.util.tracing.NormalizedSpan"; +} + + // @@protoc_insertion_point(namespace_scope) } // namespace tracing } // namespace util } // namespace cockroach namespace google { namespace protobuf { +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::cockroach::util::tracing::LogRecord_Field* Arena::CreateMaybeMessage< ::cockroach::util::tracing::LogRecord_Field >(Arena* arena) { + return Arena::CreateInternal< ::cockroach::util::tracing::LogRecord_Field >(arena); +} +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::cockroach::util::tracing::LogRecord* Arena::CreateMaybeMessage< ::cockroach::util::tracing::LogRecord >(Arena* arena) { + return Arena::CreateInternal< ::cockroach::util::tracing::LogRecord >(arena); +} template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::cockroach::util::tracing::RecordedSpan_BaggageEntry_DoNotUse* Arena::CreateMaybeMessage< ::cockroach::util::tracing::RecordedSpan_BaggageEntry_DoNotUse >(Arena* arena) { return Arena::CreateInternal< ::cockroach::util::tracing::RecordedSpan_BaggageEntry_DoNotUse >(arena); } template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::cockroach::util::tracing::RecordedSpan_TagsEntry_DoNotUse* Arena::CreateMaybeMessage< ::cockroach::util::tracing::RecordedSpan_TagsEntry_DoNotUse >(Arena* arena) { return Arena::CreateInternal< ::cockroach::util::tracing::RecordedSpan_TagsEntry_DoNotUse >(arena); } -template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::cockroach::util::tracing::RecordedSpan_LogRecord_Field* Arena::CreateMaybeMessage< ::cockroach::util::tracing::RecordedSpan_LogRecord_Field >(Arena* arena) { - return Arena::CreateInternal< ::cockroach::util::tracing::RecordedSpan_LogRecord_Field >(arena); -} -template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::cockroach::util::tracing::RecordedSpan_LogRecord* Arena::CreateMaybeMessage< ::cockroach::util::tracing::RecordedSpan_LogRecord >(Arena* arena) { - return Arena::CreateInternal< ::cockroach::util::tracing::RecordedSpan_LogRecord >(arena); -} template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::cockroach::util::tracing::RecordedSpan* Arena::CreateMaybeMessage< ::cockroach::util::tracing::RecordedSpan >(Arena* arena) { return Arena::CreateInternal< ::cockroach::util::tracing::RecordedSpan >(arena); } +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::cockroach::util::tracing::NormalizedSpan_TagsEntry_DoNotUse* Arena::CreateMaybeMessage< ::cockroach::util::tracing::NormalizedSpan_TagsEntry_DoNotUse >(Arena* arena) { + return Arena::CreateInternal< ::cockroach::util::tracing::NormalizedSpan_TagsEntry_DoNotUse >(arena); +} +template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::cockroach::util::tracing::NormalizedSpan* Arena::CreateMaybeMessage< ::cockroach::util::tracing::NormalizedSpan >(Arena* arena) { + return Arena::CreateInternal< ::cockroach::util::tracing::NormalizedSpan >(arena); +} } // namespace protobuf } // namespace google diff --git a/c-deps/libroach/protos/util/tracing/recorded_span.pb.h b/c-deps/libroach/protos/util/tracing/recorded_span.pb.h index 9e428fd3c4d0..ff88832b9998 100644 --- a/c-deps/libroach/protos/util/tracing/recorded_span.pb.h +++ b/c-deps/libroach/protos/util/tracing/recorded_span.pb.h @@ -43,7 +43,7 @@ namespace protobuf_util_2ftracing_2frecorded_5fspan_2eproto { struct TableStruct { static const ::google::protobuf::internal::ParseTableField entries[]; static const ::google::protobuf::internal::AuxillaryParseTableField aux[]; - static const ::google::protobuf::internal::ParseTable schema[5]; + static const ::google::protobuf::internal::ParseTable schema[7]; static const ::google::protobuf::internal::FieldMetadata field_metadata[]; static const ::google::protobuf::internal::SerializationTable serialization_table[]; static const ::google::protobuf::uint32 offsets[]; @@ -52,18 +52,24 @@ struct TableStruct { namespace cockroach { namespace util { namespace tracing { +class LogRecord; +class LogRecordDefaultTypeInternal; +extern LogRecordDefaultTypeInternal _LogRecord_default_instance_; +class LogRecord_Field; +class LogRecord_FieldDefaultTypeInternal; +extern LogRecord_FieldDefaultTypeInternal _LogRecord_Field_default_instance_; +class NormalizedSpan; +class NormalizedSpanDefaultTypeInternal; +extern NormalizedSpanDefaultTypeInternal _NormalizedSpan_default_instance_; +class NormalizedSpan_TagsEntry_DoNotUse; +class NormalizedSpan_TagsEntry_DoNotUseDefaultTypeInternal; +extern NormalizedSpan_TagsEntry_DoNotUseDefaultTypeInternal _NormalizedSpan_TagsEntry_DoNotUse_default_instance_; class RecordedSpan; class RecordedSpanDefaultTypeInternal; extern RecordedSpanDefaultTypeInternal _RecordedSpan_default_instance_; class RecordedSpan_BaggageEntry_DoNotUse; class RecordedSpan_BaggageEntry_DoNotUseDefaultTypeInternal; extern RecordedSpan_BaggageEntry_DoNotUseDefaultTypeInternal _RecordedSpan_BaggageEntry_DoNotUse_default_instance_; -class RecordedSpan_LogRecord; -class RecordedSpan_LogRecordDefaultTypeInternal; -extern RecordedSpan_LogRecordDefaultTypeInternal _RecordedSpan_LogRecord_default_instance_; -class RecordedSpan_LogRecord_Field; -class RecordedSpan_LogRecord_FieldDefaultTypeInternal; -extern RecordedSpan_LogRecord_FieldDefaultTypeInternal _RecordedSpan_LogRecord_Field_default_instance_; class RecordedSpan_TagsEntry_DoNotUse; class RecordedSpan_TagsEntry_DoNotUseDefaultTypeInternal; extern RecordedSpan_TagsEntry_DoNotUseDefaultTypeInternal _RecordedSpan_TagsEntry_DoNotUse_default_instance_; @@ -72,10 +78,12 @@ extern RecordedSpan_TagsEntry_DoNotUseDefaultTypeInternal _RecordedSpan_TagsEntr } // namespace cockroach namespace google { namespace protobuf { +template<> ::cockroach::util::tracing::LogRecord* Arena::CreateMaybeMessage<::cockroach::util::tracing::LogRecord>(Arena*); +template<> ::cockroach::util::tracing::LogRecord_Field* Arena::CreateMaybeMessage<::cockroach::util::tracing::LogRecord_Field>(Arena*); +template<> ::cockroach::util::tracing::NormalizedSpan* Arena::CreateMaybeMessage<::cockroach::util::tracing::NormalizedSpan>(Arena*); +template<> ::cockroach::util::tracing::NormalizedSpan_TagsEntry_DoNotUse* Arena::CreateMaybeMessage<::cockroach::util::tracing::NormalizedSpan_TagsEntry_DoNotUse>(Arena*); template<> ::cockroach::util::tracing::RecordedSpan* Arena::CreateMaybeMessage<::cockroach::util::tracing::RecordedSpan>(Arena*); template<> ::cockroach::util::tracing::RecordedSpan_BaggageEntry_DoNotUse* Arena::CreateMaybeMessage<::cockroach::util::tracing::RecordedSpan_BaggageEntry_DoNotUse>(Arena*); -template<> ::cockroach::util::tracing::RecordedSpan_LogRecord* Arena::CreateMaybeMessage<::cockroach::util::tracing::RecordedSpan_LogRecord>(Arena*); -template<> ::cockroach::util::tracing::RecordedSpan_LogRecord_Field* Arena::CreateMaybeMessage<::cockroach::util::tracing::RecordedSpan_LogRecord_Field>(Arena*); template<> ::cockroach::util::tracing::RecordedSpan_TagsEntry_DoNotUse* Arena::CreateMaybeMessage<::cockroach::util::tracing::RecordedSpan_TagsEntry_DoNotUse>(Arena*); } // namespace protobuf } // namespace google @@ -85,62 +93,24 @@ namespace tracing { // =================================================================== -class RecordedSpan_BaggageEntry_DoNotUse : public ::google::protobuf::internal::MapEntryLite { -public: - typedef ::google::protobuf::internal::MapEntryLite SuperType; - RecordedSpan_BaggageEntry_DoNotUse(); - RecordedSpan_BaggageEntry_DoNotUse(::google::protobuf::Arena* arena); - void MergeFrom(const RecordedSpan_BaggageEntry_DoNotUse& other); - static const RecordedSpan_BaggageEntry_DoNotUse* internal_default_instance() { return reinterpret_cast(&_RecordedSpan_BaggageEntry_DoNotUse_default_instance_); } -}; - -// ------------------------------------------------------------------- - -class RecordedSpan_TagsEntry_DoNotUse : public ::google::protobuf::internal::MapEntryLite { -public: - typedef ::google::protobuf::internal::MapEntryLite SuperType; - RecordedSpan_TagsEntry_DoNotUse(); - RecordedSpan_TagsEntry_DoNotUse(::google::protobuf::Arena* arena); - void MergeFrom(const RecordedSpan_TagsEntry_DoNotUse& other); - static const RecordedSpan_TagsEntry_DoNotUse* internal_default_instance() { return reinterpret_cast(&_RecordedSpan_TagsEntry_DoNotUse_default_instance_); } -}; - -// ------------------------------------------------------------------- - -class RecordedSpan_LogRecord_Field : public ::google::protobuf::MessageLite /* @@protoc_insertion_point(class_definition:cockroach.util.tracing.RecordedSpan.LogRecord.Field) */ { +class LogRecord_Field : public ::google::protobuf::MessageLite /* @@protoc_insertion_point(class_definition:cockroach.util.tracing.LogRecord.Field) */ { public: - RecordedSpan_LogRecord_Field(); - virtual ~RecordedSpan_LogRecord_Field(); + LogRecord_Field(); + virtual ~LogRecord_Field(); - RecordedSpan_LogRecord_Field(const RecordedSpan_LogRecord_Field& from); + LogRecord_Field(const LogRecord_Field& from); - inline RecordedSpan_LogRecord_Field& operator=(const RecordedSpan_LogRecord_Field& from) { + inline LogRecord_Field& operator=(const LogRecord_Field& from) { CopyFrom(from); return *this; } #if LANG_CXX11 - RecordedSpan_LogRecord_Field(RecordedSpan_LogRecord_Field&& from) noexcept - : RecordedSpan_LogRecord_Field() { + LogRecord_Field(LogRecord_Field&& from) noexcept + : LogRecord_Field() { *this = ::std::move(from); } - inline RecordedSpan_LogRecord_Field& operator=(RecordedSpan_LogRecord_Field&& from) noexcept { + inline LogRecord_Field& operator=(LogRecord_Field&& from) noexcept { if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { if (this != &from) InternalSwap(&from); } else { @@ -149,34 +119,34 @@ class RecordedSpan_LogRecord_Field : public ::google::protobuf::MessageLite /* @ return *this; } #endif - static const RecordedSpan_LogRecord_Field& default_instance(); + static const LogRecord_Field& default_instance(); static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY - static inline const RecordedSpan_LogRecord_Field* internal_default_instance() { - return reinterpret_cast( - &_RecordedSpan_LogRecord_Field_default_instance_); + static inline const LogRecord_Field* internal_default_instance() { + return reinterpret_cast( + &_LogRecord_Field_default_instance_); } static constexpr int kIndexInFileMessages = - 2; + 0; - void Swap(RecordedSpan_LogRecord_Field* other); - friend void swap(RecordedSpan_LogRecord_Field& a, RecordedSpan_LogRecord_Field& b) { + void Swap(LogRecord_Field* other); + friend void swap(LogRecord_Field& a, LogRecord_Field& b) { a.Swap(&b); } // implements Message ---------------------------------------------- - inline RecordedSpan_LogRecord_Field* New() const final { - return CreateMaybeMessage(NULL); + inline LogRecord_Field* New() const final { + return CreateMaybeMessage(NULL); } - RecordedSpan_LogRecord_Field* New(::google::protobuf::Arena* arena) const final { - return CreateMaybeMessage(arena); + LogRecord_Field* New(::google::protobuf::Arena* arena) const final { + return CreateMaybeMessage(arena); } void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from) final; - void CopyFrom(const RecordedSpan_LogRecord_Field& from); - void MergeFrom(const RecordedSpan_LogRecord_Field& from); + void CopyFrom(const LogRecord_Field& from); + void MergeFrom(const LogRecord_Field& from); void Clear() final; bool IsInitialized() const final; @@ -192,7 +162,7 @@ class RecordedSpan_LogRecord_Field : public ::google::protobuf::MessageLite /* @ void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; - void InternalSwap(RecordedSpan_LogRecord_Field* other); + void InternalSwap(LogRecord_Field* other); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return NULL; @@ -236,7 +206,7 @@ class RecordedSpan_LogRecord_Field : public ::google::protobuf::MessageLite /* @ ::std::string* release_value(); void set_allocated_value(::std::string* value); - // @@protoc_insertion_point(class_scope:cockroach.util.tracing.RecordedSpan.LogRecord.Field) + // @@protoc_insertion_point(class_scope:cockroach.util.tracing.LogRecord.Field) private: ::google::protobuf::internal::InternalMetadataWithArenaLite _internal_metadata_; @@ -247,24 +217,24 @@ class RecordedSpan_LogRecord_Field : public ::google::protobuf::MessageLite /* @ }; // ------------------------------------------------------------------- -class RecordedSpan_LogRecord : public ::google::protobuf::MessageLite /* @@protoc_insertion_point(class_definition:cockroach.util.tracing.RecordedSpan.LogRecord) */ { +class LogRecord : public ::google::protobuf::MessageLite /* @@protoc_insertion_point(class_definition:cockroach.util.tracing.LogRecord) */ { public: - RecordedSpan_LogRecord(); - virtual ~RecordedSpan_LogRecord(); + LogRecord(); + virtual ~LogRecord(); - RecordedSpan_LogRecord(const RecordedSpan_LogRecord& from); + LogRecord(const LogRecord& from); - inline RecordedSpan_LogRecord& operator=(const RecordedSpan_LogRecord& from) { + inline LogRecord& operator=(const LogRecord& from) { CopyFrom(from); return *this; } #if LANG_CXX11 - RecordedSpan_LogRecord(RecordedSpan_LogRecord&& from) noexcept - : RecordedSpan_LogRecord() { + LogRecord(LogRecord&& from) noexcept + : LogRecord() { *this = ::std::move(from); } - inline RecordedSpan_LogRecord& operator=(RecordedSpan_LogRecord&& from) noexcept { + inline LogRecord& operator=(LogRecord&& from) noexcept { if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { if (this != &from) InternalSwap(&from); } else { @@ -273,34 +243,34 @@ class RecordedSpan_LogRecord : public ::google::protobuf::MessageLite /* @@proto return *this; } #endif - static const RecordedSpan_LogRecord& default_instance(); + static const LogRecord& default_instance(); static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY - static inline const RecordedSpan_LogRecord* internal_default_instance() { - return reinterpret_cast( - &_RecordedSpan_LogRecord_default_instance_); + static inline const LogRecord* internal_default_instance() { + return reinterpret_cast( + &_LogRecord_default_instance_); } static constexpr int kIndexInFileMessages = - 3; + 1; - void Swap(RecordedSpan_LogRecord* other); - friend void swap(RecordedSpan_LogRecord& a, RecordedSpan_LogRecord& b) { + void Swap(LogRecord* other); + friend void swap(LogRecord& a, LogRecord& b) { a.Swap(&b); } // implements Message ---------------------------------------------- - inline RecordedSpan_LogRecord* New() const final { - return CreateMaybeMessage(NULL); + inline LogRecord* New() const final { + return CreateMaybeMessage(NULL); } - RecordedSpan_LogRecord* New(::google::protobuf::Arena* arena) const final { - return CreateMaybeMessage(arena); + LogRecord* New(::google::protobuf::Arena* arena) const final { + return CreateMaybeMessage(arena); } void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from) final; - void CopyFrom(const RecordedSpan_LogRecord& from); - void MergeFrom(const RecordedSpan_LogRecord& from); + void CopyFrom(const LogRecord& from); + void MergeFrom(const LogRecord& from); void Clear() final; bool IsInitialized() const final; @@ -316,7 +286,7 @@ class RecordedSpan_LogRecord : public ::google::protobuf::MessageLite /* @@proto void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; - void InternalSwap(RecordedSpan_LogRecord* other); + void InternalSwap(LogRecord* other); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return NULL; @@ -330,19 +300,19 @@ class RecordedSpan_LogRecord : public ::google::protobuf::MessageLite /* @@proto // nested types ---------------------------------------------------- - typedef RecordedSpan_LogRecord_Field Field; + typedef LogRecord_Field Field; // accessors ------------------------------------------------------- int fields_size() const; void clear_fields(); static const int kFieldsFieldNumber = 2; - ::cockroach::util::tracing::RecordedSpan_LogRecord_Field* mutable_fields(int index); - ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::RecordedSpan_LogRecord_Field >* + ::cockroach::util::tracing::LogRecord_Field* mutable_fields(int index); + ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::LogRecord_Field >* mutable_fields(); - const ::cockroach::util::tracing::RecordedSpan_LogRecord_Field& fields(int index) const; - ::cockroach::util::tracing::RecordedSpan_LogRecord_Field* add_fields(); - const ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::RecordedSpan_LogRecord_Field >& + const ::cockroach::util::tracing::LogRecord_Field& fields(int index) const; + ::cockroach::util::tracing::LogRecord_Field* add_fields(); + const ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::LogRecord_Field >& fields() const; bool has_time() const; @@ -356,17 +326,55 @@ class RecordedSpan_LogRecord : public ::google::protobuf::MessageLite /* @@proto ::google::protobuf::Timestamp* mutable_time(); void set_allocated_time(::google::protobuf::Timestamp* time); - // @@protoc_insertion_point(class_scope:cockroach.util.tracing.RecordedSpan.LogRecord) + // @@protoc_insertion_point(class_scope:cockroach.util.tracing.LogRecord) private: ::google::protobuf::internal::InternalMetadataWithArenaLite _internal_metadata_; - ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::RecordedSpan_LogRecord_Field > fields_; + ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::LogRecord_Field > fields_; ::google::protobuf::Timestamp* time_; mutable ::google::protobuf::internal::CachedSize _cached_size_; friend struct ::protobuf_util_2ftracing_2frecorded_5fspan_2eproto::TableStruct; }; // ------------------------------------------------------------------- +class RecordedSpan_BaggageEntry_DoNotUse : public ::google::protobuf::internal::MapEntryLite { +public: + typedef ::google::protobuf::internal::MapEntryLite SuperType; + RecordedSpan_BaggageEntry_DoNotUse(); + RecordedSpan_BaggageEntry_DoNotUse(::google::protobuf::Arena* arena); + void MergeFrom(const RecordedSpan_BaggageEntry_DoNotUse& other); + static const RecordedSpan_BaggageEntry_DoNotUse* internal_default_instance() { return reinterpret_cast(&_RecordedSpan_BaggageEntry_DoNotUse_default_instance_); } +}; + +// ------------------------------------------------------------------- + +class RecordedSpan_TagsEntry_DoNotUse : public ::google::protobuf::internal::MapEntryLite { +public: + typedef ::google::protobuf::internal::MapEntryLite SuperType; + RecordedSpan_TagsEntry_DoNotUse(); + RecordedSpan_TagsEntry_DoNotUse(::google::protobuf::Arena* arena); + void MergeFrom(const RecordedSpan_TagsEntry_DoNotUse& other); + static const RecordedSpan_TagsEntry_DoNotUse* internal_default_instance() { return reinterpret_cast(&_RecordedSpan_TagsEntry_DoNotUse_default_instance_); } +}; + +// ------------------------------------------------------------------- + class RecordedSpan : public ::google::protobuf::MessageLite /* @@protoc_insertion_point(class_definition:cockroach.util.tracing.RecordedSpan) */ { public: RecordedSpan(); @@ -450,7 +458,6 @@ class RecordedSpan : public ::google::protobuf::MessageLite /* @@protoc_insertio // nested types ---------------------------------------------------- - typedef RecordedSpan_LogRecord LogRecord; // accessors ------------------------------------------------------- @@ -475,12 +482,12 @@ class RecordedSpan : public ::google::protobuf::MessageLite /* @@protoc_insertio int logs_size() const; void clear_logs(); static const int kLogsFieldNumber = 9; - ::cockroach::util::tracing::RecordedSpan_LogRecord* mutable_logs(int index); - ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::RecordedSpan_LogRecord >* + ::cockroach::util::tracing::LogRecord* mutable_logs(int index); + ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::LogRecord >* mutable_logs(); - const ::cockroach::util::tracing::RecordedSpan_LogRecord& logs(int index) const; - ::cockroach::util::tracing::RecordedSpan_LogRecord* add_logs(); - const ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::RecordedSpan_LogRecord >& + const ::cockroach::util::tracing::LogRecord& logs(int index) const; + ::cockroach::util::tracing::LogRecord* add_logs(); + const ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::LogRecord >& logs() const; // string operation = 4; @@ -562,7 +569,7 @@ class RecordedSpan : public ::google::protobuf::MessageLite /* @@protoc_insertio ::google::protobuf::internal::WireFormatLite::TYPE_STRING, ::google::protobuf::internal::WireFormatLite::TYPE_STRING, 0 > tags_; - ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::RecordedSpan_LogRecord > logs_; + ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::LogRecord > logs_; ::google::protobuf::internal::ArenaStringPtr operation_; ::google::protobuf::Timestamp* start_time_; ::google::protobuf::Duration* duration_; @@ -573,6 +580,198 @@ class RecordedSpan : public ::google::protobuf::MessageLite /* @@protoc_insertio mutable ::google::protobuf::internal::CachedSize _cached_size_; friend struct ::protobuf_util_2ftracing_2frecorded_5fspan_2eproto::TableStruct; }; +// ------------------------------------------------------------------- + +class NormalizedSpan_TagsEntry_DoNotUse : public ::google::protobuf::internal::MapEntryLite { +public: + typedef ::google::protobuf::internal::MapEntryLite SuperType; + NormalizedSpan_TagsEntry_DoNotUse(); + NormalizedSpan_TagsEntry_DoNotUse(::google::protobuf::Arena* arena); + void MergeFrom(const NormalizedSpan_TagsEntry_DoNotUse& other); + static const NormalizedSpan_TagsEntry_DoNotUse* internal_default_instance() { return reinterpret_cast(&_NormalizedSpan_TagsEntry_DoNotUse_default_instance_); } +}; + +// ------------------------------------------------------------------- + +class NormalizedSpan : public ::google::protobuf::MessageLite /* @@protoc_insertion_point(class_definition:cockroach.util.tracing.NormalizedSpan) */ { + public: + NormalizedSpan(); + virtual ~NormalizedSpan(); + + NormalizedSpan(const NormalizedSpan& from); + + inline NormalizedSpan& operator=(const NormalizedSpan& from) { + CopyFrom(from); + return *this; + } + #if LANG_CXX11 + NormalizedSpan(NormalizedSpan&& from) noexcept + : NormalizedSpan() { + *this = ::std::move(from); + } + + inline NormalizedSpan& operator=(NormalizedSpan&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif + static const NormalizedSpan& default_instance(); + + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY + static inline const NormalizedSpan* internal_default_instance() { + return reinterpret_cast( + &_NormalizedSpan_default_instance_); + } + static constexpr int kIndexInFileMessages = + 6; + + void Swap(NormalizedSpan* other); + friend void swap(NormalizedSpan& a, NormalizedSpan& b) { + a.Swap(&b); + } + + // implements Message ---------------------------------------------- + + inline NormalizedSpan* New() const final { + return CreateMaybeMessage(NULL); + } + + NormalizedSpan* New(::google::protobuf::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from) + final; + void CopyFrom(const NormalizedSpan& from); + void MergeFrom(const NormalizedSpan& from); + void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) final; + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const final; + void DiscardUnknownFields(); + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + void InternalSwap(NormalizedSpan* other); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return NULL; + } + inline void* MaybeArenaPtr() const { + return NULL; + } + public: + + ::std::string GetTypeName() const final; + + // nested types ---------------------------------------------------- + + + // accessors ------------------------------------------------------- + + // map tags = 2; + int tags_size() const; + void clear_tags(); + static const int kTagsFieldNumber = 2; + const ::google::protobuf::Map< ::std::string, ::std::string >& + tags() const; + ::google::protobuf::Map< ::std::string, ::std::string >* + mutable_tags(); + + int logs_size() const; + void clear_logs(); + static const int kLogsFieldNumber = 5; + ::cockroach::util::tracing::LogRecord* mutable_logs(int index); + ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::LogRecord >* + mutable_logs(); + const ::cockroach::util::tracing::LogRecord& logs(int index) const; + ::cockroach::util::tracing::LogRecord* add_logs(); + const ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::LogRecord >& + logs() const; + + int children_size() const; + void clear_children(); + static const int kChildrenFieldNumber = 6; + ::cockroach::util::tracing::NormalizedSpan* mutable_children(int index); + ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::NormalizedSpan >* + mutable_children(); + const ::cockroach::util::tracing::NormalizedSpan& children(int index) const; + ::cockroach::util::tracing::NormalizedSpan* add_children(); + const ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::NormalizedSpan >& + children() const; + + // string operation = 1; + void clear_operation(); + static const int kOperationFieldNumber = 1; + const ::std::string& operation() const; + void set_operation(const ::std::string& value); + #if LANG_CXX11 + void set_operation(::std::string&& value); + #endif + void set_operation(const char* value); + void set_operation(const char* value, size_t size); + ::std::string* mutable_operation(); + ::std::string* release_operation(); + void set_allocated_operation(::std::string* operation); + + bool has_start_time() const; + void clear_start_time(); + static const int kStartTimeFieldNumber = 3; + private: + const ::google::protobuf::Timestamp& _internal_start_time() const; + public: + const ::google::protobuf::Timestamp& start_time() const; + ::google::protobuf::Timestamp* release_start_time(); + ::google::protobuf::Timestamp* mutable_start_time(); + void set_allocated_start_time(::google::protobuf::Timestamp* start_time); + + bool has_duration() const; + void clear_duration(); + static const int kDurationFieldNumber = 4; + private: + const ::google::protobuf::Duration& _internal_duration() const; + public: + const ::google::protobuf::Duration& duration() const; + ::google::protobuf::Duration* release_duration(); + ::google::protobuf::Duration* mutable_duration(); + void set_allocated_duration(::google::protobuf::Duration* duration); + + // @@protoc_insertion_point(class_scope:cockroach.util.tracing.NormalizedSpan) + private: + + ::google::protobuf::internal::InternalMetadataWithArenaLite _internal_metadata_; + ::google::protobuf::internal::MapFieldLite< + NormalizedSpan_TagsEntry_DoNotUse, + ::std::string, ::std::string, + ::google::protobuf::internal::WireFormatLite::TYPE_STRING, + ::google::protobuf::internal::WireFormatLite::TYPE_STRING, + 0 > tags_; + ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::LogRecord > logs_; + ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::NormalizedSpan > children_; + ::google::protobuf::internal::ArenaStringPtr operation_; + ::google::protobuf::Timestamp* start_time_; + ::google::protobuf::Duration* duration_; + mutable ::google::protobuf::internal::CachedSize _cached_size_; + friend struct ::protobuf_util_2ftracing_2frecorded_5fspan_2eproto::TableStruct; +}; // =================================================================== @@ -582,151 +781,147 @@ class RecordedSpan : public ::google::protobuf::MessageLite /* @@protoc_insertio #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif // __GNUC__ -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// RecordedSpan_LogRecord_Field +// LogRecord_Field // string key = 1; -inline void RecordedSpan_LogRecord_Field::clear_key() { +inline void LogRecord_Field::clear_key() { key_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } -inline const ::std::string& RecordedSpan_LogRecord_Field::key() const { - // @@protoc_insertion_point(field_get:cockroach.util.tracing.RecordedSpan.LogRecord.Field.key) +inline const ::std::string& LogRecord_Field::key() const { + // @@protoc_insertion_point(field_get:cockroach.util.tracing.LogRecord.Field.key) return key_.GetNoArena(); } -inline void RecordedSpan_LogRecord_Field::set_key(const ::std::string& value) { +inline void LogRecord_Field::set_key(const ::std::string& value) { key_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:cockroach.util.tracing.RecordedSpan.LogRecord.Field.key) + // @@protoc_insertion_point(field_set:cockroach.util.tracing.LogRecord.Field.key) } #if LANG_CXX11 -inline void RecordedSpan_LogRecord_Field::set_key(::std::string&& value) { +inline void LogRecord_Field::set_key(::std::string&& value) { key_.SetNoArena( &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:cockroach.util.tracing.RecordedSpan.LogRecord.Field.key) + // @@protoc_insertion_point(field_set_rvalue:cockroach.util.tracing.LogRecord.Field.key) } #endif -inline void RecordedSpan_LogRecord_Field::set_key(const char* value) { +inline void LogRecord_Field::set_key(const char* value) { GOOGLE_DCHECK(value != NULL); key_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:cockroach.util.tracing.RecordedSpan.LogRecord.Field.key) + // @@protoc_insertion_point(field_set_char:cockroach.util.tracing.LogRecord.Field.key) } -inline void RecordedSpan_LogRecord_Field::set_key(const char* value, size_t size) { +inline void LogRecord_Field::set_key(const char* value, size_t size) { key_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); - // @@protoc_insertion_point(field_set_pointer:cockroach.util.tracing.RecordedSpan.LogRecord.Field.key) + // @@protoc_insertion_point(field_set_pointer:cockroach.util.tracing.LogRecord.Field.key) } -inline ::std::string* RecordedSpan_LogRecord_Field::mutable_key() { +inline ::std::string* LogRecord_Field::mutable_key() { - // @@protoc_insertion_point(field_mutable:cockroach.util.tracing.RecordedSpan.LogRecord.Field.key) + // @@protoc_insertion_point(field_mutable:cockroach.util.tracing.LogRecord.Field.key) return key_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } -inline ::std::string* RecordedSpan_LogRecord_Field::release_key() { - // @@protoc_insertion_point(field_release:cockroach.util.tracing.RecordedSpan.LogRecord.Field.key) +inline ::std::string* LogRecord_Field::release_key() { + // @@protoc_insertion_point(field_release:cockroach.util.tracing.LogRecord.Field.key) return key_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } -inline void RecordedSpan_LogRecord_Field::set_allocated_key(::std::string* key) { +inline void LogRecord_Field::set_allocated_key(::std::string* key) { if (key != NULL) { } else { } key_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), key); - // @@protoc_insertion_point(field_set_allocated:cockroach.util.tracing.RecordedSpan.LogRecord.Field.key) + // @@protoc_insertion_point(field_set_allocated:cockroach.util.tracing.LogRecord.Field.key) } // string value = 2; -inline void RecordedSpan_LogRecord_Field::clear_value() { +inline void LogRecord_Field::clear_value() { value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } -inline const ::std::string& RecordedSpan_LogRecord_Field::value() const { - // @@protoc_insertion_point(field_get:cockroach.util.tracing.RecordedSpan.LogRecord.Field.value) +inline const ::std::string& LogRecord_Field::value() const { + // @@protoc_insertion_point(field_get:cockroach.util.tracing.LogRecord.Field.value) return value_.GetNoArena(); } -inline void RecordedSpan_LogRecord_Field::set_value(const ::std::string& value) { +inline void LogRecord_Field::set_value(const ::std::string& value) { value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:cockroach.util.tracing.RecordedSpan.LogRecord.Field.value) + // @@protoc_insertion_point(field_set:cockroach.util.tracing.LogRecord.Field.value) } #if LANG_CXX11 -inline void RecordedSpan_LogRecord_Field::set_value(::std::string&& value) { +inline void LogRecord_Field::set_value(::std::string&& value) { value_.SetNoArena( &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); - // @@protoc_insertion_point(field_set_rvalue:cockroach.util.tracing.RecordedSpan.LogRecord.Field.value) + // @@protoc_insertion_point(field_set_rvalue:cockroach.util.tracing.LogRecord.Field.value) } #endif -inline void RecordedSpan_LogRecord_Field::set_value(const char* value) { +inline void LogRecord_Field::set_value(const char* value) { GOOGLE_DCHECK(value != NULL); value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:cockroach.util.tracing.RecordedSpan.LogRecord.Field.value) + // @@protoc_insertion_point(field_set_char:cockroach.util.tracing.LogRecord.Field.value) } -inline void RecordedSpan_LogRecord_Field::set_value(const char* value, size_t size) { +inline void LogRecord_Field::set_value(const char* value, size_t size) { value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast(value), size)); - // @@protoc_insertion_point(field_set_pointer:cockroach.util.tracing.RecordedSpan.LogRecord.Field.value) + // @@protoc_insertion_point(field_set_pointer:cockroach.util.tracing.LogRecord.Field.value) } -inline ::std::string* RecordedSpan_LogRecord_Field::mutable_value() { +inline ::std::string* LogRecord_Field::mutable_value() { - // @@protoc_insertion_point(field_mutable:cockroach.util.tracing.RecordedSpan.LogRecord.Field.value) + // @@protoc_insertion_point(field_mutable:cockroach.util.tracing.LogRecord.Field.value) return value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } -inline ::std::string* RecordedSpan_LogRecord_Field::release_value() { - // @@protoc_insertion_point(field_release:cockroach.util.tracing.RecordedSpan.LogRecord.Field.value) +inline ::std::string* LogRecord_Field::release_value() { + // @@protoc_insertion_point(field_release:cockroach.util.tracing.LogRecord.Field.value) return value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } -inline void RecordedSpan_LogRecord_Field::set_allocated_value(::std::string* value) { +inline void LogRecord_Field::set_allocated_value(::std::string* value) { if (value != NULL) { } else { } value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set_allocated:cockroach.util.tracing.RecordedSpan.LogRecord.Field.value) + // @@protoc_insertion_point(field_set_allocated:cockroach.util.tracing.LogRecord.Field.value) } // ------------------------------------------------------------------- -// RecordedSpan_LogRecord +// LogRecord -inline bool RecordedSpan_LogRecord::has_time() const { +inline bool LogRecord::has_time() const { return this != internal_default_instance() && time_ != NULL; } -inline const ::google::protobuf::Timestamp& RecordedSpan_LogRecord::_internal_time() const { +inline const ::google::protobuf::Timestamp& LogRecord::_internal_time() const { return *time_; } -inline const ::google::protobuf::Timestamp& RecordedSpan_LogRecord::time() const { +inline const ::google::protobuf::Timestamp& LogRecord::time() const { const ::google::protobuf::Timestamp* p = time_; - // @@protoc_insertion_point(field_get:cockroach.util.tracing.RecordedSpan.LogRecord.time) + // @@protoc_insertion_point(field_get:cockroach.util.tracing.LogRecord.time) return p != NULL ? *p : *reinterpret_cast( &::google::protobuf::_Timestamp_default_instance_); } -inline ::google::protobuf::Timestamp* RecordedSpan_LogRecord::release_time() { - // @@protoc_insertion_point(field_release:cockroach.util.tracing.RecordedSpan.LogRecord.time) +inline ::google::protobuf::Timestamp* LogRecord::release_time() { + // @@protoc_insertion_point(field_release:cockroach.util.tracing.LogRecord.time) ::google::protobuf::Timestamp* temp = time_; time_ = NULL; return temp; } -inline ::google::protobuf::Timestamp* RecordedSpan_LogRecord::mutable_time() { +inline ::google::protobuf::Timestamp* LogRecord::mutable_time() { if (time_ == NULL) { auto* p = CreateMaybeMessage<::google::protobuf::Timestamp>(GetArenaNoVirtual()); time_ = p; } - // @@protoc_insertion_point(field_mutable:cockroach.util.tracing.RecordedSpan.LogRecord.time) + // @@protoc_insertion_point(field_mutable:cockroach.util.tracing.LogRecord.time) return time_; } -inline void RecordedSpan_LogRecord::set_allocated_time(::google::protobuf::Timestamp* time) { +inline void LogRecord::set_allocated_time(::google::protobuf::Timestamp* time) { ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); if (message_arena == NULL) { delete reinterpret_cast< ::google::protobuf::MessageLite*>(time_); @@ -743,40 +938,44 @@ inline void RecordedSpan_LogRecord::set_allocated_time(::google::protobuf::Times } time_ = time; - // @@protoc_insertion_point(field_set_allocated:cockroach.util.tracing.RecordedSpan.LogRecord.time) + // @@protoc_insertion_point(field_set_allocated:cockroach.util.tracing.LogRecord.time) } -inline int RecordedSpan_LogRecord::fields_size() const { +inline int LogRecord::fields_size() const { return fields_.size(); } -inline void RecordedSpan_LogRecord::clear_fields() { +inline void LogRecord::clear_fields() { fields_.Clear(); } -inline ::cockroach::util::tracing::RecordedSpan_LogRecord_Field* RecordedSpan_LogRecord::mutable_fields(int index) { - // @@protoc_insertion_point(field_mutable:cockroach.util.tracing.RecordedSpan.LogRecord.fields) +inline ::cockroach::util::tracing::LogRecord_Field* LogRecord::mutable_fields(int index) { + // @@protoc_insertion_point(field_mutable:cockroach.util.tracing.LogRecord.fields) return fields_.Mutable(index); } -inline ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::RecordedSpan_LogRecord_Field >* -RecordedSpan_LogRecord::mutable_fields() { - // @@protoc_insertion_point(field_mutable_list:cockroach.util.tracing.RecordedSpan.LogRecord.fields) +inline ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::LogRecord_Field >* +LogRecord::mutable_fields() { + // @@protoc_insertion_point(field_mutable_list:cockroach.util.tracing.LogRecord.fields) return &fields_; } -inline const ::cockroach::util::tracing::RecordedSpan_LogRecord_Field& RecordedSpan_LogRecord::fields(int index) const { - // @@protoc_insertion_point(field_get:cockroach.util.tracing.RecordedSpan.LogRecord.fields) +inline const ::cockroach::util::tracing::LogRecord_Field& LogRecord::fields(int index) const { + // @@protoc_insertion_point(field_get:cockroach.util.tracing.LogRecord.fields) return fields_.Get(index); } -inline ::cockroach::util::tracing::RecordedSpan_LogRecord_Field* RecordedSpan_LogRecord::add_fields() { - // @@protoc_insertion_point(field_add:cockroach.util.tracing.RecordedSpan.LogRecord.fields) +inline ::cockroach::util::tracing::LogRecord_Field* LogRecord::add_fields() { + // @@protoc_insertion_point(field_add:cockroach.util.tracing.LogRecord.fields) return fields_.Add(); } -inline const ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::RecordedSpan_LogRecord_Field >& -RecordedSpan_LogRecord::fields() const { - // @@protoc_insertion_point(field_list:cockroach.util.tracing.RecordedSpan.LogRecord.fields) +inline const ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::LogRecord_Field >& +LogRecord::fields() const { + // @@protoc_insertion_point(field_list:cockroach.util.tracing.LogRecord.fields) return fields_; } // ------------------------------------------------------------------- +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + // RecordedSpan inline void RecordedSpan::clear_trace_id() { @@ -1009,24 +1208,24 @@ inline int RecordedSpan::logs_size() const { inline void RecordedSpan::clear_logs() { logs_.Clear(); } -inline ::cockroach::util::tracing::RecordedSpan_LogRecord* RecordedSpan::mutable_logs(int index) { +inline ::cockroach::util::tracing::LogRecord* RecordedSpan::mutable_logs(int index) { // @@protoc_insertion_point(field_mutable:cockroach.util.tracing.RecordedSpan.logs) return logs_.Mutable(index); } -inline ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::RecordedSpan_LogRecord >* +inline ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::LogRecord >* RecordedSpan::mutable_logs() { // @@protoc_insertion_point(field_mutable_list:cockroach.util.tracing.RecordedSpan.logs) return &logs_; } -inline const ::cockroach::util::tracing::RecordedSpan_LogRecord& RecordedSpan::logs(int index) const { +inline const ::cockroach::util::tracing::LogRecord& RecordedSpan::logs(int index) const { // @@protoc_insertion_point(field_get:cockroach.util.tracing.RecordedSpan.logs) return logs_.Get(index); } -inline ::cockroach::util::tracing::RecordedSpan_LogRecord* RecordedSpan::add_logs() { +inline ::cockroach::util::tracing::LogRecord* RecordedSpan::add_logs() { // @@protoc_insertion_point(field_add:cockroach.util.tracing.RecordedSpan.logs) return logs_.Add(); } -inline const ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::RecordedSpan_LogRecord >& +inline const ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::LogRecord >& RecordedSpan::logs() const { // @@protoc_insertion_point(field_list:cockroach.util.tracing.RecordedSpan.logs) return logs_; @@ -1080,6 +1279,237 @@ inline void RecordedSpan::set_allocated_stats(::google::protobuf::Any* stats) { // @@protoc_insertion_point(field_set_allocated:cockroach.util.tracing.RecordedSpan.stats) } +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// NormalizedSpan + +// string operation = 1; +inline void NormalizedSpan::clear_operation() { + operation_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline const ::std::string& NormalizedSpan::operation() const { + // @@protoc_insertion_point(field_get:cockroach.util.tracing.NormalizedSpan.operation) + return operation_.GetNoArena(); +} +inline void NormalizedSpan::set_operation(const ::std::string& value) { + + operation_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:cockroach.util.tracing.NormalizedSpan.operation) +} +#if LANG_CXX11 +inline void NormalizedSpan::set_operation(::std::string&& value) { + + operation_.SetNoArena( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); + // @@protoc_insertion_point(field_set_rvalue:cockroach.util.tracing.NormalizedSpan.operation) +} +#endif +inline void NormalizedSpan::set_operation(const char* value) { + GOOGLE_DCHECK(value != NULL); + + operation_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:cockroach.util.tracing.NormalizedSpan.operation) +} +inline void NormalizedSpan::set_operation(const char* value, size_t size) { + + operation_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:cockroach.util.tracing.NormalizedSpan.operation) +} +inline ::std::string* NormalizedSpan::mutable_operation() { + + // @@protoc_insertion_point(field_mutable:cockroach.util.tracing.NormalizedSpan.operation) + return operation_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline ::std::string* NormalizedSpan::release_operation() { + // @@protoc_insertion_point(field_release:cockroach.util.tracing.NormalizedSpan.operation) + + return operation_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void NormalizedSpan::set_allocated_operation(::std::string* operation) { + if (operation != NULL) { + + } else { + + } + operation_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), operation); + // @@protoc_insertion_point(field_set_allocated:cockroach.util.tracing.NormalizedSpan.operation) +} + +// map tags = 2; +inline int NormalizedSpan::tags_size() const { + return tags_.size(); +} +inline void NormalizedSpan::clear_tags() { + tags_.Clear(); +} +inline const ::google::protobuf::Map< ::std::string, ::std::string >& +NormalizedSpan::tags() const { + // @@protoc_insertion_point(field_map:cockroach.util.tracing.NormalizedSpan.tags) + return tags_.GetMap(); +} +inline ::google::protobuf::Map< ::std::string, ::std::string >* +NormalizedSpan::mutable_tags() { + // @@protoc_insertion_point(field_mutable_map:cockroach.util.tracing.NormalizedSpan.tags) + return tags_.MutableMap(); +} + +inline bool NormalizedSpan::has_start_time() const { + return this != internal_default_instance() && start_time_ != NULL; +} +inline const ::google::protobuf::Timestamp& NormalizedSpan::_internal_start_time() const { + return *start_time_; +} +inline const ::google::protobuf::Timestamp& NormalizedSpan::start_time() const { + const ::google::protobuf::Timestamp* p = start_time_; + // @@protoc_insertion_point(field_get:cockroach.util.tracing.NormalizedSpan.start_time) + return p != NULL ? *p : *reinterpret_cast( + &::google::protobuf::_Timestamp_default_instance_); +} +inline ::google::protobuf::Timestamp* NormalizedSpan::release_start_time() { + // @@protoc_insertion_point(field_release:cockroach.util.tracing.NormalizedSpan.start_time) + + ::google::protobuf::Timestamp* temp = start_time_; + start_time_ = NULL; + return temp; +} +inline ::google::protobuf::Timestamp* NormalizedSpan::mutable_start_time() { + + if (start_time_ == NULL) { + auto* p = CreateMaybeMessage<::google::protobuf::Timestamp>(GetArenaNoVirtual()); + start_time_ = p; + } + // @@protoc_insertion_point(field_mutable:cockroach.util.tracing.NormalizedSpan.start_time) + return start_time_; +} +inline void NormalizedSpan::set_allocated_start_time(::google::protobuf::Timestamp* start_time) { + ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); + if (message_arena == NULL) { + delete reinterpret_cast< ::google::protobuf::MessageLite*>(start_time_); + } + if (start_time) { + ::google::protobuf::Arena* submessage_arena = + reinterpret_cast<::google::protobuf::MessageLite*>(start_time)->GetArena(); + if (message_arena != submessage_arena) { + start_time = ::google::protobuf::internal::GetOwnedMessage( + message_arena, start_time, submessage_arena); + } + + } else { + + } + start_time_ = start_time; + // @@protoc_insertion_point(field_set_allocated:cockroach.util.tracing.NormalizedSpan.start_time) +} + +inline bool NormalizedSpan::has_duration() const { + return this != internal_default_instance() && duration_ != NULL; +} +inline const ::google::protobuf::Duration& NormalizedSpan::_internal_duration() const { + return *duration_; +} +inline const ::google::protobuf::Duration& NormalizedSpan::duration() const { + const ::google::protobuf::Duration* p = duration_; + // @@protoc_insertion_point(field_get:cockroach.util.tracing.NormalizedSpan.duration) + return p != NULL ? *p : *reinterpret_cast( + &::google::protobuf::_Duration_default_instance_); +} +inline ::google::protobuf::Duration* NormalizedSpan::release_duration() { + // @@protoc_insertion_point(field_release:cockroach.util.tracing.NormalizedSpan.duration) + + ::google::protobuf::Duration* temp = duration_; + duration_ = NULL; + return temp; +} +inline ::google::protobuf::Duration* NormalizedSpan::mutable_duration() { + + if (duration_ == NULL) { + auto* p = CreateMaybeMessage<::google::protobuf::Duration>(GetArenaNoVirtual()); + duration_ = p; + } + // @@protoc_insertion_point(field_mutable:cockroach.util.tracing.NormalizedSpan.duration) + return duration_; +} +inline void NormalizedSpan::set_allocated_duration(::google::protobuf::Duration* duration) { + ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); + if (message_arena == NULL) { + delete reinterpret_cast< ::google::protobuf::MessageLite*>(duration_); + } + if (duration) { + ::google::protobuf::Arena* submessage_arena = + reinterpret_cast<::google::protobuf::MessageLite*>(duration)->GetArena(); + if (message_arena != submessage_arena) { + duration = ::google::protobuf::internal::GetOwnedMessage( + message_arena, duration, submessage_arena); + } + + } else { + + } + duration_ = duration; + // @@protoc_insertion_point(field_set_allocated:cockroach.util.tracing.NormalizedSpan.duration) +} + +inline int NormalizedSpan::logs_size() const { + return logs_.size(); +} +inline void NormalizedSpan::clear_logs() { + logs_.Clear(); +} +inline ::cockroach::util::tracing::LogRecord* NormalizedSpan::mutable_logs(int index) { + // @@protoc_insertion_point(field_mutable:cockroach.util.tracing.NormalizedSpan.logs) + return logs_.Mutable(index); +} +inline ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::LogRecord >* +NormalizedSpan::mutable_logs() { + // @@protoc_insertion_point(field_mutable_list:cockroach.util.tracing.NormalizedSpan.logs) + return &logs_; +} +inline const ::cockroach::util::tracing::LogRecord& NormalizedSpan::logs(int index) const { + // @@protoc_insertion_point(field_get:cockroach.util.tracing.NormalizedSpan.logs) + return logs_.Get(index); +} +inline ::cockroach::util::tracing::LogRecord* NormalizedSpan::add_logs() { + // @@protoc_insertion_point(field_add:cockroach.util.tracing.NormalizedSpan.logs) + return logs_.Add(); +} +inline const ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::LogRecord >& +NormalizedSpan::logs() const { + // @@protoc_insertion_point(field_list:cockroach.util.tracing.NormalizedSpan.logs) + return logs_; +} + +inline int NormalizedSpan::children_size() const { + return children_.size(); +} +inline void NormalizedSpan::clear_children() { + children_.Clear(); +} +inline ::cockroach::util::tracing::NormalizedSpan* NormalizedSpan::mutable_children(int index) { + // @@protoc_insertion_point(field_mutable:cockroach.util.tracing.NormalizedSpan.children) + return children_.Mutable(index); +} +inline ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::NormalizedSpan >* +NormalizedSpan::mutable_children() { + // @@protoc_insertion_point(field_mutable_list:cockroach.util.tracing.NormalizedSpan.children) + return &children_; +} +inline const ::cockroach::util::tracing::NormalizedSpan& NormalizedSpan::children(int index) const { + // @@protoc_insertion_point(field_get:cockroach.util.tracing.NormalizedSpan.children) + return children_.Get(index); +} +inline ::cockroach::util::tracing::NormalizedSpan* NormalizedSpan::add_children() { + // @@protoc_insertion_point(field_add:cockroach.util.tracing.NormalizedSpan.children) + return children_.Add(); +} +inline const ::google::protobuf::RepeatedPtrField< ::cockroach::util::tracing::NormalizedSpan >& +NormalizedSpan::children() const { + // @@protoc_insertion_point(field_list:cockroach.util.tracing.NormalizedSpan.children) + return children_; +} + #ifdef __GNUC__ #pragma GCC diagnostic pop #endif // __GNUC__ @@ -1091,6 +1521,10 @@ inline void RecordedSpan::set_allocated_stats(::google::protobuf::Any* stats) { // ------------------------------------------------------------------- +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + // @@protoc_insertion_point(namespace_scope) diff --git a/docs/generated/settings/settings.html b/docs/generated/settings/settings.html index 7c76bbcadb24..3dfbbd05285d 100644 --- a/docs/generated/settings/settings.html +++ b/docs/generated/settings/settings.html @@ -64,6 +64,6 @@ trace.debug.enablebooleanfalseif set, traces for recent requests can be seen in the /debug page trace.lightstep.tokenstringif set, traces go to Lightstep using this token trace.zipkin.collectorstringif set, traces go to the given Zipkin instance (example: '127.0.0.1:9411'); ignored if trace.lightstep.token is set -versioncustom validation19.2-13set the active cluster version in the format '.' +versioncustom validation19.2-14set the active cluster version in the format '.' diff --git a/pkg/cli/zip_test.go b/pkg/cli/zip_test.go index 3cefffa71a40..55338f6a77d3 100644 --- a/pkg/cli/zip_test.go +++ b/pkg/cli/zip_test.go @@ -164,7 +164,7 @@ requesting heap profile for node 1... writing: debug/nodes/1/heap.pprof requesting heap files for node 1... 0 found requesting goroutine files for node 1... 0 found requesting log file ... -requesting ranges... 29 found +requesting ranges... 32 found writing: debug/nodes/1/ranges/1.json writing: debug/nodes/1/ranges/2.json writing: debug/nodes/1/ranges/3.json @@ -194,13 +194,16 @@ writing: debug/nodes/1/ranges/26.json writing: debug/nodes/1/ranges/27.json writing: debug/nodes/1/ranges/28.json writing: debug/nodes/1/ranges/29.json +writing: debug/nodes/1/ranges/30.json +writing: debug/nodes/1/ranges/31.json +writing: debug/nodes/1/ranges/32.json requesting list of SQL databases... 3 found requesting database details for defaultdb... writing: debug/schema/defaultdb@details.json 0 tables found requesting database details for postgres... writing: debug/schema/postgres@details.json 0 tables found requesting database details for system... writing: debug/schema/system@details.json -23 tables found +26 tables found requesting table details for system.comments... writing: debug/schema/system/comments.json requesting table details for system.descriptor... writing: debug/schema/system/descriptor.json requesting table details for system.eventlog... writing: debug/schema/system/eventlog.json @@ -219,6 +222,9 @@ requesting table details for system.reports_meta... writing: debug/schema/system requesting table details for system.role_members... writing: debug/schema/system/role_members.json requesting table details for system.role_options... writing: debug/schema/system/role_options.json requesting table details for system.settings... writing: debug/schema/system/settings.json +requesting table details for system.statement_bundle_chunks... writing: debug/schema/system/statement_bundle_chunks.json +requesting table details for system.statement_diagnostics... writing: debug/schema/system/statement_diagnostics.json +requesting table details for system.statement_diagnostics_requests... writing: debug/schema/system/statement_diagnostics_requests.json requesting table details for system.table_statistics... writing: debug/schema/system/table_statistics.json requesting table details for system.ui... writing: debug/schema/system/ui.json requesting table details for system.users... writing: debug/schema/system/users.json @@ -284,7 +290,7 @@ requesting table details for defaultdb.pg_catalog.pg_class... writing: debug/sch requesting database details for postgres... writing: debug/schema/postgres@details.json 0 tables found requesting database details for system... writing: debug/schema/system-1@details.json -23 tables found +26 tables found requesting table details for system.comments... writing: debug/schema/system-1/comments.json requesting table details for system.descriptor... writing: debug/schema/system-1/descriptor.json requesting table details for system.eventlog... writing: debug/schema/system-1/eventlog.json @@ -303,6 +309,9 @@ requesting table details for system.reports_meta... writing: debug/schema/system requesting table details for system.role_members... writing: debug/schema/system-1/role_members.json requesting table details for system.role_options... writing: debug/schema/system-1/role_options.json requesting table details for system.settings... writing: debug/schema/system-1/settings.json +requesting table details for system.statement_bundle_chunks... writing: debug/schema/system-1/statement_bundle_chunks.json +requesting table details for system.statement_diagnostics... writing: debug/schema/system-1/statement_diagnostics.json +requesting table details for system.statement_diagnostics_requests... writing: debug/schema/system-1/statement_diagnostics_requests.json requesting table details for system.table_statistics... writing: debug/schema/system-1/table_statistics.json requesting table details for system.ui... writing: debug/schema/system-1/ui.json requesting table details for system.users... writing: debug/schema/system-1/users.json @@ -561,7 +570,7 @@ requesting heap profile for node 1... writing: debug/nodes/1/heap.pprof requesting heap files for node 1... 0 found requesting goroutine files for node 1... 0 found requesting log file ... -requesting ranges... 29 found +requesting ranges... 32 found writing: debug/nodes/1/ranges/1.json writing: debug/nodes/1/ranges/2.json writing: debug/nodes/1/ranges/3.json @@ -591,6 +600,9 @@ writing: debug/nodes/1/ranges/26.json writing: debug/nodes/1/ranges/27.json writing: debug/nodes/1/ranges/28.json writing: debug/nodes/1/ranges/29.json +writing: debug/nodes/1/ranges/30.json +writing: debug/nodes/1/ranges/31.json +writing: debug/nodes/1/ranges/32.json writing: debug/nodes/2/status.json using SQL connection URL for node 2: postgresql://... retrieving SQL data for crdb_internal.feature_usage... writing: debug/nodes/2/crdb_internal.feature_usage.txt @@ -660,7 +672,7 @@ requesting heap profile for node 3... writing: debug/nodes/3/heap.pprof requesting heap files for node 3... 0 found requesting goroutine files for node 3... 0 found requesting log file ... -requesting ranges... 29 found +requesting ranges... 32 found writing: debug/nodes/3/ranges/1.json writing: debug/nodes/3/ranges/2.json writing: debug/nodes/3/ranges/3.json @@ -690,13 +702,16 @@ writing: debug/nodes/3/ranges/26.json writing: debug/nodes/3/ranges/27.json writing: debug/nodes/3/ranges/28.json writing: debug/nodes/3/ranges/29.json +writing: debug/nodes/3/ranges/30.json +writing: debug/nodes/3/ranges/31.json +writing: debug/nodes/3/ranges/32.json requesting list of SQL databases... 3 found requesting database details for defaultdb... writing: debug/schema/defaultdb@details.json 0 tables found requesting database details for postgres... writing: debug/schema/postgres@details.json 0 tables found requesting database details for system... writing: debug/schema/system@details.json -23 tables found +26 tables found requesting table details for system.comments... writing: debug/schema/system/comments.json requesting table details for system.descriptor... writing: debug/schema/system/descriptor.json requesting table details for system.eventlog... writing: debug/schema/system/eventlog.json @@ -715,6 +730,9 @@ requesting table details for system.reports_meta... writing: debug/schema/system requesting table details for system.role_members... writing: debug/schema/system/role_members.json requesting table details for system.role_options... writing: debug/schema/system/role_options.json requesting table details for system.settings... writing: debug/schema/system/settings.json +requesting table details for system.statement_bundle_chunks... writing: debug/schema/system/statement_bundle_chunks.json +requesting table details for system.statement_diagnostics... writing: debug/schema/system/statement_diagnostics.json +requesting table details for system.statement_diagnostics_requests... writing: debug/schema/system/statement_diagnostics_requests.json requesting table details for system.table_statistics... writing: debug/schema/system/table_statistics.json requesting table details for system.ui... writing: debug/schema/system/ui.json requesting table details for system.users... writing: debug/schema/system/users.json diff --git a/pkg/gossip/keys.go b/pkg/gossip/keys.go index 9689c444710f..3cd6325007e1 100644 --- a/pkg/gossip/keys.go +++ b/pkg/gossip/keys.go @@ -91,6 +91,13 @@ const ( // client connections a node has open. This is used by other nodes in the // cluster to build a map of the gossip network. KeyGossipClientsPrefix = "gossip-clients" + + // KeyGossipStatementDiagnosticsRequest is the gossip key for new statement + // diagnostics requests. The values is the id of the request that generated + // the notification, as a little-endian-encoded uint64. + // stmtDiagnosticsRequestRegistry listens for notifications and responds by + // polling for new requests. + KeyGossipStatementDiagnosticsRequest = "stmt-diag-req" ) // MakeKey creates a canonical key under which to gossip a piece of diff --git a/pkg/keys/constants.go b/pkg/keys/constants.go index 4f56a4917969..8ebada4bdfc1 100644 --- a/pkg/keys/constants.go +++ b/pkg/keys/constants.go @@ -363,6 +363,10 @@ const ( RoleOptionsTableID = 33 + StatementBundleChunksTableID = 34 + StatementDiagnosticsRequestsTableID = 35 + StatementDiagnosticsTableID = 36 + // CommentType is type for system.comments DatabaseCommentType = 0 TableCommentType = 1 diff --git a/pkg/server/server.go b/pkg/server/server.go index 3bf7ad3f362c..c8a52d142538 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -846,7 +846,7 @@ func NewServer(cfg Config, stopper *stop.Stopper) (*Server, error) { ) s.internalExecutor = internalExecutor execCfg.InternalExecutor = internalExecutor - + s.status.stmtDiagnosticsRequester = execCfg.NewStmtDiagnosticsRequestRegistry() s.execCfg = &execCfg s.leaseMgr.SetInternalExecutor(execCfg.InternalExecutor) diff --git a/pkg/server/status.go b/pkg/server/status.go index b2d7923cd6f9..c972da566ba1 100644 --- a/pkg/server/status.go +++ b/pkg/server/status.go @@ -128,19 +128,20 @@ func propagateGatewayMetadata(ctx context.Context) context.Context { type statusServer struct { log.AmbientContext - st *cluster.Settings - cfg *base.Config - admin *adminServer - db *client.DB - gossip *gossip.Gossip - metricSource metricMarshaler - nodeLiveness *storage.NodeLiveness - storePool *storage.StorePool - rpcCtx *rpc.Context - stores *storage.Stores - stopper *stop.Stopper - sessionRegistry *sql.SessionRegistry - si systemInfoOnce + st *cluster.Settings + cfg *base.Config + admin *adminServer + db *client.DB + gossip *gossip.Gossip + metricSource metricMarshaler + nodeLiveness *storage.NodeLiveness + storePool *storage.StorePool + rpcCtx *rpc.Context + stores *storage.Stores + stopper *stop.Stopper + sessionRegistry *sql.SessionRegistry + si systemInfoOnce + stmtDiagnosticsRequester sql.StmtDiagnosticsRequester } // newStatusServer allocates and returns a statusServer. diff --git a/pkg/server/testserver.go b/pkg/server/testserver.go index fcfd14c15c8b..be3c2d7ac820 100644 --- a/pkg/server/testserver.go +++ b/pkg/server/testserver.go @@ -649,6 +649,11 @@ func (ts *TestServer) DistSender() *kv.DistSender { return ts.DistSenderI().(*kv.DistSender) } +// SQLServer is part of TestServerInterface. +func (ts *TestServer) SQLServer() interface{} { + return ts.PGServer().SQLServer +} + // DistSQLServer is part of TestServerInterface. func (ts *TestServer) DistSQLServer() interface{} { return ts.distSQLServer diff --git a/pkg/settings/cluster/cockroach_versions.go b/pkg/settings/cluster/cockroach_versions.go index aa545ca521cf..4a31e3fb7128 100644 --- a/pkg/settings/cluster/cockroach_versions.go +++ b/pkg/settings/cluster/cockroach_versions.go @@ -54,6 +54,7 @@ const ( VersionNoExplicitForeignKeyIndexIDs VersionHashShardedIndexes VersionCreateRolePrivilege + VersionStatementDiagnosticsSystemTables // Add new versions here (step one of two). ) @@ -417,6 +418,15 @@ var versionsSingleton = keyedVersions([]keyedVersion{ Key: VersionCreateRolePrivilege, Version: roachpb.Version{Major: 19, Minor: 2, Unstable: 13}, }, + { + // VersionStatementDiagnosticsSystemTables introduces the system tables for + // storing statement information (like traces, bundles). + // In this version and later the system.statement_diagnostics_requests, + // system.statement_diagnostics and system.statement_bundle_chunks tables + // are part of the system bootstap schema. + Key: VersionStatementDiagnosticsSystemTables, + Version: roachpb.Version{Major: 19, Minor: 2, Unstable: 14}, + }, // Add new versions here (step two of two). }) diff --git a/pkg/settings/cluster/versionkey_string.go b/pkg/settings/cluster/versionkey_string.go index d9d32871258d..6e2f7bccdeed 100644 --- a/pkg/settings/cluster/versionkey_string.go +++ b/pkg/settings/cluster/versionkey_string.go @@ -30,11 +30,12 @@ func _() { _ = x[VersionNoExplicitForeignKeyIndexIDs-19] _ = x[VersionHashShardedIndexes-20] _ = x[VersionCreateRolePrivilege-21] + _ = x[VersionStatementDiagnosticsSystemTables-22] } -const _VersionKey_name = "Version19_1VersionStart19_2VersionLearnerReplicasVersionTopLevelForeignKeysVersionAtomicChangeReplicasTriggerVersionAtomicChangeReplicasVersionTableDescModificationTimeFromMVCCVersionPartitionedBackupVersion19_2VersionStart20_1VersionContainsEstimatesCounterVersionChangeReplicasDemotionVersionSecondaryIndexColumnFamiliesVersionNamespaceTableWithSchemasVersionProtectedTimestampsVersionPrimaryKeyChangesVersionAuthLocalAndTrustRejectMethodsVersionPrimaryKeyColumnsOutOfFamilyZeroVersionRootPasswordVersionNoExplicitForeignKeyIndexIDsVersionHashShardedIndexesVersionCreateRolePrivilege" +const _VersionKey_name = "Version19_1VersionStart19_2VersionLearnerReplicasVersionTopLevelForeignKeysVersionAtomicChangeReplicasTriggerVersionAtomicChangeReplicasVersionTableDescModificationTimeFromMVCCVersionPartitionedBackupVersion19_2VersionStart20_1VersionContainsEstimatesCounterVersionChangeReplicasDemotionVersionSecondaryIndexColumnFamiliesVersionNamespaceTableWithSchemasVersionProtectedTimestampsVersionPrimaryKeyChangesVersionAuthLocalAndTrustRejectMethodsVersionPrimaryKeyColumnsOutOfFamilyZeroVersionRootPasswordVersionNoExplicitForeignKeyIndexIDsVersionHashShardedIndexesVersionCreateRolePrivilegeVersionStatementDiagnosticsSystemTables" -var _VersionKey_index = [...]uint16{0, 11, 27, 49, 75, 109, 136, 176, 200, 211, 227, 258, 287, 322, 354, 380, 404, 441, 480, 499, 534, 559, 585} +var _VersionKey_index = [...]uint16{0, 11, 27, 49, 75, 109, 136, 176, 200, 211, 227, 258, 287, 322, 354, 380, 404, 441, 480, 499, 534, 559, 585, 624} func (i VersionKey) String() string { if i < 0 || i >= VersionKey(len(_VersionKey_index)-1) { diff --git a/pkg/sql/conn_executor.go b/pkg/sql/conn_executor.go index f57527244008..34ff4d896dd0 100644 --- a/pkg/sql/conn_executor.go +++ b/pkg/sql/conn_executor.go @@ -340,6 +340,8 @@ func (s *Server) Start(ctx context.Context, stopper *stop.Stopper) { s.PeriodicallyClearSQLStats(ctx, stopper, maxSQLStatReset, &s.reportedStats) // Start a second loop to clear SQL stats at the requested interval. s.PeriodicallyClearSQLStats(ctx, stopper, sqlStatReset, &s.sqlStats) + + s.PeriodicallyPollForStatementInfoRequests(ctx, stopper) } // ResetSQLStats resets the executor's collected sql statistics. @@ -599,6 +601,7 @@ func (s *Server) newConnExecutor( ctxHolder: ctxHolder{connCtx: ctx}, executorType: executorTypeExec, hasCreatedTemporarySchema: false, + stmtInfoRegistry: s.cfg.stmtInfoRequestRegistry, } ex.state.txnAbortCount = ex.metrics.EngineMetrics.TxnAbortCount @@ -775,6 +778,30 @@ func (s *Server) PeriodicallyClearSQLStats( }) } +// PeriodicallyPollForStatementInfoRequests runs a worker that periodically +// polls system.statement_diagnostics_requests. +func (s *Server) PeriodicallyPollForStatementInfoRequests( + ctx context.Context, stopper *stop.Stopper, +) { + pollingInterval := 10 * time.Second + stopper.RunWorker(ctx, func(ctx context.Context) { + ctx, _ = stopper.WithCancelOnQuiesce(ctx) + var timer timeutil.Timer + for { + if err := s.cfg.stmtInfoRequestRegistry.pollRequests(ctx); err != nil { + log.Warningf(ctx, "error polling for statement diagnostics requests: %s", err) + } + timer.Reset(pollingInterval) + select { + case <-stopper.ShouldQuiesce(): + return + case <-timer.C: + timer.Read = true + } + } + }) +} + type closeType int const ( @@ -1067,6 +1094,10 @@ type connExecutor struct { // hasCreatedTemporarySchema is set if the executor has created a // temporary schema, which requires special cleanup on close. hasCreatedTemporarySchema bool + + // stmtInfoRequestRegistry is used to track which queries need to have + // information collected. + stmtInfoRegistry *stmtDiagnosticsRequestRegistry } // ctxHolder contains a connection's context and, while session tracing is diff --git a/pkg/sql/conn_executor_exec.go b/pkg/sql/conn_executor_exec.go index 3cff3a52cefb..1cf6e78b9b04 100644 --- a/pkg/sql/conn_executor_exec.go +++ b/pkg/sql/conn_executor_exec.go @@ -34,6 +34,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/util/timeutil" "github.com/cockroachdb/cockroach/pkg/util/tracing" "github.com/cockroachdb/errors" + "github.com/opentracing/opentracing-go" ) // execStmt executes one statement by dispatching according to the current @@ -179,6 +180,21 @@ func (ex *connExecutor) execStmtInOpenState( } }() + shouldCollectInfo, recordStmtInfoFn := ex.stmtInfoRegistry.shouldCollectDiagnostics(ctx, stmt.AST) + if shouldCollectInfo { + tr := ex.server.cfg.AmbientCtx.Tracer + origCtx := ctx + var sp opentracing.Span + ctx, sp = tracing.StartSnowballTrace(ctx, tr, "traced statement") + defer func() { + // Record the statement information that we've collected. + // Note that in case of implicit transactions, the trace contains the auto-commit too. + sp.Finish() + trace := tracing.GetRecording(sp) + recordStmtInfoFn(origCtx, trace) + }() + } + if ex.sessionData.StmtTimeout > 0 { timeoutTicker = time.AfterFunc( ex.sessionData.StmtTimeout-timeutil.Since(ex.phaseTimes[sessionQueryReceived]), @@ -1146,6 +1162,7 @@ func (ex *connExecutor) handleAutoCommit( ) (fsm.Event, fsm.EventPayload) { txn := ex.state.mu.txn if txn.IsCommitted() { + log.Event(ctx, "statement execution committed the txn") return eventTxnFinish{}, eventTxnFinishPayload{commit: true} } diff --git a/pkg/sql/conn_executor_internal_test.go b/pkg/sql/conn_executor_internal_test.go index e0b6ff35df79..4163aa996eba 100644 --- a/pkg/sql/conn_executor_internal_test.go +++ b/pkg/sql/conn_executor_internal_test.go @@ -281,8 +281,9 @@ func startConnExecutor( dummyLivenessProvider{}, /* liveness */ nil, /* nodeDialer */ ), - QueryCache: querycache.New(0), - TestingKnobs: ExecutorTestingKnobs{}, + QueryCache: querycache.New(0), + TestingKnobs: ExecutorTestingKnobs{}, + stmtInfoRequestRegistry: newStmtDiagnosticsRequestRegistry(nil, nil, nil, 0), } pool := mon.MakeUnlimitedMonitor( context.Background(), "test", mon.MemoryResource, diff --git a/pkg/sql/exec_util.go b/pkg/sql/exec_util.go index 3072448d5bae..f2bb48fd5bf1 100644 --- a/pkg/sql/exec_util.go +++ b/pkg/sql/exec_util.go @@ -569,11 +569,24 @@ type ExecutorConfig struct { // ProtectedTimestampProvider encapsulates the protected timestamp subsystem. ProtectedTimestampProvider protectedts.Provider + + stmtInfoRequestRegistry *stmtDiagnosticsRequestRegistry } // Organization returns the value of cluster.organization. -func (ec *ExecutorConfig) Organization() string { - return ClusterOrganization.Get(&ec.Settings.SV) +func (cfg *ExecutorConfig) Organization() string { + return ClusterOrganization.Get(&cfg.Settings.SV) +} + +// NewStmtDiagnosticsRequestRegistry initializes cfg.stmtInfoRequestRegistry and +// returns it as the publicly-accessible StmtDiagnosticsRequester. +func (cfg *ExecutorConfig) NewStmtDiagnosticsRequestRegistry() StmtDiagnosticsRequester { + if cfg.InternalExecutor == nil { + panic("cfg.InternalExecutor not initialized") + } + cfg.stmtInfoRequestRegistry = newStmtDiagnosticsRequestRegistry( + cfg.InternalExecutor, cfg.DB, cfg.Gossip, cfg.NodeID.Get()) + return cfg.stmtInfoRequestRegistry } var _ base.ModuleTestingKnobs = &ExecutorTestingKnobs{} @@ -1490,7 +1503,7 @@ func (st *SessionTracing) TraceExecEnd(ctx context.Context, err error, count int // extractMsgFromRecord extracts the message of the event, which is either in an // "event" or "error" field. -func extractMsgFromRecord(rec tracing.RecordedSpan_LogRecord) string { +func extractMsgFromRecord(rec tracing.LogRecord) string { for _, f := range rec.Fields { key := f.Key if key == "event" { diff --git a/pkg/sql/logictest/testdata/logic_test/grant_table b/pkg/sql/logictest/testdata/logic_test/grant_table index 0f3450947440..84c02e8cbfb2 100644 --- a/pkg/sql/logictest/testdata/logic_test/grant_table +++ b/pkg/sql/logictest/testdata/logic_test/grant_table @@ -358,6 +358,36 @@ system public protected_ts_records admin GRANT system public protected_ts_records admin SELECT system public protected_ts_records root GRANT system public protected_ts_records root SELECT +system public statement_bundle_chunks admin DELETE +system public statement_bundle_chunks admin GRANT +system public statement_bundle_chunks admin INSERT +system public statement_bundle_chunks admin SELECT +system public statement_bundle_chunks admin UPDATE +system public statement_bundle_chunks root DELETE +system public statement_bundle_chunks root GRANT +system public statement_bundle_chunks root INSERT +system public statement_bundle_chunks root SELECT +system public statement_bundle_chunks root UPDATE +system public statement_diagnostics_requests admin DELETE +system public statement_diagnostics_requests admin GRANT +system public statement_diagnostics_requests admin INSERT +system public statement_diagnostics_requests admin SELECT +system public statement_diagnostics_requests admin UPDATE +system public statement_diagnostics_requests root DELETE +system public statement_diagnostics_requests root GRANT +system public statement_diagnostics_requests root INSERT +system public statement_diagnostics_requests root SELECT +system public statement_diagnostics_requests root UPDATE +system public statement_diagnostics admin DELETE +system public statement_diagnostics admin GRANT +system public statement_diagnostics admin INSERT +system public statement_diagnostics admin SELECT +system public statement_diagnostics admin UPDATE +system public statement_diagnostics root DELETE +system public statement_diagnostics root GRANT +system public statement_diagnostics root INSERT +system public statement_diagnostics root SELECT +system public statement_diagnostics root UPDATE system public role_options admin DELETE system public role_options admin GRANT system public role_options admin INSERT @@ -481,6 +511,21 @@ system public settings root GRA system public settings root INSERT system public settings root SELECT system public settings root UPDATE +system public statement_bundle_chunks root DELETE +system public statement_bundle_chunks root GRANT +system public statement_bundle_chunks root INSERT +system public statement_bundle_chunks root SELECT +system public statement_bundle_chunks root UPDATE +system public statement_diagnostics root DELETE +system public statement_diagnostics root GRANT +system public statement_diagnostics root INSERT +system public statement_diagnostics root SELECT +system public statement_diagnostics root UPDATE +system public statement_diagnostics_requests root DELETE +system public statement_diagnostics_requests root GRANT +system public statement_diagnostics_requests root INSERT +system public statement_diagnostics_requests root SELECT +system public statement_diagnostics_requests root UPDATE system public table_statistics root DELETE system public table_statistics root GRANT system public table_statistics root INSERT diff --git a/pkg/sql/logictest/testdata/logic_test/information_schema b/pkg/sql/logictest/testdata/logic_test/information_schema index 19b1c2492f05..2a1288061bd4 100644 --- a/pkg/sql/logictest/testdata/logic_test/information_schema +++ b/pkg/sql/logictest/testdata/logic_test/information_schema @@ -628,6 +628,9 @@ system public namespace BASE TABLE system public protected_ts_meta BASE TABLE YES 1 system public protected_ts_records BASE TABLE YES 1 system public role_options BASE TABLE YES 1 +system public statement_bundle_chunks BASE TABLE YES 1 +system public statement_diagnostics_requests BASE TABLE YES 1 +system public statement_diagnostics BASE TABLE YES 1 statement ok ALTER TABLE other_db.xyz ADD COLUMN j INT @@ -772,6 +775,19 @@ system public 630200280_6_1_not_null system p system public 630200280_6_2_not_null system public settings CHECK NO NO system public 630200280_6_3_not_null system public settings CHECK NO NO system public primary system public settings PRIMARY KEY NO NO +system public 630200280_34_1_not_null system public statement_bundle_chunks CHECK NO NO +system public 630200280_34_3_not_null system public statement_bundle_chunks CHECK NO NO +system public primary system public statement_bundle_chunks PRIMARY KEY NO NO +system public 630200280_36_1_not_null system public statement_diagnostics CHECK NO NO +system public 630200280_36_2_not_null system public statement_diagnostics CHECK NO NO +system public 630200280_36_3_not_null system public statement_diagnostics CHECK NO NO +system public 630200280_36_4_not_null system public statement_diagnostics CHECK NO NO +system public primary system public statement_diagnostics PRIMARY KEY NO NO +system public 630200280_35_1_not_null system public statement_diagnostics_requests CHECK NO NO +system public 630200280_35_2_not_null system public statement_diagnostics_requests CHECK NO NO +system public 630200280_35_3_not_null system public statement_diagnostics_requests CHECK NO NO +system public 630200280_35_5_not_null system public statement_diagnostics_requests CHECK NO NO +system public primary system public statement_diagnostics_requests PRIMARY KEY NO NO system public 630200280_20_1_not_null system public table_statistics CHECK NO NO system public 630200280_20_2_not_null system public table_statistics CHECK NO NO system public 630200280_20_4_not_null system public table_statistics CHECK NO NO @@ -884,6 +900,16 @@ system public 630200280_32_6_not_null spans IS NOT NUL system public 630200280_32_7_not_null verified IS NOT NULL system public 630200280_33_1_not_null username IS NOT NULL system public 630200280_33_2_not_null option IS NOT NULL +system public 630200280_34_1_not_null id IS NOT NULL +system public 630200280_34_3_not_null data IS NOT NULL +system public 630200280_35_1_not_null id IS NOT NULL +system public 630200280_35_2_not_null completed IS NOT NULL +system public 630200280_35_3_not_null statement_fingerprint IS NOT NULL +system public 630200280_35_5_not_null requested_at IS NOT NULL +system public 630200280_36_1_not_null id IS NOT NULL +system public 630200280_36_2_not_null statement_fingerprint IS NOT NULL +system public 630200280_36_3_not_null statement IS NOT NULL +system public 630200280_36_4_not_null collected_at IS NOT NULL system public 630200280_3_1_not_null id IS NOT NULL system public 630200280_4_1_not_null username IS NOT NULL system public 630200280_4_3_not_null isRole IS NOT NULL @@ -937,6 +963,9 @@ system public role_members role sy system public role_options option system public primary system public role_options username system public primary system public settings name system public primary +system public statement_bundle_chunks id system public primary +system public statement_diagnostics id system public primary +system public statement_diagnostics_requests id system public primary system public table_statistics statisticID system public primary system public table_statistics tableID system public primary system public ui key system public primary @@ -1026,114 +1055,130 @@ FROM system.information_schema.columns WHERE table_schema != 'information_schema' AND table_schema != 'pg_catalog' AND table_schema != 'crdb_internal' ORDER BY 3,4 ---- -table_catalog table_schema table_name column_name ordinal_position -system public comments comment 4 -system public comments object_id 2 -system public comments sub_id 3 -system public comments type 1 -system public descriptor descriptor 2 -system public descriptor id 1 -system public eventlog eventType 2 -system public eventlog info 5 -system public eventlog reportingID 4 -system public eventlog targetID 3 -system public eventlog timestamp 1 -system public eventlog uniqueID 6 -system public jobs created 3 -system public jobs id 1 -system public jobs payload 4 -system public jobs progress 5 -system public jobs status 2 -system public lease descID 1 -system public lease expiration 4 -system public lease nodeID 3 -system public lease version 2 -system public locations latitude 3 -system public locations localityKey 1 -system public locations localityValue 2 -system public locations longitude 4 -system public namespace id 4 -system public namespace name 3 -system public namespace parentID 1 -system public namespace parentSchemaID 2 -system public namespace_deprecated id 3 -system public namespace_deprecated name 2 -system public namespace_deprecated parentID 1 -system public protected_ts_meta num_records 3 -system public protected_ts_meta num_spans 4 -system public protected_ts_meta singleton 1 -system public protected_ts_meta total_bytes 5 -system public protected_ts_meta version 2 -system public protected_ts_records id 1 -system public protected_ts_records meta 4 -system public protected_ts_records meta_type 3 -system public protected_ts_records num_spans 5 -system public protected_ts_records spans 6 -system public protected_ts_records ts 2 -system public protected_ts_records verified 7 -system public rangelog eventType 4 -system public rangelog info 6 -system public rangelog otherRangeID 5 -system public rangelog rangeID 2 -system public rangelog storeID 3 -system public rangelog timestamp 1 -system public rangelog uniqueID 7 -system public replication_constraint_stats config 4 -system public replication_constraint_stats report_id 5 -system public replication_constraint_stats subzone_id 2 -system public replication_constraint_stats type 3 -system public replication_constraint_stats violating_ranges 7 -system public replication_constraint_stats violation_start 6 -system public replication_constraint_stats zone_id 1 -system public replication_critical_localities at_risk_ranges 5 -system public replication_critical_localities locality 3 -system public replication_critical_localities report_id 4 -system public replication_critical_localities subzone_id 2 -system public replication_critical_localities zone_id 1 -system public replication_stats over_replicated_ranges 7 -system public replication_stats report_id 3 -system public replication_stats subzone_id 2 -system public replication_stats total_ranges 4 -system public replication_stats unavailable_ranges 5 -system public replication_stats under_replicated_ranges 6 -system public replication_stats zone_id 1 -system public reports_meta generated 2 -system public reports_meta id 1 -system public role_members isAdmin 3 -system public role_members member 2 -system public role_members role 1 -system public role_options option 2 -system public role_options username 1 -system public role_options value 3 -system public settings lastUpdated 3 -system public settings name 1 -system public settings value 2 -system public settings valueType 4 -system public table_statistics columnIDs 4 -system public table_statistics createdAt 5 -system public table_statistics distinctCount 7 -system public table_statistics histogram 9 -system public table_statistics name 3 -system public table_statistics nullCount 8 -system public table_statistics rowCount 6 -system public table_statistics statisticID 2 -system public table_statistics tableID 1 -system public ui key 1 -system public ui lastUpdated 3 -system public ui value 2 -system public users hashedPassword 2 -system public users isRole 3 -system public users username 1 -system public web_sessions auditInfo 8 -system public web_sessions createdAt 4 -system public web_sessions expiresAt 5 -system public web_sessions hashedSecret 2 -system public web_sessions id 1 -system public web_sessions lastUsedAt 7 -system public web_sessions revokedAt 6 -system public web_sessions username 3 -system public zones config 2 -system public zones id 1 +table_catalog table_schema table_name column_name ordinal_position +system public comments comment 4 +system public comments object_id 2 +system public comments sub_id 3 +system public comments type 1 +system public descriptor descriptor 2 +system public descriptor id 1 +system public eventlog eventType 2 +system public eventlog info 5 +system public eventlog reportingID 4 +system public eventlog targetID 3 +system public eventlog timestamp 1 +system public eventlog uniqueID 6 +system public jobs created 3 +system public jobs id 1 +system public jobs payload 4 +system public jobs progress 5 +system public jobs status 2 +system public lease descID 1 +system public lease expiration 4 +system public lease nodeID 3 +system public lease version 2 +system public locations latitude 3 +system public locations localityKey 1 +system public locations localityValue 2 +system public locations longitude 4 +system public namespace id 4 +system public namespace name 3 +system public namespace parentID 1 +system public namespace parentSchemaID 2 +system public namespace_deprecated id 3 +system public namespace_deprecated name 2 +system public namespace_deprecated parentID 1 +system public protected_ts_meta num_records 3 +system public protected_ts_meta num_spans 4 +system public protected_ts_meta singleton 1 +system public protected_ts_meta total_bytes 5 +system public protected_ts_meta version 2 +system public protected_ts_records id 1 +system public protected_ts_records meta 4 +system public protected_ts_records meta_type 3 +system public protected_ts_records num_spans 5 +system public protected_ts_records spans 6 +system public protected_ts_records ts 2 +system public protected_ts_records verified 7 +system public rangelog eventType 4 +system public rangelog info 6 +system public rangelog otherRangeID 5 +system public rangelog rangeID 2 +system public rangelog storeID 3 +system public rangelog timestamp 1 +system public rangelog uniqueID 7 +system public replication_constraint_stats config 4 +system public replication_constraint_stats report_id 5 +system public replication_constraint_stats subzone_id 2 +system public replication_constraint_stats type 3 +system public replication_constraint_stats violating_ranges 7 +system public replication_constraint_stats violation_start 6 +system public replication_constraint_stats zone_id 1 +system public replication_critical_localities at_risk_ranges 5 +system public replication_critical_localities locality 3 +system public replication_critical_localities report_id 4 +system public replication_critical_localities subzone_id 2 +system public replication_critical_localities zone_id 1 +system public replication_stats over_replicated_ranges 7 +system public replication_stats report_id 3 +system public replication_stats subzone_id 2 +system public replication_stats total_ranges 4 +system public replication_stats unavailable_ranges 5 +system public replication_stats under_replicated_ranges 6 +system public replication_stats zone_id 1 +system public reports_meta generated 2 +system public reports_meta id 1 +system public role_members isAdmin 3 +system public role_members member 2 +system public role_members role 1 +system public role_options option 2 +system public role_options username 1 +system public role_options value 3 +system public settings lastUpdated 3 +system public settings name 1 +system public settings value 2 +system public settings valueType 4 +system public statement_bundle_chunks data 3 +system public statement_bundle_chunks description 2 +system public statement_bundle_chunks id 1 +system public statement_diagnostics bundle_chunks 6 +system public statement_diagnostics collected_at 4 +system public statement_diagnostics error 7 +system public statement_diagnostics id 1 +system public statement_diagnostics statement 3 +system public statement_diagnostics statement_fingerprint 2 +system public statement_diagnostics trace 5 +system public statement_diagnostics_requests completed 2 +system public statement_diagnostics_requests completed_at 6 +system public statement_diagnostics_requests id 1 +system public statement_diagnostics_requests requested_at 5 +system public statement_diagnostics_requests statement_diagnostics_id 4 +system public statement_diagnostics_requests statement_fingerprint 3 +system public table_statistics columnIDs 4 +system public table_statistics createdAt 5 +system public table_statistics distinctCount 7 +system public table_statistics histogram 9 +system public table_statistics name 3 +system public table_statistics nullCount 8 +system public table_statistics rowCount 6 +system public table_statistics statisticID 2 +system public table_statistics tableID 1 +system public ui key 1 +system public ui lastUpdated 3 +system public ui value 2 +system public users hashedPassword 2 +system public users isRole 3 +system public users username 1 +system public web_sessions auditInfo 8 +system public web_sessions createdAt 4 +system public web_sessions expiresAt 5 +system public web_sessions hashedSecret 2 +system public web_sessions id 1 +system public web_sessions lastUsedAt 7 +system public web_sessions revokedAt 6 +system public web_sessions username 3 +system public zones config 2 +system public zones id 1 statement ok SET DATABASE = test @@ -1708,6 +1753,36 @@ NULL root system public settings NULL root system public settings INSERT NULL NO NULL root system public settings SELECT NULL YES NULL root system public settings UPDATE NULL NO +NULL admin system public statement_bundle_chunks DELETE NULL NO +NULL admin system public statement_bundle_chunks GRANT NULL NO +NULL admin system public statement_bundle_chunks INSERT NULL NO +NULL admin system public statement_bundle_chunks SELECT NULL YES +NULL admin system public statement_bundle_chunks UPDATE NULL NO +NULL root system public statement_bundle_chunks DELETE NULL NO +NULL root system public statement_bundle_chunks GRANT NULL NO +NULL root system public statement_bundle_chunks INSERT NULL NO +NULL root system public statement_bundle_chunks SELECT NULL YES +NULL root system public statement_bundle_chunks UPDATE NULL NO +NULL admin system public statement_diagnostics DELETE NULL NO +NULL admin system public statement_diagnostics GRANT NULL NO +NULL admin system public statement_diagnostics INSERT NULL NO +NULL admin system public statement_diagnostics SELECT NULL YES +NULL admin system public statement_diagnostics UPDATE NULL NO +NULL root system public statement_diagnostics DELETE NULL NO +NULL root system public statement_diagnostics GRANT NULL NO +NULL root system public statement_diagnostics INSERT NULL NO +NULL root system public statement_diagnostics SELECT NULL YES +NULL root system public statement_diagnostics UPDATE NULL NO +NULL admin system public statement_diagnostics_requests DELETE NULL NO +NULL admin system public statement_diagnostics_requests GRANT NULL NO +NULL admin system public statement_diagnostics_requests INSERT NULL NO +NULL admin system public statement_diagnostics_requests SELECT NULL YES +NULL admin system public statement_diagnostics_requests UPDATE NULL NO +NULL root system public statement_diagnostics_requests DELETE NULL NO +NULL root system public statement_diagnostics_requests GRANT NULL NO +NULL root system public statement_diagnostics_requests INSERT NULL NO +NULL root system public statement_diagnostics_requests SELECT NULL YES +NULL root system public statement_diagnostics_requests UPDATE NULL NO NULL admin system public table_statistics DELETE NULL NO NULL admin system public table_statistics GRANT NULL NO NULL admin system public table_statistics INSERT NULL NO @@ -2073,6 +2148,36 @@ NULL root system public role_options NULL root system public role_options INSERT NULL NO NULL root system public role_options SELECT NULL YES NULL root system public role_options UPDATE NULL NO +NULL admin system public statement_bundle_chunks DELETE NULL NO +NULL admin system public statement_bundle_chunks GRANT NULL NO +NULL admin system public statement_bundle_chunks INSERT NULL NO +NULL admin system public statement_bundle_chunks SELECT NULL YES +NULL admin system public statement_bundle_chunks UPDATE NULL NO +NULL root system public statement_bundle_chunks DELETE NULL NO +NULL root system public statement_bundle_chunks GRANT NULL NO +NULL root system public statement_bundle_chunks INSERT NULL NO +NULL root system public statement_bundle_chunks SELECT NULL YES +NULL root system public statement_bundle_chunks UPDATE NULL NO +NULL admin system public statement_diagnostics_requests DELETE NULL NO +NULL admin system public statement_diagnostics_requests GRANT NULL NO +NULL admin system public statement_diagnostics_requests INSERT NULL NO +NULL admin system public statement_diagnostics_requests SELECT NULL YES +NULL admin system public statement_diagnostics_requests UPDATE NULL NO +NULL root system public statement_diagnostics_requests DELETE NULL NO +NULL root system public statement_diagnostics_requests GRANT NULL NO +NULL root system public statement_diagnostics_requests INSERT NULL NO +NULL root system public statement_diagnostics_requests SELECT NULL YES +NULL root system public statement_diagnostics_requests UPDATE NULL NO +NULL admin system public statement_diagnostics DELETE NULL NO +NULL admin system public statement_diagnostics GRANT NULL NO +NULL admin system public statement_diagnostics INSERT NULL NO +NULL admin system public statement_diagnostics SELECT NULL YES +NULL admin system public statement_diagnostics UPDATE NULL NO +NULL root system public statement_diagnostics DELETE NULL NO +NULL root system public statement_diagnostics GRANT NULL NO +NULL root system public statement_diagnostics INSERT NULL NO +NULL root system public statement_diagnostics SELECT NULL YES +NULL root system public statement_diagnostics UPDATE NULL NO statement ok CREATE TABLE other_db.xyz (i INT) diff --git a/pkg/sql/logictest/testdata/logic_test/pg_catalog b/pkg/sql/logictest/testdata/logic_test/pg_catalog index 6463f073c96c..1048d36cd3a8 100644 --- a/pkg/sql/logictest/testdata/logic_test/pg_catalog +++ b/pkg/sql/logictest/testdata/logic_test/pg_catalog @@ -629,6 +629,8 @@ indexrelid indrelid indnatts indisunique indisprimary indisexclusion indim 1062763829 25 4 true true false true false true false false true false 1 2 3 4 0 0 3903121477 3903121477 0 0 0 0 2 2 2 2 NULL NULL 1276104432 12 2 true true false true false true false false true false 1 6 0 0 0 0 2 2 NULL NULL 1322500096 28 1 true true false true false true false false true false 1 0 0 2 NULL NULL +1489445036 35 2 false false false false false true false false true false 2 1 0 0 0 0 2 2 NULL NULL +1489445039 35 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1582236367 3 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1628632028 19 1 false false false false false true false false true false 5 0 0 2 NULL NULL 1628632029 19 1 false false false false false true false false true false 4 0 0 2 NULL NULL @@ -640,8 +642,10 @@ indexrelid indrelid indnatts indisunique indisprimary indisexclusion indim 2621181440 15 2 false false false false false true false false true false 2 3 3903121477 0 0 0 2 2 NULL NULL 2621181443 15 1 true true false true false true false false true false 1 0 0 2 NULL NULL 2667577107 31 1 true true false true false true false false true false 1 0 0 2 NULL NULL +2834522046 34 1 true true false true false true false false true false 1 0 0 2 NULL NULL 2927313374 2 2 true true false true false true false false true false 1 2 0 3903121477 0 0 2 2 NULL NULL 3094258317 33 2 true true false true false true false false true false 1 2 3903121477 3903121477 0 0 2 2 NULL NULL +3353994584 36 1 true true false true false true false false true false 1 0 0 2 NULL NULL 3446785912 4 1 true true false true false true false false true false 1 3903121477 0 2 NULL NULL 3493181576 20 2 true true false true false true false false true false 1 2 0 0 0 0 2 2 NULL NULL 3706522183 11 4 true true false true false true false false true false 1 2 4 3 0 0 0 0 0 0 0 0 2 2 2 2 NULL NULL @@ -674,6 +678,9 @@ indexrelid operator_argument_type_oid operator_argument_position 1276104432 0 1 1276104432 0 2 1322500096 0 1 +1489445036 0 1 +1489445036 0 2 +1489445039 0 1 1582236367 0 1 1628632028 0 1 1628632029 0 1 @@ -689,10 +696,12 @@ indexrelid operator_argument_type_oid operator_argument_position 2621181440 0 2 2621181443 0 1 2667577107 0 1 +2834522046 0 1 2927313374 0 1 2927313374 0 2 3094258317 0 1 3094258317 0 2 +3353994584 0 1 3446785912 0 1 3493181576 0 1 3493181576 0 2 diff --git a/pkg/sql/logictest/testdata/logic_test/ranges b/pkg/sql/logictest/testdata/logic_test/ranges index 74016c0898c3..c6c1eda85ef4 100644 --- a/pkg/sql/logictest/testdata/logic_test/ranges +++ b/pkg/sql/logictest/testdata/logic_test/ranges @@ -303,7 +303,10 @@ start_key start_pretty end_key [166] /NamespaceTable/30 [167] /NamespaceTable/Max system namespace · {1} 1 [167] /NamespaceTable/Max [168] /Table/32 system protected_ts_meta · {1} 1 [168] /Table/32 [169] /Table/33 system protected_ts_records · {1} 1 -[169] /Table/33 [189 137] /Table/53/1 system role_options · {1} 1 +[169] /Table/33 [170] /Table/34 system role_options · {1} 1 +[170] /Table/34 [171] /Table/35 system statement_bundle_chunks · {1} 1 +[171] /Table/35 [172] /Table/36 system statement_diagnostics_requests · {1} 1 +[172] /Table/36 [189 137] /Table/53/1 system statement_diagnostics · {1} 1 [189 137] /Table/53/1 [189 137 137] /Table/53/1/1 test t · {1} 1 [189 137 137] /Table/53/1/1 [189 137 141 137] /Table/53/1/5/1 test t · {3,4} 3 [189 137 141 137] /Table/53/1/5/1 [189 137 141 138] /Table/53/1/5/2 test t · {1,2,3} 1 @@ -355,7 +358,10 @@ start_key start_pretty end_key [166] /NamespaceTable/30 [167] /NamespaceTable/Max system namespace · {1} 1 [167] /NamespaceTable/Max [168] /Table/32 system protected_ts_meta · {1} 1 [168] /Table/32 [169] /Table/33 system protected_ts_records · {1} 1 -[169] /Table/33 [189 137] /Table/53/1 system role_options · {1} 1 +[169] /Table/33 [170] /Table/34 system role_options · {1} 1 +[170] /Table/34 [171] /Table/35 system statement_bundle_chunks · {1} 1 +[171] /Table/35 [172] /Table/36 system statement_diagnostics_requests · {1} 1 +[172] /Table/36 [189 137] /Table/53/1 system statement_diagnostics · {1} 1 [189 137] /Table/53/1 [189 137 137] /Table/53/1/1 test t · {1} 1 [189 137 137] /Table/53/1/1 [189 137 141 137] /Table/53/1/5/1 test t · {3,4} 3 [189 137 141 137] /Table/53/1/5/1 [189 137 141 138] /Table/53/1/5/2 test t · {1,2,3} 1 diff --git a/pkg/sql/logictest/testdata/logic_test/show_source b/pkg/sql/logictest/testdata/logic_test/show_source index c8cc4fab33db..4ed895fc2516 100644 --- a/pkg/sql/logictest/testdata/logic_test/show_source +++ b/pkg/sql/logictest/testdata/logic_test/show_source @@ -199,6 +199,9 @@ reports_meta namespace protected_ts_meta protected_ts_records +statement_bundle_chunks +statement_diagnostics_requests +statement_diagnostics role_options query TT colnames,rowsort @@ -227,6 +230,9 @@ reports_meta · namespace · protected_ts_meta · protected_ts_records · +statement_bundle_chunks · +statement_diagnostics_requests · +statement_diagnostics · role_options · query ITTT colnames diff --git a/pkg/sql/logictest/testdata/logic_test/system b/pkg/sql/logictest/testdata/logic_test/system index 70fcdfd370a8..23d5e91b9ba1 100644 --- a/pkg/sql/logictest/testdata/logic_test/system +++ b/pkg/sql/logictest/testdata/logic_test/system @@ -27,6 +27,9 @@ reports_meta role_members role_options settings +statement_bundle_chunks +statement_diagnostics +statement_diagnostics_requests table_statistics ui users @@ -60,6 +63,9 @@ SELECT id FROM system.descriptor 31 32 33 +34 +35 +36 50 51 52 @@ -330,6 +336,36 @@ system public settings root GRANT system public settings root INSERT system public settings root SELECT system public settings root UPDATE +system public statement_bundle_chunks admin DELETE +system public statement_bundle_chunks admin GRANT +system public statement_bundle_chunks admin INSERT +system public statement_bundle_chunks admin SELECT +system public statement_bundle_chunks admin UPDATE +system public statement_bundle_chunks root DELETE +system public statement_bundle_chunks root GRANT +system public statement_bundle_chunks root INSERT +system public statement_bundle_chunks root SELECT +system public statement_bundle_chunks root UPDATE +system public statement_diagnostics admin DELETE +system public statement_diagnostics admin GRANT +system public statement_diagnostics admin INSERT +system public statement_diagnostics admin SELECT +system public statement_diagnostics admin UPDATE +system public statement_diagnostics root DELETE +system public statement_diagnostics root GRANT +system public statement_diagnostics root INSERT +system public statement_diagnostics root SELECT +system public statement_diagnostics root UPDATE +system public statement_diagnostics_requests admin DELETE +system public statement_diagnostics_requests admin GRANT +system public statement_diagnostics_requests admin INSERT +system public statement_diagnostics_requests admin SELECT +system public statement_diagnostics_requests admin UPDATE +system public statement_diagnostics_requests root DELETE +system public statement_diagnostics_requests root GRANT +system public statement_diagnostics_requests root INSERT +system public statement_diagnostics_requests root SELECT +system public statement_diagnostics_requests root UPDATE system public table_statistics admin DELETE system public table_statistics admin GRANT system public table_statistics admin INSERT diff --git a/pkg/sql/logictest/testdata/logic_test/system_namespace b/pkg/sql/logictest/testdata/logic_test/system_namespace index 1d61a05d592d..3161aacc1edc 100644 --- a/pkg/sql/logictest/testdata/logic_test/system_namespace +++ b/pkg/sql/logictest/testdata/logic_test/system_namespace @@ -28,6 +28,9 @@ SELECT * FROM system.namespace 1 29 role_members 23 1 29 role_options 33 1 29 settings 6 +1 29 statement_bundle_chunks 34 +1 29 statement_diagnostics 36 +1 29 statement_diagnostics_requests 35 1 29 table_statistics 20 1 29 ui 14 1 29 users 4 diff --git a/pkg/sql/opt/exec/execbuilder/testdata/autocommit b/pkg/sql/opt/exec/execbuilder/testdata/autocommit index 36d6acb062f3..ddbdd538d933 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/autocommit +++ b/pkg/sql/opt/exec/execbuilder/testdata/autocommit @@ -33,11 +33,11 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r29: sending batch 1 CPut, 1 EndTxn to (n1,s1):1 +dist sender send r32: sending batch 1 CPut, 1 EndTxn to (n1,s1):1 # Multi-row insert should auto-commit. query B @@ -54,11 +54,11 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r29: sending batch 2 CPut, 1 EndTxn to (n1,s1):1 +dist sender send r32: sending batch 2 CPut, 1 EndTxn to (n1,s1):1 # No auto-commit inside a transaction. statement ok @@ -78,11 +78,11 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r29: sending batch 2 CPut to (n1,s1):1 +dist sender send r32: sending batch 2 CPut to (n1,s1):1 statement ok ROLLBACK @@ -102,11 +102,11 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r29: sending batch 2 CPut, 1 EndTxn to (n1,s1):1 +dist sender send r32: sending batch 2 CPut, 1 EndTxn to (n1,s1):1 # TODO(radu): allow non-side-effecting projections. query B @@ -123,13 +123,13 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r29: sending batch 2 CPut to (n1,s1):1 -dist sender send r29: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r32: sending batch 2 CPut to (n1,s1):1 +dist sender send r32: sending batch 1 EndTxn to (n1,s1):1 # Insert with RETURNING statement with side-effects should not auto-commit. # In this case division can (in principle) error out. @@ -147,13 +147,13 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r29: sending batch 2 CPut to (n1,s1):1 -dist sender send r29: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r32: sending batch 2 CPut to (n1,s1):1 +dist sender send r32: sending batch 1 EndTxn to (n1,s1):1 # Another way to test the scenario above: generate an error and ensure that the # mutation was not committed. @@ -184,11 +184,11 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r29: sending batch 1 Put, 1 EndTxn to (n1,s1):1 +dist sender send r32: sending batch 1 Put, 1 EndTxn to (n1,s1):1 # Multi-row upsert should auto-commit. query B @@ -205,11 +205,11 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r29: sending batch 2 Put, 1 EndTxn to (n1,s1):1 +dist sender send r32: sending batch 2 Put, 1 EndTxn to (n1,s1):1 # No auto-commit inside a transaction. statement ok @@ -229,11 +229,11 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r29: sending batch 2 Put to (n1,s1):1 +dist sender send r32: sending batch 2 Put to (n1,s1):1 statement ok ROLLBACK @@ -253,11 +253,11 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r29: sending batch 2 Put, 1 EndTxn to (n1,s1):1 +dist sender send r32: sending batch 2 Put, 1 EndTxn to (n1,s1):1 # TODO(radu): allow non-side-effecting projections. query B @@ -274,13 +274,13 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r29: sending batch 2 Put to (n1,s1):1 -dist sender send r29: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r32: sending batch 2 Put to (n1,s1):1 +dist sender send r32: sending batch 1 EndTxn to (n1,s1):1 # Upsert with RETURNING statement with side-effects should not auto-commit. # In this case division can (in principle) error out. @@ -298,13 +298,13 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r29: sending batch 2 Put to (n1,s1):1 -dist sender send r29: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r32: sending batch 2 Put to (n1,s1):1 +dist sender send r32: sending batch 1 EndTxn to (n1,s1):1 # Another way to test the scenario above: generate an error and ensure that the # mutation was not committed. @@ -335,12 +335,12 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r29: sending batch 1 Scan to (n1,s1):1 -dist sender send r29: sending batch 2 Put, 1 EndTxn to (n1,s1):1 +dist sender send r32: sending batch 1 Scan to (n1,s1):1 +dist sender send r32: sending batch 2 Put, 1 EndTxn to (n1,s1):1 # No auto-commit inside a transaction. statement ok @@ -360,12 +360,12 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r29: sending batch 1 Scan to (n1,s1):1 -dist sender send r29: sending batch 2 Put to (n1,s1):1 +dist sender send r32: sending batch 1 Scan to (n1,s1):1 +dist sender send r32: sending batch 2 Put to (n1,s1):1 statement ok ROLLBACK @@ -385,12 +385,12 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r29: sending batch 1 Scan to (n1,s1):1 -dist sender send r29: sending batch 2 Put, 1 EndTxn to (n1,s1):1 +dist sender send r32: sending batch 1 Scan to (n1,s1):1 +dist sender send r32: sending batch 2 Put, 1 EndTxn to (n1,s1):1 # TODO(radu): allow non-side-effecting projections. query B @@ -407,14 +407,14 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r29: sending batch 1 Scan to (n1,s1):1 -dist sender send r29: sending batch 2 Put to (n1,s1):1 -dist sender send r29: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r32: sending batch 1 Scan to (n1,s1):1 +dist sender send r32: sending batch 2 Put to (n1,s1):1 +dist sender send r32: sending batch 1 EndTxn to (n1,s1):1 # Update with RETURNING statement with side-effects should not auto-commit. # In this case division can (in principle) error out. @@ -432,14 +432,14 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r29: sending batch 1 Scan to (n1,s1):1 -dist sender send r29: sending batch 2 Put to (n1,s1):1 -dist sender send r29: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r32: sending batch 1 Scan to (n1,s1):1 +dist sender send r32: sending batch 2 Put to (n1,s1):1 +dist sender send r32: sending batch 1 EndTxn to (n1,s1):1 # Another way to test the scenario above: generate an error and ensure that the # mutation was not committed. @@ -470,11 +470,11 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r29: sending batch 1 DelRng, 1 EndTxn to (n1,s1):1 +dist sender send r32: sending batch 1 DelRng, 1 EndTxn to (n1,s1):1 # Multi-row delete should auto-commit. query B @@ -491,11 +491,11 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r29: sending batch 1 DelRng, 1 EndTxn to (n1,s1):1 +dist sender send r32: sending batch 1 DelRng, 1 EndTxn to (n1,s1):1 # No auto-commit inside a transaction. statement ok @@ -515,11 +515,11 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r29: sending batch 1 DelRng to (n1,s1):1 +dist sender send r32: sending batch 1 DelRng to (n1,s1):1 statement ok ROLLBACK @@ -539,12 +539,12 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r29: sending batch 1 Scan to (n1,s1):1 -dist sender send r29: sending batch 2 Del, 1 EndTxn to (n1,s1):1 +dist sender send r32: sending batch 1 Scan to (n1,s1):1 +dist sender send r32: sending batch 2 Del, 1 EndTxn to (n1,s1):1 # TODO(radu): allow non-side-effecting projections. query B @@ -561,14 +561,14 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r29: sending batch 1 Scan to (n1,s1):1 -dist sender send r29: sending batch 2 Del to (n1,s1):1 -dist sender send r29: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r32: sending batch 1 Scan to (n1,s1):1 +dist sender send r32: sending batch 2 Del to (n1,s1):1 +dist sender send r32: sending batch 1 EndTxn to (n1,s1):1 # Insert with RETURNING statement with side-effects should not auto-commit. # In this case division can (in principle) error out. @@ -586,14 +586,14 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r29: sending batch 1 Scan to (n1,s1):1 -dist sender send r29: sending batch 2 Del to (n1,s1):1 -dist sender send r29: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r32: sending batch 1 Scan to (n1,s1):1 +dist sender send r32: sending batch 2 Del to (n1,s1):1 +dist sender send r32: sending batch 1 EndTxn to (n1,s1):1 statement ok INSERT INTO ab VALUES (12, 0); @@ -636,14 +636,14 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r29: sending batch 2 CPut, 2 InitPut to (n1,s1):1 -dist sender send r29: sending batch 2 Scan to (n1,s1):1 -dist sender send r29: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r32: sending batch 2 CPut, 2 InitPut to (n1,s1):1 +dist sender send r32: sending batch 2 Scan to (n1,s1):1 +dist sender send r32: sending batch 1 EndTxn to (n1,s1):1 query B SELECT count(*) > 0 FROM [ @@ -659,15 +659,15 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r29: sending batch 1 Scan to (n1,s1):1 -dist sender send r29: sending batch 1 Put, 1 CPut, 1 Del to (n1,s1):1 -dist sender send r29: sending batch 1 Scan to (n1,s1):1 -dist sender send r29: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r32: sending batch 1 Scan to (n1,s1):1 +dist sender send r32: sending batch 1 Put, 1 CPut, 1 Del to (n1,s1):1 +dist sender send r32: sending batch 1 Scan to (n1,s1):1 +dist sender send r32: sending batch 1 EndTxn to (n1,s1):1 query B SELECT count(*) > 0 FROM [ @@ -684,15 +684,15 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r29: sending batch 1 Scan to (n1,s1):1 -dist sender send r29: sending batch 1 Del to (n1,s1):1 -dist sender send r29: sending batch 1 Scan to (n1,s1):1 -dist sender send r29: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r32: sending batch 1 Scan to (n1,s1):1 +dist sender send r32: sending batch 1 Del to (n1,s1):1 +dist sender send r32: sending batch 1 Scan to (n1,s1):1 +dist sender send r32: sending batch 1 EndTxn to (n1,s1):1 # ----------------------- # Multiple mutation tests @@ -715,14 +715,14 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r29: sending batch 2 CPut to (n1,s1):1 -dist sender send r29: sending batch 2 CPut to (n1,s1):1 -dist sender send r29: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r32: sending batch 2 CPut to (n1,s1):1 +dist sender send r32: sending batch 2 CPut to (n1,s1):1 +dist sender send r32: sending batch 1 EndTxn to (n1,s1):1 query B SELECT count(*) > 0 FROM [ @@ -740,11 +740,11 @@ SET TRACING=OFF query TT SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] -WHERE message LIKE '%r29: sending batch%' +WHERE message LIKE '%r32: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r29: sending batch 2 CPut to (n1,s1):1 -dist sender send r29: sending batch 2 CPut to (n1,s1):1 -dist sender send r29: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r32: sending batch 2 CPut to (n1,s1):1 +dist sender send r32: sending batch 2 CPut to (n1,s1):1 +dist sender send r32: sending batch 1 EndTxn to (n1,s1):1 diff --git a/pkg/sql/opt/exec/execbuilder/testdata/delete_range b/pkg/sql/opt/exec/execbuilder/testdata/delete_range index 50636778c1f8..196340dd71cb 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/delete_range +++ b/pkg/sql/opt/exec/execbuilder/testdata/delete_range @@ -16,9 +16,9 @@ SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] WHERE message LIKE '%DelRange%' OR message LIKE '%DelRng%' ---- flow DelRange /Table/53/1 - /Table/53/2 -dist sender send r29: sending batch 1 DelRng to (n1,s1):1 +dist sender send r32: sending batch 1 DelRng to (n1,s1):1 flow DelRange /Table/53/1/601/0 - /Table/53/2 -dist sender send r29: sending batch 1 DelRng to (n1,s1):1 +dist sender send r32: sending batch 1 DelRng to (n1,s1):1 # Ensure that DelRange requests are autocommitted when DELETE FROM happens on a # chunk of fewer than 600 keys. @@ -34,4 +34,4 @@ SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] WHERE message LIKE '%DelRange%' OR message LIKE '%sending batch%' ---- flow DelRange /Table/53/1/5 - /Table/53/1/5/# -dist sender send r29: sending batch 1 DelRng, 1 EndTxn to (n1,s1):1 +dist sender send r32: sending batch 1 DelRng, 1 EndTxn to (n1,s1):1 diff --git a/pkg/sql/opt/exec/execbuilder/testdata/upsert b/pkg/sql/opt/exec/execbuilder/testdata/upsert index 5f63e9cfedc1..d08b87243d9b 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/upsert +++ b/pkg/sql/opt/exec/execbuilder/testdata/upsert @@ -255,7 +255,7 @@ SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] table reader Scan /Table/57/1/2{-/#} flow CPut /Table/57/1/2/0 -> /TUPLE/2:2:Int/3 flow InitPut /Table/57/2/3/0 -> /BYTES/0x8a -kv.DistSender: sending partial batch r29: sending batch 1 CPut, 1 EndTxn to (n1,s1):1 +kv.DistSender: sending partial batch r32: sending batch 1 CPut, 1 EndTxn to (n1,s1):1 flow fast path completed exec stmt rows affected: 1 @@ -269,7 +269,7 @@ SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] table reader Scan /Table/57/1/1{-/#} flow CPut /Table/57/1/1/0 -> /TUPLE/2:2:Int/2 flow InitPut /Table/57/2/2/0 -> /BYTES/0x89 -kv.DistSender: sending partial batch r29: sending batch 1 CPut, 1 EndTxn to (n1,s1):1 +kv.DistSender: sending partial batch r32: sending batch 1 CPut, 1 EndTxn to (n1,s1):1 flow fast path completed exec stmt rows affected: 1 @@ -286,7 +286,7 @@ table reader fetched: /kv/primary/2/v -> /3 flow Put /Table/57/1/2/0 -> /TUPLE/2:2:Int/2 flow Del /Table/57/2/3/0 flow CPut /Table/57/2/2/0 -> /BYTES/0x8a (expecting does not exist) -kv.DistSender: sending partial batch r29: sending batch 1 Put, 1 EndTxn to (n1,s1):1 +kv.DistSender: sending partial batch r32: sending batch 1 Put, 1 EndTxn to (n1,s1):1 exec stmt execution failed after 0 rows: duplicate key value (v)=(2) violates unique constraint "woo" diff --git a/pkg/sql/pgwire/pgwire_test.go b/pkg/sql/pgwire/pgwire_test.go index 64d4966ac925..37b906558973 100644 --- a/pkg/sql/pgwire/pgwire_test.go +++ b/pkg/sql/pgwire/pgwire_test.go @@ -556,7 +556,7 @@ func TestPGPreparedQuery(t *testing.T) { baseTest.Results("users", "primary", false, 1, "username", "ASC", false, false), }}, {"SHOW TABLES FROM system", []preparedQueryTest{ - baseTest.Results("comments").Others(22), + baseTest.Results("comments").Others(25), }}, {"SHOW SCHEMAS FROM system", []preparedQueryTest{ baseTest.Results("crdb_internal").Others(3), diff --git a/pkg/sql/sqlbase/system.go b/pkg/sql/sqlbase/system.go index d0957dfb9110..30b56bf765bc 100644 --- a/pkg/sql/sqlbase/system.go +++ b/pkg/sql/sqlbase/system.go @@ -250,6 +250,41 @@ CREATE TABLE system.protected_ts_records ( verified BOOL NOT NULL DEFAULT (false), FAMILY "primary" (id, ts, meta_type, meta, num_spans, spans, verified) );` + + StatementBundleChunksTableSchema = ` +CREATE TABLE system.statement_bundle_chunks ( + id INT8 PRIMARY KEY DEFAULT unique_rowid(), + description STRING, + data BYTES NOT NULL, + + FAMILY "primary" (id, description, data) +);` + + StatementDiagnosticsRequestsTableSchema = ` +CREATE TABLE system.statement_diagnostics_requests( + id INT8 DEFAULT unique_rowid() PRIMARY KEY NOT NULL, + completed BOOL NOT NULL DEFAULT FALSE, + statement_fingerprint STRING NOT NULL, + statement_diagnostics_id INT8, + requested_at TIMESTAMPTZ NOT NULL, + completed_at TIMESTAMPTZ, + INDEX completed_idx (completed, id) STORING (statement_fingerprint), + + FAMILY "primary" (id, completed, statement_fingerprint, statement_diagnostics_id, requested_at, completed_at) +);` + + StatementDiagnosticsTableSchema = ` +create table system.statement_diagnostics( + id INT8 DEFAULT unique_rowid() PRIMARY KEY NOT NULL, + statement_fingerprint STRING NOT NULL, + statement STRING NOT NULL, + collected_at TIMESTAMPTZ NOT NULL, + trace JSONB, + bundle_chunks INT ARRAY, + error STRING, + + FAMILY "primary" (id, statement_fingerprint, statement, collected_at, trace, bundle_chunks, error) +);` ) func pk(name string) IndexDescriptor { @@ -299,6 +334,9 @@ var SystemAllowedPrivileges = map[ID]privilege.List{ keys.ReportsMetaTableID: privilege.ReadWriteData, keys.ProtectedTimestampsMetaTableID: privilege.ReadData, keys.ProtectedTimestampsRecordsTableID: privilege.ReadData, + keys.StatementBundleChunksTableID: privilege.ReadWriteData, + keys.StatementDiagnosticsRequestsTableID: privilege.ReadWriteData, + keys.StatementDiagnosticsTableID: privilege.ReadWriteData, } // Helpers used to make some of the TableDescriptor literals below more concise. @@ -1288,6 +1326,113 @@ var ( FormatVersion: InterleavedFormatVersion, NextMutationID: 1, } + + StatementBundleChunksTable = TableDescriptor{ + Name: "statement_bundle_chunks", + ID: keys.StatementBundleChunksTableID, + ParentID: keys.SystemDatabaseID, + UnexposedParentSchemaID: keys.PublicSchemaID, + Version: 1, + Columns: []ColumnDescriptor{ + {Name: "id", ID: 1, Type: *types.Int, DefaultExpr: &uniqueRowIDString}, + {Name: "description", ID: 2, Type: *types.String, Nullable: true}, + {Name: "data", ID: 3, Type: *types.Bytes}, + }, + NextColumnID: 4, + Families: []ColumnFamilyDescriptor{ + { + Name: "primary", + ColumnNames: []string{"id", "description", "data"}, + ColumnIDs: []ColumnID{1, 2, 3}, + }, + }, + NextFamilyID: 1, + PrimaryIndex: pk("id"), + NextIndexID: 2, + Privileges: NewCustomSuperuserPrivilegeDescriptor(SystemAllowedPrivileges[keys.StatementBundleChunksTableID]), + FormatVersion: InterleavedFormatVersion, + NextMutationID: 1, + } + + // TODO(andrei): Add a foreign key reference to the statement_diagnostics table when + // it no longer requires us to create an index on statement_diagnostics_id. + StatementDiagnosticsRequestsTable = TableDescriptor{ + Name: "statement_diagnostics_requests", + ID: keys.StatementDiagnosticsRequestsTableID, + ParentID: keys.SystemDatabaseID, + UnexposedParentSchemaID: keys.PublicSchemaID, + Version: 1, + Columns: []ColumnDescriptor{ + {Name: "id", ID: 1, Type: *types.Int, DefaultExpr: &uniqueRowIDString, Nullable: false}, + {Name: "completed", ID: 2, Type: *types.Bool, Nullable: false, DefaultExpr: &falseBoolString}, + {Name: "statement_fingerprint", ID: 3, Type: *types.String, Nullable: false}, + {Name: "statement_diagnostics_id", ID: 4, Type: *types.Int, Nullable: true}, + {Name: "requested_at", ID: 5, Type: *types.TimestampTZ, Nullable: false}, + {Name: "completed_at", ID: 6, Type: *types.TimestampTZ, Nullable: true}, + }, + NextColumnID: 7, + Families: []ColumnFamilyDescriptor{ + { + Name: "primary", + ColumnNames: []string{"id", "completed", "statement_fingerprint", "statement_diagnostics_id", "requested_at", "completed_at"}, + ColumnIDs: []ColumnID{1, 2, 3, 4, 5, 6}, + }, + }, + NextFamilyID: 1, + PrimaryIndex: pk("id"), + // Index for the polling query. + Indexes: []IndexDescriptor{ + { + Name: "completed_idx", + ID: 2, + Unique: false, + ColumnNames: []string{"completed", "id"}, + StoreColumnNames: []string{"statement_fingerprint"}, + ColumnIDs: []ColumnID{2, 1}, + ColumnDirections: []IndexDescriptor_Direction{IndexDescriptor_ASC, IndexDescriptor_ASC}, + StoreColumnIDs: []ColumnID{3}, + Version: SecondaryIndexFamilyFormatVersion, + }, + }, + NextIndexID: 3, + Privileges: NewCustomSuperuserPrivilegeDescriptor( + SystemAllowedPrivileges[keys.StatementDiagnosticsRequestsTableID]), + FormatVersion: InterleavedFormatVersion, + NextMutationID: 1, + } + + StatementDiagnosticsTable = TableDescriptor{ + Name: "statement_diagnostics", + ID: keys.StatementDiagnosticsTableID, + ParentID: keys.SystemDatabaseID, + UnexposedParentSchemaID: keys.PublicSchemaID, + Version: 1, + Columns: []ColumnDescriptor{ + {Name: "id", ID: 1, Type: *types.Int, DefaultExpr: &uniqueRowIDString, Nullable: false}, + {Name: "statement_fingerprint", ID: 2, Type: *types.String, Nullable: false}, + {Name: "statement", ID: 3, Type: *types.String, Nullable: false}, + {Name: "collected_at", ID: 4, Type: *types.TimestampTZ, Nullable: false}, + {Name: "trace", ID: 5, Type: *types.Jsonb, Nullable: true}, + {Name: "bundle_chunks", ID: 6, Type: *types.IntArray, Nullable: true}, + {Name: "error", ID: 7, Type: *types.String, Nullable: true}, + }, + NextColumnID: 8, + Families: []ColumnFamilyDescriptor{ + { + Name: "primary", + ColumnNames: []string{"id", "statement_fingerprint", "statement", + "collected_at", "trace", "bundle_chunks", "error"}, + ColumnIDs: []ColumnID{1, 2, 3, 4, 5, 6, 7}, + }, + }, + NextFamilyID: 1, + PrimaryIndex: pk("id"), + NextIndexID: 2, + Privileges: NewCustomSuperuserPrivilegeDescriptor( + SystemAllowedPrivileges[keys.StatementDiagnosticsTableID]), + FormatVersion: InterleavedFormatVersion, + NextMutationID: 1, + } ) // Create a kv pair for the zone config for the given key and config value. @@ -1341,6 +1486,11 @@ func addSystemDescriptorsToSchema(target *MetadataSchema) { target.AddDescriptor(keys.SystemDatabaseID, &ReplicationCriticalLocalitiesTable) target.AddDescriptor(keys.SystemDatabaseID, &ProtectedTimestampsMetaTable) target.AddDescriptor(keys.SystemDatabaseID, &ProtectedTimestampsRecordsTable) + + // Tables introduced in 20.1. + target.AddDescriptor(keys.SystemDatabaseID, &StatementBundleChunksTable) + target.AddDescriptor(keys.SystemDatabaseID, &StatementDiagnosticsRequestsTable) + target.AddDescriptor(keys.SystemDatabaseID, &StatementDiagnosticsTable) } // addSystemDatabaseToSchema populates the supplied MetadataSchema with the diff --git a/pkg/sql/statement_diagnostics.go b/pkg/sql/statement_diagnostics.go new file mode 100644 index 000000000000..3863efc0d4cf --- /dev/null +++ b/pkg/sql/statement_diagnostics.go @@ -0,0 +1,414 @@ +// Copyright 2020 The Cockroach Authors. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package sql + +import ( + "context" + "encoding/binary" + "errors" + + "github.com/cockroachdb/cockroach/pkg/gossip" + "github.com/cockroachdb/cockroach/pkg/internal/client" + "github.com/cockroachdb/cockroach/pkg/roachpb" + "github.com/cockroachdb/cockroach/pkg/security" + "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" + "github.com/cockroachdb/cockroach/pkg/sql/sqlbase" + "github.com/cockroachdb/cockroach/pkg/util/log" + "github.com/cockroachdb/cockroach/pkg/util/syncutil" + "github.com/cockroachdb/cockroach/pkg/util/timeutil" + "github.com/cockroachdb/cockroach/pkg/util/tracing" + "github.com/gogo/protobuf/jsonpb" +) + +// StmtDiagnosticsRequester is the interface into stmtDiagnosticsRequestRegistry +// used by AdminUI endpoints. +type StmtDiagnosticsRequester interface { + // InsertRequest adds an entry to system.statement_diagnostics_requests for + // tracing a query with the given fingerprint. Once this returns, calling + // shouldCollectDiagnostics() on the current node will return true for the given + // fingerprint. + // + // It returns the ID of the new row. + InsertRequest(ctx context.Context, fprint string) (int, error) +} + +// stmtDiagnosticsRequestRegistry maintains a view on the statement fingerprints +// on which data is to be collected (i.e. system.statement_diagnostics_requests) +// and provides utilities for checking a query against this list and satisfying +// the requests. +type stmtDiagnosticsRequestRegistry struct { + mu struct { + // NOTE: This lock can't be held while the registry runs any statements + // internally; it'd deadlock. + syncutil.Mutex + // requests waiting for the right query to come along. + requests []stmtDiagRequest + // ids of requests that this node is in the process of servicing. + ongoing []int + + // epoch is observed before reading system.statement_diagnostics_requests, and then + // checked again before loading the tables contents. If the value changed in + // between, then the table contents might be stale. + epoch int + } + ie *InternalExecutor + db *client.DB + gossip *gossip.Gossip + nodeID roachpb.NodeID +} + +func newStmtDiagnosticsRequestRegistry( + ie *InternalExecutor, db *client.DB, g *gossip.Gossip, nodeID roachpb.NodeID, +) *stmtDiagnosticsRequestRegistry { + r := &stmtDiagnosticsRequestRegistry{ + ie: ie, + db: db, + gossip: g, + nodeID: nodeID, + } + // Some tests pass a nil gossip. + if g != nil { + g.RegisterCallback(gossip.KeyGossipStatementDiagnosticsRequest, r.gossipNotification) + } + return r +} + +type stmtDiagRequest struct { + id int + queryFingerprint string +} + +// addRequestInternalLocked adds a request to r.mu.requests. If the request is +// already present, the call is a noop. +func (r *stmtDiagnosticsRequestRegistry) addRequestInternalLocked( + ctx context.Context, req stmtDiagRequest, +) { + if r.findRequestLocked(req.id) { + // Request already exists. + return + } + r.mu.requests = append(r.mu.requests, req) +} + +func (r *stmtDiagnosticsRequestRegistry) findRequestLocked(requestID int) bool { + for _, er := range r.mu.requests { + if er.id == requestID { + return true + } + } + for _, id := range r.mu.ongoing { + if id == requestID { + return true + } + } + return false +} + +// InsertRequest is part of the StmtDiagnosticsRequester interface. +func (r *stmtDiagnosticsRequestRegistry) InsertRequest( + ctx context.Context, fprint string, +) (int, error) { + var requestID int + err := r.db.Txn(ctx, func(ctx context.Context, txn *client.Txn) error { + // Check if there's already a pending request for this fingerprint. + row, err := r.ie.QueryRowEx(ctx, "stmt-diag-check-pending", txn, + sqlbase.InternalExecutorSessionDataOverride{ + User: security.RootUser, + }, + "SELECT count(1) FROM system.statement_diagnostics_requests "+ + "WHERE completed = false AND statement_fingerprint = $1", + fprint) + if err != nil { + return err + } + count := int(*row[0].(*tree.DInt)) + if count != 0 { + return errors.New("a pending request for the requested fingerprint already exists") + } + + row, err = r.ie.QueryRowEx(ctx, "stmt-diag-insert-request", txn, + sqlbase.InternalExecutorSessionDataOverride{ + User: security.RootUser, + }, + "INSERT INTO system.statement_diagnostics_requests (statement_fingerprint, requested_at) "+ + "VALUES ($1, $2) RETURNING id", + fprint, timeutil.Now()) + if err != nil { + return err + } + requestID = int(*row[0].(*tree.DInt)) + return nil + }) + if err != nil { + return 0, err + } + + // Manually insert the request in the (local) registry. This lets this node + // pick up the request quickly if the right query comes around, without + // waiting for the poller. + r.mu.Lock() + defer r.mu.Unlock() + r.mu.epoch++ + req := stmtDiagRequest{ + id: requestID, + queryFingerprint: fprint, + } + r.addRequestInternalLocked(ctx, req) + + // Notify all the other nodes that they have to poll. + buf := make([]byte, 8) + binary.LittleEndian.PutUint64(buf, uint64(requestID)) + if err := r.gossip.AddInfo(gossip.KeyGossipStatementDiagnosticsRequest, buf, 0 /* ttl */); err != nil { + log.Warningf(ctx, "error notifying of diagnostics request: %s", err) + } + + return requestID, nil +} + +// removeExtraLocked removes all the requests not in ids. +func (r *stmtDiagnosticsRequestRegistry) removeExtraLocked(ids []int) { + valid := func(req stmtDiagRequest) bool { + for _, id := range ids { + if req.id == id { + return true + } + } + return false + } + + // Compact the valid requests in the beginning of r.mu.requests. + i := 0 // index of valid requests + for _, req := range r.mu.requests { + if valid(req) { + r.mu.requests[i] = req + i++ + } + } + r.mu.requests = r.mu.requests[:i] +} + +// shouldCollectDiagnostics checks whether any data should be collected for the +// given query. If data is to be collected, the returned function needs to be +// called once the data was collected. +// +// Once shouldCollectDiagnostics returns true, it will not return true again on +// this node for the same diagnostics request. +func (r *stmtDiagnosticsRequestRegistry) shouldCollectDiagnostics( + ctx context.Context, ast tree.Statement, +) (bool, func(ctx context.Context, trace tracing.Recording)) { + r.mu.Lock() + defer r.mu.Unlock() + + // Return quickly if we have no requests to trace. + if len(r.mu.requests) == 0 { + return false, nil + } + + fprint := tree.AsStringWithFlags(ast, tree.FmtHideConstants) + + var req stmtDiagRequest + idx := -1 + for i, er := range r.mu.requests { + if er.queryFingerprint == fprint { + req = er + idx = i + break + } + } + if idx == -1 { + return false, nil + } + + // Remove the request. + l := len(r.mu.requests) + r.mu.requests[idx] = r.mu.requests[l-1] + r.mu.requests = r.mu.requests[:l-1] + + r.mu.ongoing = append(r.mu.ongoing, req.id) + + return true, func(ctx context.Context, trace tracing.Recording) { + defer func() { + r.mu.Lock() + defer r.mu.Unlock() + // Remove the request from r.mu.ongoing. + for i, id := range r.mu.ongoing { + if id == req.id { + l := len(r.mu.ongoing) + r.mu.ongoing[i] = r.mu.ongoing[l-1] + r.mu.ongoing = r.mu.ongoing[:l-1] + } + } + }() + + if err := r.insertDiagnostics(ctx, req, tree.AsString(ast), trace); err != nil { + log.Warningf(ctx, "failed to insert trace: %s", err) + } + } +} + +// insertDiagnostics inserts a trace into system.statement_diagnostics and marks +// the corresponding request as completed in +// system.statement_diagnostics_requests. +func (r *stmtDiagnosticsRequestRegistry) insertDiagnostics( + ctx context.Context, req stmtDiagRequest, stmt string, trace tracing.Recording, +) error { + return r.db.Txn(ctx, func(ctx context.Context, txn *client.Txn) error { + { + row, err := r.ie.QueryRowEx(ctx, "stmt-diag-check-completed", txn, + sqlbase.InternalExecutorSessionDataOverride{User: security.RootUser}, + "SELECT count(1) FROM system.statement_diagnostics_requests WHERE id = $1 AND completed = false", + req.id) + if err != nil { + return err + } + cnt := int(*row[0].(*tree.DInt)) + if cnt == 0 { + // Someone else already marked the request as completed. We've traced for nothing. + // This can only happen once per node, per request since we're going to + // remove the request from the registry. + return nil + } + } + + var traceID int + if json, err := traceToJSON(trace); err != nil { + row, err := r.ie.QueryRowEx(ctx, "stmt-diag-insert-trace", txn, + sqlbase.InternalExecutorSessionDataOverride{User: security.RootUser}, + "INSERT INTO system.statement_diagnostics "+ + "(statement_fingerprint, statement, collected_at, error) "+ + "VALUES ($1, $2, $3, $4) RETURNING id", + req.queryFingerprint, stmt, timeutil.Now(), err.Error()) + if err != nil { + return err + } + traceID = int(*row[0].(*tree.DInt)) + } else { + // Insert the trace into system.statement_diagnostics. + row, err := r.ie.QueryRowEx(ctx, "stmt-diag-insert-trace", txn, + sqlbase.InternalExecutorSessionDataOverride{User: security.RootUser}, + "INSERT INTO system.statement_diagnostics "+ + "(statement_fingerprint, statement, collected_at, trace) "+ + "VALUES ($1, $2, $3, $4) RETURNING id", + req.queryFingerprint, stmt, timeutil.Now(), json) + if err != nil { + return err + } + traceID = int(*row[0].(*tree.DInt)) + } + + // Mark the request from system.statement_diagnostics_request as completed. + _, err := r.ie.ExecEx(ctx, "stmt-diag-mark-completed", txn, + sqlbase.InternalExecutorSessionDataOverride{User: security.RootUser}, + "UPDATE system.statement_diagnostics_requests "+ + "SET completed = true, statement_diagnostics_id = $1 WHERE id = $2", + traceID, req.id) + return err + }) +} + +// pollRequests reads the pending rows from system.statement_diagnostics_requests and +// updates r.mu.requests accordingly. +func (r *stmtDiagnosticsRequestRegistry) pollRequests(ctx context.Context) error { + var rows []tree.Datums + // Loop until we run the query without straddling an epoch increment. + for { + r.mu.Lock() + epoch := r.mu.epoch + r.mu.Unlock() + + var err error + rows, err = r.ie.QueryEx(ctx, "stmt-diag-poll", nil, /* txn */ + sqlbase.InternalExecutorSessionDataOverride{ + User: security.RootUser, + }, + "SELECT id, statement_fingerprint FROM system.statement_diagnostics_requests "+ + "WHERE completed = false") + if err != nil { + return err + } + + r.mu.Lock() + // If the epoch changed it means that a request was added to the registry + // manually while the query was running. In that case, if we were to process + // the query results normally, we might remove that manually-added request. + if r.mu.epoch != epoch { + r.mu.Unlock() + continue + } + break + } + defer r.mu.Unlock() + + ids := make([]int, 0, len(rows)) + for _, row := range rows { + id := int(*row[0].(*tree.DInt)) + ids = append(ids, id) + fprint := string(*row[1].(*tree.DString)) + + req := stmtDiagRequest{ + id: id, + queryFingerprint: fprint, + } + r.addRequestInternalLocked(ctx, req) + r.removeExtraLocked(ids) + } + return nil +} + +// gossipNotification is called in response to a gossip update informing us that +// we need to poll. +func (r *stmtDiagnosticsRequestRegistry) gossipNotification(s string, value roachpb.Value) { + if s != gossip.KeyGossipStatementDiagnosticsRequest { + // We don't expect any other notifications. Perhaps in a future version we + // added other keys with the same prefix. + return + } + requestID := int(binary.LittleEndian.Uint64(value.RawBytes)) + r.mu.Lock() + if r.findRequestLocked(requestID) { + r.mu.Unlock() + return + } + r.mu.Unlock() + if err := r.pollRequests(context.TODO()); err != nil { + log.Warningf(context.TODO(), "failed to poll for diagnostics requests: %s", err) + } +} + +func normalizeSpan(s tracing.RecordedSpan, trace tracing.Recording) tracing.NormalizedSpan { + var n tracing.NormalizedSpan + n.Operation = s.Operation + n.StartTime = s.StartTime + n.Duration = s.Duration + n.Tags = s.Tags + n.Logs = s.Logs + + for _, ss := range trace { + if ss.ParentSpanID != s.SpanID { + continue + } + n.Children = append(n.Children, normalizeSpan(ss, trace)) + } + return n +} + +// traceToJSON converts a trace to a JSON format suitable for the +// system.statement_diagnostics.trace column. +// +// traceToJSON assumes that the first span in the recording contains all the +// other spans. +func traceToJSON(trace tracing.Recording) (string, error) { + root := normalizeSpan(trace[0], trace) + marshaller := jsonpb.Marshaler{ + Indent: " ", + } + return marshaller.MarshalToString(&root) +} diff --git a/pkg/sql/statement_diagnostics_test.go b/pkg/sql/statement_diagnostics_test.go new file mode 100644 index 000000000000..8b1b3de52601 --- /dev/null +++ b/pkg/sql/statement_diagnostics_test.go @@ -0,0 +1,115 @@ +// Copyright 2020 The Cockroach Authors. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package sql + +import ( + "context" + gosql "database/sql" + "fmt" + "testing" + + "github.com/cockroachdb/cockroach/pkg/base" + "github.com/cockroachdb/cockroach/pkg/testutils" + "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" + "github.com/cockroachdb/cockroach/pkg/util/leaktest" + "github.com/stretchr/testify/require" +) + +func TestTraceRequest(t *testing.T) { + defer leaktest.AfterTest(t)() + s, db, _ := serverutils.StartServer(t, base.TestServerArgs{}) + ctx := context.Background() + defer s.Stopper().Stop(ctx) + _, err := db.Exec("CREATE TABLE test (x int PRIMARY KEY)") + require.NoError(t, err) + + // Ask to trace a particular query. + reqID, err := s.ExecutorConfig().(ExecutorConfig).stmtInfoRequestRegistry.InsertRequest( + ctx, "INSERT INTO test VALUES (_)") + require.NoError(t, err) + reqRow := db.QueryRow( + "SELECT completed, statement_diagnostics_id FROM system.statement_diagnostics_requests WHERE ID = $1", reqID) + var completed bool + var traceID gosql.NullInt64 + require.NoError(t, reqRow.Scan(&completed, &traceID)) + require.False(t, completed) + require.False(t, traceID.Valid) // traceID should be NULL + + // Run the query. + _, err = db.Exec("INSERT INTO test VALUES (1)") + require.NoError(t, err) + + // Check that the row from statement_diagnostics_request was marked as completed. + traceRow := db.QueryRow( + "SELECT completed, statement_diagnostics_id FROM system.statement_diagnostics_requests WHERE ID = $1", reqID) + require.NoError(t, traceRow.Scan(&completed, &traceID)) + require.True(t, completed) + require.True(t, traceID.Valid) + + // Check the trace. + row := db.QueryRow("SELECT jsonb_pretty(trace) FROM system.statement_diagnostics WHERE ID = $1", traceID.Int64) + var json string + require.NoError(t, row.Scan(&json)) + require.Contains(t, json, "traced statement") + require.Contains(t, json, "statement execution committed the txn") +} + +// Test that a different node can service a trace request. +func TestTraceRequestDifferentNode(t *testing.T) { + defer leaktest.AfterTest(t)() + tc := serverutils.StartTestCluster(t, 2, base.TestClusterArgs{}) + ctx := context.Background() + defer tc.Stopper().Stop(ctx) + db0 := tc.ServerConn(0) + db1 := tc.ServerConn(1) + _, err := db0.Exec("CREATE TABLE test (x int PRIMARY KEY)") + require.NoError(t, err) + + // Ask to trace a particular query using node 0. + reqID, err := tc.Server(0).ExecutorConfig().(ExecutorConfig).stmtInfoRequestRegistry.InsertRequest( + ctx, "INSERT INTO test VALUES (_)") + require.NoError(t, err) + reqRow := db0.QueryRow( + "SELECT completed, statement_diagnostics_id FROM system.statement_diagnostics_requests WHERE ID = $1", reqID) + var completed bool + var traceID gosql.NullInt64 + require.NoError(t, reqRow.Scan(&completed, &traceID)) + require.False(t, completed) + require.False(t, traceID.Valid) // traceID should be NULL + + // Repeatedly run the query through node 1 until we get a trace. + testutils.SucceedsSoon(t, func() error { + // Run the query using node 1. + _, err = db1.Exec("INSERT INTO test VALUES (1)") + require.NoError(t, err) + + // Check that the row from statement_diagnostics_request was marked as completed. + traceRow := db0.QueryRow( + "SELECT completed, statement_diagnostics_id FROM system.statement_diagnostics_requests WHERE ID = $1", + reqID) + require.NoError(t, traceRow.Scan(&completed, &traceID)) + if !completed { + _, err := db0.Exec("DELETE FROM test") + require.NoError(t, err) + return fmt.Errorf("not completed yet") + } + return nil + }) + require.True(t, traceID.Valid) + + // Check the trace. + row := db0.QueryRow("SELECT jsonb_pretty(trace) FROM system.statement_diagnostics WHERE ID = $1", + traceID.Int64) + var json string + require.NoError(t, row.Scan(&json)) + require.Contains(t, json, "traced statement") + require.Contains(t, json, "statement execution committed the txn") +} diff --git a/pkg/sql/tests/system_table_test.go b/pkg/sql/tests/system_table_test.go index 13b83cddeba2..f26636321fe9 100644 --- a/pkg/sql/tests/system_table_test.go +++ b/pkg/sql/tests/system_table_test.go @@ -25,6 +25,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/util/leaktest" "github.com/gogo/protobuf/proto" "github.com/kr/pretty" + "github.com/stretchr/testify/require" ) func TestInitialKeys(t *testing.T) { @@ -120,6 +121,9 @@ func TestSystemTableLiterals(t *testing.T) { {keys.ProtectedTimestampsMetaTableID, sqlbase.ProtectedTimestampsMetaTableSchema, sqlbase.ProtectedTimestampsMetaTable}, {keys.ProtectedTimestampsRecordsTableID, sqlbase.ProtectedTimestampsRecordsTableSchema, sqlbase.ProtectedTimestampsRecordsTable}, {keys.RoleOptionsTableID, sqlbase.RoleOptionsTableSchema, sqlbase.RoleOptionsTable}, + {keys.StatementBundleChunksTableID, sqlbase.StatementBundleChunksTableSchema, sqlbase.StatementBundleChunksTable}, + {keys.StatementDiagnosticsRequestsTableID, sqlbase.StatementDiagnosticsRequestsTableSchema, sqlbase.StatementDiagnosticsRequestsTable}, + {keys.StatementDiagnosticsTableID, sqlbase.StatementDiagnosticsTableSchema, sqlbase.StatementDiagnosticsTable}, } { privs := *test.pkg.Privileges gen, err := sql.CreateTestTableDescriptor( @@ -132,6 +136,7 @@ func TestSystemTableLiterals(t *testing.T) { if err != nil { t.Fatalf("test: %+v, err: %v", test, err) } + require.NoError(t, gen.ValidateTable()) if !proto.Equal(&test.pkg, &gen) { diff := strings.Join(pretty.Diff(&test.pkg, &gen), "\n") diff --git a/pkg/sqlmigrations/migrations.go b/pkg/sqlmigrations/migrations.go index 6972485e55a4..a4361707d1d6 100644 --- a/pkg/sqlmigrations/migrations.go +++ b/pkg/sqlmigrations/migrations.go @@ -164,31 +164,31 @@ var backwardCompatibleMigrations = []migrationDescriptor{ }, { // Introduced in v2.1, repeat of 2.0 migration to catch mixed-version issues. - // TODO(mberhault): bake into v2.2. + // TODO(mberhault): bake into v19.1. name: "repeat: ensure admin role privileges in all descriptors", }, { // Introduced in v2.1. - // TODO(mberhault): bake into v2.2. + // TODO(mberhault): bake into v19.1. name: "disallow public user or role name", workFn: disallowPublicUserOrRole, }, { // Introduced in v2.1. - // TODO(knz): bake this migration into v2.2. + // TODO(knz): bake this migration into v19.1. name: "create default databases", workFn: createDefaultDbs, newDescriptorIDs: databaseIDs(sessiondata.DefaultDatabaseName, sessiondata.PgDatabaseName), }, { // Introduced in v2.1. - // TODO(dt): Bake into v2.2. + // TODO(dt): Bake into v19.1. name: "add progress to system.jobs", workFn: addJobsProgress, }, { - // Introduced in v2.2. - // TODO(knz): bake this migration into v2.3. + // Introduced in v19.1. + // TODO(knz): bake this migration into v19.2 name: "create system.comment table", workFn: createCommentTable, // This migration has been introduced some time before 19.2. @@ -296,6 +296,16 @@ var backwardCompatibleMigrations = []migrationDescriptor{ includedInBootstrap: cluster.VersionByKey(cluster.VersionCreateRolePrivilege), newDescriptorIDs: staticIDs(keys.RoleOptionsTableID), }, + { + // Introduced in v20.1. + // TODO(andrei): Bake this migration into v20.2. + name: "create statement_diagnostics_requests, statement_diagnostics and " + + "system.statement_bundle_chunks tables", + workFn: createStatementInfoSystemTables, + includedInBootstrap: cluster.VersionByKey(cluster.VersionStatementDiagnosticsSystemTables), + newDescriptorIDs: staticIDs(keys.StatementBundleChunksTableID, + keys.StatementDiagnosticsRequestsTableID, keys.StatementDiagnosticsTableID), + }, } func staticIDs(ids ...sqlbase.ID) func(ctx context.Context, db db) ([]sqlbase.ID, error) { @@ -823,6 +833,19 @@ func createReportsMetaTable(ctx context.Context, r runner) error { return createSystemTable(ctx, r, sqlbase.ReportsMetaTable) } +func createStatementInfoSystemTables(ctx context.Context, r runner) error { + if err := createSystemTable(ctx, r, sqlbase.StatementBundleChunksTable); err != nil { + return errors.Wrap(err, "failed to create system.statement_bundle_chunks") + } + if err := createSystemTable(ctx, r, sqlbase.StatementDiagnosticsRequestsTable); err != nil { + return errors.Wrap(err, "failed to create system.statement_diagnostics_requests") + } + if err := createSystemTable(ctx, r, sqlbase.StatementDiagnosticsTable); err != nil { + return errors.Wrap(err, "failed to create system.statement_diagnostics") + } + return nil +} + // SettingsDefaultOverrides documents the effect of several migrations that add // an explicit value for a setting, effectively changing the "default value" // from what was defined in code. diff --git a/pkg/testutils/serverutils/test_server_shim.go b/pkg/testutils/serverutils/test_server_shim.go index dea9e346d176..87a7f307e8c4 100644 --- a/pkg/testutils/serverutils/test_server_shim.go +++ b/pkg/testutils/serverutils/test_server_shim.go @@ -92,6 +92,9 @@ type TestServerInterface interface { // The real return type is *kv.DistSender. DistSenderI() interface{} + // SQLServer returns the *sql.Server as an interface{}. + SQLServer() interface{} + // DistSQLServer returns the *distsql.ServerImpl as an interface{}. DistSQLServer() interface{} diff --git a/pkg/util/tracing/recorded_span.pb.go b/pkg/util/tracing/recorded_span.pb.go index 2814dc71bb95..02f44df07219 100644 --- a/pkg/util/tracing/recorded_span.pb.go +++ b/pkg/util/tracing/recorded_span.pb.go @@ -27,6 +27,77 @@ var _ = time.Kitchen // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package +// LogRecord is a log message recorded in a traced span. +type LogRecord struct { + // Time of the log record. + Time time.Time `protobuf:"bytes,1,opt,name=time,proto3,stdtime" json:"time"` + // Fields with values converted to strings. + Fields []LogRecord_Field `protobuf:"bytes,2,rep,name=fields,proto3" json:"fields"` +} + +func (m *LogRecord) Reset() { *m = LogRecord{} } +func (m *LogRecord) String() string { return proto.CompactTextString(m) } +func (*LogRecord) ProtoMessage() {} +func (*LogRecord) Descriptor() ([]byte, []int) { + return fileDescriptor_recorded_span_2278c97c583fd31c, []int{0} +} +func (m *LogRecord) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LogRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (dst *LogRecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_LogRecord.Merge(dst, src) +} +func (m *LogRecord) XXX_Size() int { + return m.Size() +} +func (m *LogRecord) XXX_DiscardUnknown() { + xxx_messageInfo_LogRecord.DiscardUnknown(m) +} + +var xxx_messageInfo_LogRecord proto.InternalMessageInfo + +type LogRecord_Field struct { + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (m *LogRecord_Field) Reset() { *m = LogRecord_Field{} } +func (m *LogRecord_Field) String() string { return proto.CompactTextString(m) } +func (*LogRecord_Field) ProtoMessage() {} +func (*LogRecord_Field) Descriptor() ([]byte, []int) { + return fileDescriptor_recorded_span_2278c97c583fd31c, []int{0, 0} +} +func (m *LogRecord_Field) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LogRecord_Field) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (dst *LogRecord_Field) XXX_Merge(src proto.Message) { + xxx_messageInfo_LogRecord_Field.Merge(dst, src) +} +func (m *LogRecord_Field) XXX_Size() int { + return m.Size() +} +func (m *LogRecord_Field) XXX_DiscardUnknown() { + xxx_messageInfo_LogRecord_Field.DiscardUnknown(m) +} + +var xxx_messageInfo_LogRecord_Field proto.InternalMessageInfo + // RecordedSpan is a span that is part of a recording. It can be transferred // over the wire for snowball tracing. type RecordedSpan struct { @@ -49,7 +120,7 @@ type RecordedSpan struct { // Duration in nanoseconds; 0 if the span is not finished. Duration time.Duration `protobuf:"bytes,8,opt,name=duration,proto3,stdduration" json:"duration"` // Events logged in the span. - Logs []RecordedSpan_LogRecord `protobuf:"bytes,9,rep,name=logs,proto3" json:"logs"` + Logs []LogRecord `protobuf:"bytes,9,rep,name=logs,proto3" json:"logs"` // Stats collected in this span. Stats *types.Any `protobuf:"bytes,10,opt,name=stats,proto3" json:"stats,omitempty"` } @@ -57,7 +128,7 @@ type RecordedSpan struct { func (m *RecordedSpan) Reset() { *m = RecordedSpan{} } func (*RecordedSpan) ProtoMessage() {} func (*RecordedSpan) Descriptor() ([]byte, []int) { - return fileDescriptor_recorded_span_5382bb969d0c274c, []int{0} + return fileDescriptor_recorded_span_2278c97c583fd31c, []int{1} } func (m *RecordedSpan) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -82,23 +153,30 @@ func (m *RecordedSpan) XXX_DiscardUnknown() { var xxx_messageInfo_RecordedSpan proto.InternalMessageInfo -type RecordedSpan_LogRecord struct { - // Time of the log record. - Time time.Time `protobuf:"bytes,1,opt,name=time,proto3,stdtime" json:"time"` - // Fields with values converted to strings. - Fields []RecordedSpan_LogRecord_Field `protobuf:"bytes,2,rep,name=fields,proto3" json:"fields"` +// NormalizedSpan is a representation of a RecordedSpan from a trace with all +// its children embedded, recursively. This JSON serialization of this proto is +// used in the system.statement_diagnostics.trace column. +// +// See RecordedSpan for the description of the fields. +type NormalizedSpan struct { + Operation string `protobuf:"bytes,1,opt,name=operation,proto3" json:"operation,omitempty"` + Tags map[string]string `protobuf:"bytes,2,rep,name=tags,proto3" json:"tags,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + StartTime time.Time `protobuf:"bytes,3,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time"` + Duration time.Duration `protobuf:"bytes,4,opt,name=duration,proto3,stdduration" json:"duration"` + Logs []LogRecord `protobuf:"bytes,5,rep,name=logs,proto3" json:"logs"` + Children []NormalizedSpan `protobuf:"bytes,6,rep,name=children,proto3" json:"children"` } -func (m *RecordedSpan_LogRecord) Reset() { *m = RecordedSpan_LogRecord{} } -func (m *RecordedSpan_LogRecord) String() string { return proto.CompactTextString(m) } -func (*RecordedSpan_LogRecord) ProtoMessage() {} -func (*RecordedSpan_LogRecord) Descriptor() ([]byte, []int) { - return fileDescriptor_recorded_span_5382bb969d0c274c, []int{0, 2} +func (m *NormalizedSpan) Reset() { *m = NormalizedSpan{} } +func (m *NormalizedSpan) String() string { return proto.CompactTextString(m) } +func (*NormalizedSpan) ProtoMessage() {} +func (*NormalizedSpan) Descriptor() ([]byte, []int) { + return fileDescriptor_recorded_span_2278c97c583fd31c, []int{2} } -func (m *RecordedSpan_LogRecord) XXX_Unmarshal(b []byte) error { +func (m *NormalizedSpan) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *RecordedSpan_LogRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *NormalizedSpan) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { b = b[:cap(b)] n, err := m.MarshalTo(b) if err != nil { @@ -106,59 +184,95 @@ func (m *RecordedSpan_LogRecord) XXX_Marshal(b []byte, deterministic bool) ([]by } return b[:n], nil } -func (dst *RecordedSpan_LogRecord) XXX_Merge(src proto.Message) { - xxx_messageInfo_RecordedSpan_LogRecord.Merge(dst, src) +func (dst *NormalizedSpan) XXX_Merge(src proto.Message) { + xxx_messageInfo_NormalizedSpan.Merge(dst, src) } -func (m *RecordedSpan_LogRecord) XXX_Size() int { +func (m *NormalizedSpan) XXX_Size() int { return m.Size() } -func (m *RecordedSpan_LogRecord) XXX_DiscardUnknown() { - xxx_messageInfo_RecordedSpan_LogRecord.DiscardUnknown(m) +func (m *NormalizedSpan) XXX_DiscardUnknown() { + xxx_messageInfo_NormalizedSpan.DiscardUnknown(m) } -var xxx_messageInfo_RecordedSpan_LogRecord proto.InternalMessageInfo - -type RecordedSpan_LogRecord_Field struct { - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` -} +var xxx_messageInfo_NormalizedSpan proto.InternalMessageInfo -func (m *RecordedSpan_LogRecord_Field) Reset() { *m = RecordedSpan_LogRecord_Field{} } -func (m *RecordedSpan_LogRecord_Field) String() string { return proto.CompactTextString(m) } -func (*RecordedSpan_LogRecord_Field) ProtoMessage() {} -func (*RecordedSpan_LogRecord_Field) Descriptor() ([]byte, []int) { - return fileDescriptor_recorded_span_5382bb969d0c274c, []int{0, 2, 0} -} -func (m *RecordedSpan_LogRecord_Field) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) +func init() { + proto.RegisterType((*LogRecord)(nil), "cockroach.util.tracing.LogRecord") + proto.RegisterType((*LogRecord_Field)(nil), "cockroach.util.tracing.LogRecord.Field") + proto.RegisterType((*RecordedSpan)(nil), "cockroach.util.tracing.RecordedSpan") + proto.RegisterMapType((map[string]string)(nil), "cockroach.util.tracing.RecordedSpan.BaggageEntry") + proto.RegisterMapType((map[string]string)(nil), "cockroach.util.tracing.RecordedSpan.TagsEntry") + proto.RegisterType((*NormalizedSpan)(nil), "cockroach.util.tracing.NormalizedSpan") + proto.RegisterMapType((map[string]string)(nil), "cockroach.util.tracing.NormalizedSpan.TagsEntry") } -func (m *RecordedSpan_LogRecord_Field) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalTo(b) +func (m *LogRecord) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) if err != nil { return nil, err } - return b[:n], nil -} -func (dst *RecordedSpan_LogRecord_Field) XXX_Merge(src proto.Message) { - xxx_messageInfo_RecordedSpan_LogRecord_Field.Merge(dst, src) -} -func (m *RecordedSpan_LogRecord_Field) XXX_Size() int { - return m.Size() + return dAtA[:n], nil } -func (m *RecordedSpan_LogRecord_Field) XXX_DiscardUnknown() { - xxx_messageInfo_RecordedSpan_LogRecord_Field.DiscardUnknown(m) + +func (m *LogRecord) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + dAtA[i] = 0xa + i++ + i = encodeVarintRecordedSpan(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.Time))) + n1, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Time, dAtA[i:]) + if err != nil { + return 0, err + } + i += n1 + if len(m.Fields) > 0 { + for _, msg := range m.Fields { + dAtA[i] = 0x12 + i++ + i = encodeVarintRecordedSpan(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + return i, nil } -var xxx_messageInfo_RecordedSpan_LogRecord_Field proto.InternalMessageInfo +func (m *LogRecord_Field) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} -func init() { - proto.RegisterType((*RecordedSpan)(nil), "cockroach.util.tracing.RecordedSpan") - proto.RegisterMapType((map[string]string)(nil), "cockroach.util.tracing.RecordedSpan.BaggageEntry") - proto.RegisterMapType((map[string]string)(nil), "cockroach.util.tracing.RecordedSpan.TagsEntry") - proto.RegisterType((*RecordedSpan_LogRecord)(nil), "cockroach.util.tracing.RecordedSpan.LogRecord") - proto.RegisterType((*RecordedSpan_LogRecord_Field)(nil), "cockroach.util.tracing.RecordedSpan.LogRecord.Field") +func (m *LogRecord_Field) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Key) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintRecordedSpan(dAtA, i, uint64(len(m.Key))) + i += copy(dAtA[i:], m.Key) + } + if len(m.Value) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintRecordedSpan(dAtA, i, uint64(len(m.Value))) + i += copy(dAtA[i:], m.Value) + } + return i, nil } + func (m *RecordedSpan) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -242,19 +356,19 @@ func (m *RecordedSpan) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x3a i++ i = encodeVarintRecordedSpan(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.StartTime))) - n1, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.StartTime, dAtA[i:]) + n2, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.StartTime, dAtA[i:]) if err != nil { return 0, err } - i += n1 + i += n2 dAtA[i] = 0x42 i++ i = encodeVarintRecordedSpan(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdDuration(m.Duration))) - n2, err := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.Duration, dAtA[i:]) + n3, err := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.Duration, dAtA[i:]) if err != nil { return 0, err } - i += n2 + i += n3 if len(m.Logs) > 0 { for _, msg := range m.Logs { dAtA[i] = 0x4a @@ -271,16 +385,16 @@ func (m *RecordedSpan) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x52 i++ i = encodeVarintRecordedSpan(dAtA, i, uint64(m.Stats.Size())) - n3, err := m.Stats.MarshalTo(dAtA[i:]) + n4, err := m.Stats.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n3 + i += n4 } return i, nil } -func (m *RecordedSpan_LogRecord) Marshal() (dAtA []byte, err error) { +func (m *NormalizedSpan) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalTo(dAtA) @@ -290,22 +404,58 @@ func (m *RecordedSpan_LogRecord) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *RecordedSpan_LogRecord) MarshalTo(dAtA []byte) (int, error) { +func (m *NormalizedSpan) MarshalTo(dAtA []byte) (int, error) { var i int _ = i var l int _ = l - dAtA[i] = 0xa + if len(m.Operation) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintRecordedSpan(dAtA, i, uint64(len(m.Operation))) + i += copy(dAtA[i:], m.Operation) + } + if len(m.Tags) > 0 { + keysForTags := make([]string, 0, len(m.Tags)) + for k := range m.Tags { + keysForTags = append(keysForTags, string(k)) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForTags) + for _, k := range keysForTags { + dAtA[i] = 0x12 + i++ + v := m.Tags[string(k)] + mapSize := 1 + len(k) + sovRecordedSpan(uint64(len(k))) + 1 + len(v) + sovRecordedSpan(uint64(len(v))) + i = encodeVarintRecordedSpan(dAtA, i, uint64(mapSize)) + dAtA[i] = 0xa + i++ + i = encodeVarintRecordedSpan(dAtA, i, uint64(len(k))) + i += copy(dAtA[i:], k) + dAtA[i] = 0x12 + i++ + i = encodeVarintRecordedSpan(dAtA, i, uint64(len(v))) + i += copy(dAtA[i:], v) + } + } + dAtA[i] = 0x1a i++ - i = encodeVarintRecordedSpan(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.Time))) - n4, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Time, dAtA[i:]) + i = encodeVarintRecordedSpan(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.StartTime))) + n5, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.StartTime, dAtA[i:]) if err != nil { return 0, err } - i += n4 - if len(m.Fields) > 0 { - for _, msg := range m.Fields { - dAtA[i] = 0x12 + i += n5 + dAtA[i] = 0x22 + i++ + i = encodeVarintRecordedSpan(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdDuration(m.Duration))) + n6, err := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.Duration, dAtA[i:]) + if err != nil { + return 0, err + } + i += n6 + if len(m.Logs) > 0 { + for _, msg := range m.Logs { + dAtA[i] = 0x2a i++ i = encodeVarintRecordedSpan(dAtA, i, uint64(msg.Size())) n, err := msg.MarshalTo(dAtA[i:]) @@ -315,35 +465,17 @@ func (m *RecordedSpan_LogRecord) MarshalTo(dAtA []byte) (int, error) { i += n } } - return i, nil -} - -func (m *RecordedSpan_LogRecord_Field) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *RecordedSpan_LogRecord_Field) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if len(m.Key) > 0 { - dAtA[i] = 0xa - i++ - i = encodeVarintRecordedSpan(dAtA, i, uint64(len(m.Key))) - i += copy(dAtA[i:], m.Key) - } - if len(m.Value) > 0 { - dAtA[i] = 0x12 - i++ - i = encodeVarintRecordedSpan(dAtA, i, uint64(len(m.Value))) - i += copy(dAtA[i:], m.Value) + if len(m.Children) > 0 { + for _, msg := range m.Children { + dAtA[i] = 0x32 + i++ + i = encodeVarintRecordedSpan(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } } return i, nil } @@ -357,6 +489,40 @@ func encodeVarintRecordedSpan(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return offset + 1 } +func (m *LogRecord) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.Time) + n += 1 + l + sovRecordedSpan(uint64(l)) + if len(m.Fields) > 0 { + for _, e := range m.Fields { + l = e.Size() + n += 1 + l + sovRecordedSpan(uint64(l)) + } + } + return n +} + +func (m *LogRecord_Field) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovRecordedSpan(uint64(l)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sovRecordedSpan(uint64(l)) + } + return n +} + func (m *RecordedSpan) Size() (n int) { if m == nil { return 0 @@ -409,16 +575,36 @@ func (m *RecordedSpan) Size() (n int) { return n } -func (m *RecordedSpan_LogRecord) Size() (n int) { +func (m *NormalizedSpan) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = github_com_gogo_protobuf_types.SizeOfStdTime(m.Time) + l = len(m.Operation) + if l > 0 { + n += 1 + l + sovRecordedSpan(uint64(l)) + } + if len(m.Tags) > 0 { + for k, v := range m.Tags { + _ = k + _ = v + mapEntrySize := 1 + len(k) + sovRecordedSpan(uint64(len(k))) + 1 + len(v) + sovRecordedSpan(uint64(len(v))) + n += mapEntrySize + 1 + sovRecordedSpan(uint64(mapEntrySize)) + } + } + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.StartTime) n += 1 + l + sovRecordedSpan(uint64(l)) - if len(m.Fields) > 0 { - for _, e := range m.Fields { + l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.Duration) + n += 1 + l + sovRecordedSpan(uint64(l)) + if len(m.Logs) > 0 { + for _, e := range m.Logs { + l = e.Size() + n += 1 + l + sovRecordedSpan(uint64(l)) + } + } + if len(m.Children) > 0 { + for _, e := range m.Children { l = e.Size() n += 1 + l + sovRecordedSpan(uint64(l)) } @@ -426,35 +612,237 @@ func (m *RecordedSpan_LogRecord) Size() (n int) { return n } -func (m *RecordedSpan_LogRecord_Field) Size() (n int) { - if m == nil { - return 0 +func sovRecordedSpan(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } } - var l int - _ = l - l = len(m.Key) - if l > 0 { - n += 1 + l + sovRecordedSpan(uint64(l)) + return n +} +func sozRecordedSpan(x uint64) (n int) { + return sovRecordedSpan(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *LogRecord) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecordedSpan + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: LogRecord: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LogRecord: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Time", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecordedSpan + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthRecordedSpan + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.Time, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fields", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecordedSpan + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthRecordedSpan + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Fields = append(m.Fields, LogRecord_Field{}) + if err := m.Fields[len(m.Fields)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipRecordedSpan(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthRecordedSpan + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } } - l = len(m.Value) - if l > 0 { - n += 1 + l + sovRecordedSpan(uint64(l)) + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *LogRecord_Field) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecordedSpan + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Field: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Field: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecordedSpan + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthRecordedSpan + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecordedSpan + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthRecordedSpan + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipRecordedSpan(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthRecordedSpan + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } } - return n -} -func sovRecordedSpan(x uint64) (n int) { - for { - n++ - x >>= 7 - if x == 0 { - break - } + if iNdEx > l { + return io.ErrUnexpectedEOF } - return n -} -func sozRecordedSpan(x uint64) (n int) { - return sovRecordedSpan(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + return nil } func (m *RecordedSpan) Unmarshal(dAtA []byte) error { l := len(dAtA) @@ -893,7 +1281,7 @@ func (m *RecordedSpan) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Logs = append(m.Logs, RecordedSpan_LogRecord{}) + m.Logs = append(m.Logs, LogRecord{}) if err := m.Logs[len(m.Logs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -952,7 +1340,7 @@ func (m *RecordedSpan) Unmarshal(dAtA []byte) error { } return nil } -func (m *RecordedSpan_LogRecord) Unmarshal(dAtA []byte) error { +func (m *NormalizedSpan) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -975,15 +1363,44 @@ func (m *RecordedSpan_LogRecord) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: LogRecord: wiretype end group for non-group") + return fmt.Errorf("proto: NormalizedSpan: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: LogRecord: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: NormalizedSpan: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Time", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Operation", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecordedSpan + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthRecordedSpan + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Operation = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Tags", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1007,13 +1424,101 @@ func (m *RecordedSpan_LogRecord) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.Time, dAtA[iNdEx:postIndex]); err != nil { - return err + if m.Tags == nil { + m.Tags = make(map[string]string) + } + var mapkey string + var mapvalue string + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecordedSpan + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecordedSpan + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthRecordedSpan + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var stringLenmapvalue uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecordedSpan + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapvalue |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapvalue := int(stringLenmapvalue) + if intStringLenmapvalue < 0 { + return ErrInvalidLengthRecordedSpan + } + postStringIndexmapvalue := iNdEx + intStringLenmapvalue + if postStringIndexmapvalue > l { + return io.ErrUnexpectedEOF + } + mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue]) + iNdEx = postStringIndexmapvalue + } else { + iNdEx = entryPreIndex + skippy, err := skipRecordedSpan(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthRecordedSpan + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } } + m.Tags[mapkey] = mapvalue iNdEx = postIndex - case 2: + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Fields", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1037,66 +1542,45 @@ func (m *RecordedSpan_LogRecord) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Fields = append(m.Fields, RecordedSpan_LogRecord_Field{}) - if err := m.Fields[len(m.Fields)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.StartTime, dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipRecordedSpan(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthRecordedSpan + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecordedSpan + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *RecordedSpan_LogRecord_Field) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRecordedSpan + if msglen < 0 { + return ErrInvalidLengthRecordedSpan } - if iNdEx >= l { + postIndex := iNdEx + msglen + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break + if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.Duration, dAtA[iNdEx:postIndex]); err != nil { + return err } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Field: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Field: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + iNdEx = postIndex + case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Logs", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowRecordedSpan @@ -1106,26 +1590,28 @@ func (m *RecordedSpan_LogRecord_Field) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + msglen |= (int(b) & 0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthRecordedSpan } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex > l { return io.ErrUnexpectedEOF } - m.Key = string(dAtA[iNdEx:postIndex]) + m.Logs = append(m.Logs, LogRecord{}) + if err := m.Logs[len(m.Logs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex - case 2: + case 6: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Children", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowRecordedSpan @@ -1135,20 +1621,22 @@ func (m *RecordedSpan_LogRecord_Field) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + msglen |= (int(b) & 0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthRecordedSpan } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex > l { return io.ErrUnexpectedEOF } - m.Value = string(dAtA[iNdEx:postIndex]) + m.Children = append(m.Children, NormalizedSpan{}) + if err := m.Children[len(m.Children)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex @@ -1277,44 +1765,48 @@ var ( ) func init() { - proto.RegisterFile("util/tracing/recorded_span.proto", fileDescriptor_recorded_span_5382bb969d0c274c) + proto.RegisterFile("util/tracing/recorded_span.proto", fileDescriptor_recorded_span_2278c97c583fd31c) } -var fileDescriptor_recorded_span_5382bb969d0c274c = []byte{ - // 548 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x52, 0x3d, 0x6f, 0xd3, 0x40, - 0x18, 0xf6, 0x25, 0x4e, 0x1c, 0xbf, 0x89, 0x50, 0x75, 0x8a, 0x90, 0x6b, 0x21, 0x3b, 0x02, 0x09, - 0x05, 0x06, 0x5b, 0x14, 0x04, 0x55, 0x17, 0x84, 0x09, 0x88, 0x08, 0x06, 0x64, 0x32, 0xb1, 0x44, - 0x97, 0xf8, 0x7a, 0x58, 0x4d, 0x7d, 0x96, 0x7d, 0x41, 0xca, 0x1f, 0x60, 0xee, 0xd8, 0x91, 0x9f, - 0x13, 0x31, 0x75, 0xec, 0x14, 0xc0, 0xf9, 0x23, 0xe8, 0xce, 0x4e, 0x5a, 0xb5, 0x0c, 0xcd, 0x76, - 0xef, 0x3d, 0x1f, 0x7a, 0xde, 0xe7, 0x0e, 0x7a, 0x73, 0x11, 0xcf, 0x7c, 0x91, 0x91, 0x69, 0x9c, - 0x30, 0x3f, 0xa3, 0x53, 0x9e, 0x45, 0x34, 0x1a, 0xe7, 0x29, 0x49, 0xbc, 0x34, 0xe3, 0x82, 0xe3, - 0xfb, 0x53, 0x3e, 0x3d, 0xc9, 0x38, 0x99, 0x7e, 0xf3, 0x24, 0xd7, 0xab, 0xb8, 0x76, 0x97, 0x71, - 0xc6, 0x15, 0xc5, 0x97, 0xa7, 0x92, 0x6d, 0xef, 0x33, 0xce, 0xd9, 0x8c, 0xfa, 0x6a, 0x9a, 0xcc, - 0x8f, 0x7d, 0x92, 0x2c, 0x2a, 0xc8, 0xbd, 0x09, 0x89, 0xf8, 0x94, 0xe6, 0x82, 0x9c, 0xa6, 0x15, - 0xc1, 0xb9, 0x49, 0x88, 0xe6, 0x19, 0x11, 0x31, 0xaf, 0x92, 0x3c, 0xfc, 0x61, 0x40, 0x27, 0xac, - 0x12, 0x7e, 0x49, 0x49, 0x82, 0x1f, 0x43, 0x4b, 0xa6, 0xa1, 0xe3, 0x38, 0xb2, 0x50, 0x0f, 0xf5, - 0xf5, 0xa0, 0x5d, 0xac, 0x5c, 0x63, 0x24, 0xef, 0x86, 0x83, 0xd0, 0x50, 0xe0, 0x30, 0xc2, 0x8f, - 0xc0, 0x90, 0x0b, 0x49, 0x5a, 0x4d, 0xd1, 0xa0, 0x58, 0xb9, 0x4d, 0x69, 0x31, 0x1c, 0x84, 0x4d, - 0x09, 0x0d, 0x23, 0xfc, 0x12, 0xee, 0xa5, 0x24, 0xa3, 0x89, 0x18, 0x6f, 0xb8, 0x75, 0xc5, 0xdd, - 0x2b, 0x56, 0x6e, 0xe7, 0xb3, 0x42, 0x2a, 0x45, 0x27, 0xbd, 0x9a, 0x22, 0xfc, 0x00, 0x4c, 0x9e, - 0xd2, 0x32, 0xa8, 0xa5, 0xf7, 0x50, 0xdf, 0x0c, 0xaf, 0x2e, 0xf0, 0x47, 0x30, 0x26, 0x84, 0x31, - 0xc2, 0xa8, 0xd5, 0xe8, 0xd5, 0xfb, 0xed, 0x83, 0x67, 0xde, 0xff, 0xfb, 0xf4, 0xae, 0x6f, 0xe6, - 0x05, 0xa5, 0xe6, 0x5d, 0x22, 0xb2, 0x45, 0xb8, 0x71, 0xc0, 0x01, 0xe8, 0x82, 0xb0, 0xdc, 0x6a, - 0x2a, 0x27, 0xef, 0x4e, 0x4e, 0x23, 0xc2, 0xf2, 0xd2, 0x46, 0x69, 0xf1, 0x5b, 0x80, 0x5c, 0x90, - 0x4c, 0x8c, 0x65, 0xfb, 0x96, 0xd1, 0x43, 0xfd, 0xf6, 0x81, 0xed, 0x95, 0xcd, 0x7b, 0x9b, 0xe6, - 0xbd, 0xd1, 0xe6, 0x69, 0x82, 0xd6, 0x72, 0xe5, 0x6a, 0x67, 0xbf, 0x5d, 0x14, 0x9a, 0x4a, 0x27, - 0x11, 0xfc, 0x1a, 0x5a, 0x9b, 0xb7, 0xb1, 0x5a, 0xca, 0x62, 0xff, 0x96, 0xc5, 0xa0, 0x22, 0x94, - 0x0e, 0xe7, 0xd2, 0x61, 0x2b, 0xc2, 0x1f, 0x40, 0x9f, 0x71, 0x96, 0x5b, 0xe6, 0x0e, 0x9b, 0x7c, - 0xe2, 0xac, 0x9c, 0x03, 0x5d, 0x3a, 0x86, 0xca, 0x01, 0x3f, 0x85, 0x46, 0x2e, 0x88, 0xc8, 0x2d, - 0x50, 0x39, 0xba, 0xb7, 0x72, 0xbc, 0x49, 0x16, 0x61, 0x49, 0xb1, 0x8f, 0xa0, 0x73, 0xbd, 0x58, - 0xbc, 0x07, 0xf5, 0x13, 0xba, 0x50, 0x5f, 0xc7, 0x0c, 0xe5, 0x11, 0x77, 0xa1, 0xf1, 0x9d, 0xcc, - 0xe6, 0x54, 0xfd, 0x13, 0x33, 0x2c, 0x87, 0xa3, 0xda, 0x21, 0xb2, 0x5f, 0x81, 0xb9, 0xad, 0x72, - 0x27, 0xe1, 0x2f, 0x04, 0xe6, 0x36, 0x3a, 0x3e, 0x04, 0x5d, 0x15, 0x8f, 0x76, 0x28, 0x5e, 0x29, - 0x70, 0x08, 0xcd, 0xe3, 0x98, 0xce, 0xa2, 0xdc, 0xaa, 0xa9, 0xd2, 0x5e, 0xec, 0x56, 0x9a, 0xf7, - 0x5e, 0x8a, 0xab, 0xea, 0x2a, 0x27, 0xdb, 0x87, 0x86, 0xba, 0xbe, 0xf3, 0x42, 0xfa, 0xf9, 0x4f, - 0x57, 0x0b, 0x9e, 0x2c, 0xff, 0x3a, 0xda, 0xb2, 0x70, 0xd0, 0x45, 0xe1, 0xa0, 0xcb, 0xc2, 0x41, - 0x7f, 0x0a, 0x07, 0x9d, 0xad, 0x1d, 0xed, 0x62, 0xed, 0x68, 0x97, 0x6b, 0x47, 0xfb, 0x6a, 0x54, - 0x61, 0x26, 0x4d, 0xb5, 0xd9, 0xf3, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xa3, 0xfc, 0x7b, 0xef, - 0x68, 0x04, 0x00, 0x00, +var fileDescriptor_recorded_span_2278c97c583fd31c = []byte{ + // 623 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x53, 0xcd, 0x6e, 0xd3, 0x4c, + 0x14, 0x8d, 0x13, 0xe7, 0xef, 0x36, 0xaa, 0xaa, 0x51, 0xf5, 0xc9, 0xb5, 0x3e, 0xd9, 0xa5, 0x48, + 0xa5, 0xb0, 0xb0, 0xa1, 0x48, 0x50, 0x95, 0x05, 0xc2, 0xa4, 0x88, 0x08, 0x84, 0x90, 0xe9, 0x8a, + 0x4d, 0x34, 0xb5, 0xa7, 0x53, 0xab, 0xae, 0xc7, 0xb2, 0x27, 0x48, 0xe1, 0x29, 0xba, 0xec, 0x92, + 0x07, 0xe0, 0x09, 0x90, 0xd8, 0x77, 0xd9, 0x65, 0x57, 0x01, 0xdc, 0x17, 0x41, 0x33, 0x9e, 0xa4, + 0x7f, 0x54, 0x4d, 0xdb, 0x9d, 0x67, 0xee, 0x39, 0xe7, 0xde, 0x39, 0xe7, 0x1a, 0x16, 0x07, 0x3c, + 0x8a, 0x5d, 0x9e, 0xe1, 0x20, 0x4a, 0xa8, 0x9b, 0x91, 0x80, 0x65, 0x21, 0x09, 0xfb, 0x79, 0x8a, + 0x13, 0x27, 0xcd, 0x18, 0x67, 0xe8, 0xbf, 0x80, 0x05, 0xbb, 0x19, 0xc3, 0xc1, 0x8e, 0x23, 0xb0, + 0x8e, 0xc2, 0x9a, 0xf3, 0x94, 0x51, 0x26, 0x21, 0xae, 0xf8, 0x2a, 0xd1, 0xe6, 0x02, 0x65, 0x8c, + 0xc6, 0xc4, 0x95, 0xa7, 0xad, 0xc1, 0xb6, 0x8b, 0x93, 0xa1, 0x2a, 0xd9, 0x17, 0x4b, 0x3c, 0xda, + 0x23, 0x39, 0xc7, 0x7b, 0xa9, 0x02, 0x58, 0x17, 0x01, 0xe1, 0x20, 0xc3, 0x3c, 0x62, 0x6a, 0x92, + 0xa5, 0x9f, 0x1a, 0xb4, 0xdf, 0x33, 0xea, 0xcb, 0x21, 0xd1, 0x1a, 0xe8, 0x42, 0xc0, 0xd0, 0x16, + 0xb5, 0x95, 0x99, 0x55, 0xd3, 0x29, 0xc9, 0xce, 0x98, 0xec, 0x6c, 0x8e, 0xd5, 0xbd, 0xd6, 0xe1, + 0xc8, 0xae, 0xec, 0xff, 0xb2, 0x35, 0x5f, 0x32, 0xd0, 0x06, 0x34, 0xb6, 0x23, 0x12, 0x87, 0xb9, + 0x51, 0x5d, 0xac, 0xad, 0xcc, 0xac, 0x3e, 0x70, 0xfe, 0xfd, 0x44, 0x67, 0xd2, 0xcc, 0x79, 0x23, + 0xf0, 0x9e, 0x2e, 0x84, 0x7c, 0x45, 0x36, 0x5d, 0xa8, 0xcb, 0x6b, 0x34, 0x07, 0xb5, 0x5d, 0x32, + 0x94, 0x83, 0xb4, 0x7d, 0xf1, 0x89, 0xe6, 0xa1, 0xfe, 0x05, 0xc7, 0x03, 0x62, 0x54, 0xe5, 0x5d, + 0x79, 0x58, 0xfa, 0x5e, 0x87, 0x8e, 0xaf, 0x1c, 0xfe, 0x94, 0xe2, 0x04, 0x2d, 0x43, 0x4b, 0xb4, + 0x22, 0xfd, 0x28, 0x94, 0x6c, 0xdd, 0x9b, 0x29, 0x46, 0x76, 0x73, 0x53, 0xdc, 0xf5, 0xba, 0x7e, + 0x53, 0x16, 0x7b, 0x21, 0xba, 0x0f, 0x4d, 0x11, 0x88, 0x80, 0x55, 0x25, 0x0c, 0x8a, 0x91, 0xdd, + 0x10, 0x12, 0xbd, 0xae, 0xdf, 0x10, 0xa5, 0x5e, 0x88, 0x9e, 0xc1, 0x6c, 0x8a, 0x33, 0x92, 0xf0, + 0xfe, 0x18, 0x5b, 0x93, 0xd8, 0xb9, 0x62, 0x64, 0x77, 0x3e, 0xca, 0x8a, 0x62, 0x74, 0xd2, 0xd3, + 0x53, 0x88, 0xfe, 0x87, 0x36, 0x4b, 0x49, 0x69, 0xb4, 0xa1, 0xcb, 0x79, 0x4f, 0x2f, 0xd0, 0x3b, + 0x68, 0x6e, 0x61, 0x4a, 0x31, 0x25, 0x46, 0x5d, 0x9a, 0xf5, 0xe4, 0x2a, 0xb3, 0xce, 0xbe, 0xcc, + 0xf1, 0x4a, 0xce, 0x46, 0xc2, 0xb3, 0xa1, 0x3f, 0x56, 0x40, 0x1e, 0xe8, 0x1c, 0xd3, 0xdc, 0x68, + 0x48, 0x25, 0x67, 0x2a, 0xa5, 0x4d, 0x4c, 0xf3, 0x52, 0x46, 0x72, 0xd1, 0x6b, 0x80, 0x9c, 0xe3, + 0x8c, 0xf7, 0x65, 0xf8, 0xcd, 0x1b, 0x84, 0xdf, 0x96, 0x3c, 0x51, 0x41, 0x2f, 0xa1, 0x35, 0xde, + 0x2d, 0xa3, 0x25, 0x25, 0x16, 0x2e, 0x49, 0x74, 0x15, 0xa0, 0x54, 0x38, 0x10, 0x0a, 0x13, 0x12, + 0x7a, 0x01, 0x7a, 0xcc, 0x68, 0x6e, 0xb4, 0xe5, 0x4b, 0xee, 0x5d, 0xbb, 0x40, 0x6a, 0x75, 0x24, + 0x09, 0x3d, 0x82, 0x7a, 0xce, 0x31, 0xcf, 0x0d, 0x90, 0xad, 0xe7, 0x2f, 0xb5, 0x7e, 0x95, 0x0c, + 0xfd, 0x12, 0x62, 0xae, 0x43, 0xe7, 0xac, 0x97, 0xd3, 0xee, 0xda, 0x7a, 0x75, 0x4d, 0x33, 0x9f, + 0x43, 0x7b, 0xe2, 0xde, 0x4d, 0x88, 0xeb, 0xfa, 0xc1, 0x37, 0xbb, 0xb2, 0xf4, 0xa3, 0x06, 0xb3, + 0x1f, 0x58, 0xb6, 0x87, 0xe3, 0xe8, 0xab, 0x5a, 0xd8, 0x73, 0xbb, 0xa2, 0x5d, 0xdc, 0x95, 0xae, + 0x8a, 0xb7, 0xfc, 0xab, 0x1e, 0x5f, 0x65, 0xca, 0x79, 0xcd, 0x6b, 0x02, 0xae, 0xdd, 0x3d, 0x60, + 0xfd, 0x2e, 0x01, 0xd7, 0x6f, 0x13, 0xf0, 0x5b, 0x68, 0x05, 0x3b, 0x51, 0x1c, 0x66, 0x24, 0x51, + 0xbb, 0xbe, 0x3c, 0x9d, 0x19, 0x4a, 0x65, 0xc2, 0xbe, 0x75, 0x84, 0xde, 0xc3, 0xc3, 0x3f, 0x56, + 0xe5, 0xb0, 0xb0, 0xb4, 0xa3, 0xc2, 0xd2, 0x8e, 0x0b, 0x4b, 0xfb, 0x5d, 0x58, 0xda, 0xfe, 0x89, + 0x55, 0x39, 0x3a, 0xb1, 0x2a, 0xc7, 0x27, 0x56, 0xe5, 0x73, 0x53, 0x8d, 0xb0, 0xd5, 0x90, 0x8e, + 0x3c, 0xfd, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x83, 0x1a, 0x5c, 0x3e, 0x0b, 0x06, 0x00, 0x00, } diff --git a/pkg/util/tracing/recorded_span.proto b/pkg/util/tracing/recorded_span.proto index e83d0fe219b1..46632370d332 100644 --- a/pkg/util/tracing/recorded_span.proto +++ b/pkg/util/tracing/recorded_span.proto @@ -17,6 +17,19 @@ import "google/protobuf/any.proto"; import "google/protobuf/timestamp.proto"; import "google/protobuf/duration.proto"; +// LogRecord is a log message recorded in a traced span. +message LogRecord { + // Time of the log record. + google.protobuf.Timestamp time = 1 [(gogoproto.nullable) = false, + (gogoproto.stdtime) = true]; + message Field { + string key = 1; + string value = 2; + } + // Fields with values converted to strings. + repeated Field fields = 2 [(gogoproto.nullable) = false]; +} + // RecordedSpan is a span that is part of a recording. It can be transferred // over the wire for snowball tracing. message RecordedSpan { @@ -43,20 +56,25 @@ message RecordedSpan { google.protobuf.Duration duration = 8 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true]; - message LogRecord { - // Time of the log record. - google.protobuf.Timestamp time = 1 [(gogoproto.nullable) = false, - (gogoproto.stdtime) = true]; - message Field { - string key = 1; - string value = 2; - } - // Fields with values converted to strings. - repeated Field fields = 2 [(gogoproto.nullable) = false]; - } // Events logged in the span. repeated LogRecord logs = 9 [(gogoproto.nullable) = false]; // Stats collected in this span. google.protobuf.Any stats = 10; } + +// NormalizedSpan is a representation of a RecordedSpan from a trace with all +// its children embedded, recursively. This JSON serialization of this proto is +// used in the system.statement_diagnostics.trace column. +// +// See RecordedSpan for the description of the fields. +message NormalizedSpan { + string operation = 1; + map tags = 2; + google.protobuf.Timestamp start_time = 3 [(gogoproto.nullable) = false, + (gogoproto.stdtime) = true]; + google.protobuf.Duration duration = 4 [(gogoproto.nullable) = false, + (gogoproto.stdduration) = true]; + repeated LogRecord logs = 5 [(gogoproto.nullable) = false]; + repeated NormalizedSpan children = 6 [(gogoproto.nullable) = false]; +} diff --git a/pkg/util/tracing/tracer_span.go b/pkg/util/tracing/tracer_span.go index 22cd80ab6a95..3fe554244fe2 100644 --- a/pkg/util/tracing/tracer_span.go +++ b/pkg/util/tracing/tracer_span.go @@ -633,12 +633,12 @@ func (s *span) getRecording() RecordedSpan { rs.Tags[k] = fmt.Sprint(v) } } - rs.Logs = make([]RecordedSpan_LogRecord, len(s.mu.recordedLogs)) + rs.Logs = make([]LogRecord, len(s.mu.recordedLogs)) for i, r := range s.mu.recordedLogs { rs.Logs[i].Time = r.Timestamp - rs.Logs[i].Fields = make([]RecordedSpan_LogRecord_Field, len(r.Fields)) + rs.Logs[i].Fields = make([]LogRecord_Field, len(r.Fields)) for j, f := range r.Fields { - rs.Logs[i].Fields[j] = RecordedSpan_LogRecord_Field{ + rs.Logs[i].Fields[j] = LogRecord_Field{ Key: f.Key(), Value: fmt.Sprint(f.Value()), }