From 2c98a9d762d0100727178b1f8609a83a9583bb15 Mon Sep 17 00:00:00 2001 From: cloud-profiler-team Date: Thu, 1 Aug 2024 06:30:18 +0000 Subject: [PATCH 1/8] Managing the function that is deprecated in the latest gRPC version. PiperOrigin-RevId: 658282005 --- src/throttler_api.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/throttler_api.cc b/src/throttler_api.cc index 0e024558..d81acf69 100644 --- a/src/throttler_api.cc +++ b/src/throttler_api.cc @@ -76,6 +76,7 @@ const char kServiceVersionLabel[] = "version"; // Range of random number const int64_t kRandomRange = 65536; +#ifdef STANDALONE_BUILD // Routes GRPC logging through cloud profiler logger. // Otherwise GRPC would log to stderr. void GRPCLog(gpr_log_func_args* args) { @@ -93,6 +94,7 @@ void GRPCLog(gpr_log_func_args* args) { << args->message; } } +#endif // STANDALONE_BUILD // Overrides the default SSL roots. Otherwise gRPC calls would fail if a SSL // roots file can't be found neither at a location specified by @@ -285,7 +287,9 @@ APIThrottler::APIThrottler( // GRPCLog is equivalent to what gRPC is doing internally, it would be safe to // delete this line and the entire GRPCLog function when you upgrade gRPC to // version 1.65 or later. +#ifdef STANDALONE_BUILD gpr_set_log_function(GRPCLog); +#endif // STANDALONE_BUILD // Create a random number generator. gen_ = std::default_random_engine(clock_->Now().tv_nsec / 1000); From 6dfadb298ae9f829b481a7095bca6abdba294fad Mon Sep 17 00:00:00 2001 From: cloud-profiler-team Date: Tue, 13 Aug 2024 23:21:30 +0000 Subject: [PATCH 2/8] Automated Code Change PiperOrigin-RevId: 662691572 --- src/throttler_api.cc | 6 ++++++ src/throttler_api.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/throttler_api.cc b/src/throttler_api.cc index d81acf69..80f70ce9 100644 --- a/src/throttler_api.cc +++ b/src/throttler_api.cc @@ -16,12 +16,17 @@ #include #include +#include #include #include #include +#include #include #include // NOLINT +#include +#include +#include #include #include #include @@ -36,6 +41,7 @@ #include "src/globals.h" #include "src/pem_roots.h" #include "src/string.h" +#include "src/throttler.h" #include "google/devtools/cloudprofiler/v2/profiler.grpc.pb.h" #include "google/protobuf/duration.pb.h" // NOLINT #include "google/rpc/error_details.pb.h" // NOLINT diff --git a/src/throttler_api.h b/src/throttler_api.h index 9083beb3..dcf24bef 100644 --- a/src/throttler_api.h +++ b/src/throttler_api.h @@ -17,9 +17,13 @@ #ifndef CLOUD_PROFILER_AGENT_JAVA_THROTTLER_API_H_ #define CLOUD_PROFILER_AGENT_JAVA_THROTTLER_API_H_ +#include +#include #include #include +#include +#include #include #include // NOLINT #include From 659a69e4fbe8f9a090cf689da4d4bd870ab50227 Mon Sep 17 00:00:00 2001 From: cloud-profiler-team Date: Wed, 28 Aug 2024 19:42:21 +0000 Subject: [PATCH 3/8] Add doc URL to profile format and use it display help link. PiperOrigin-RevId: 668565523 --- third_party/perftools/profiles/proto/profile.proto | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/third_party/perftools/profiles/proto/profile.proto b/third_party/perftools/profiles/proto/profile.proto index c154c83e..640d9d1f 100644 --- a/third_party/perftools/profiles/proto/profile.proto +++ b/third_party/perftools/profiles/proto/profile.proto @@ -93,6 +93,11 @@ message Profile { // Index into the string table of the type of the preferred sample // value. If unset, clients should default to the last sample value. int64 default_sample_type = 14; + // disable-diff-check:begin -- disabled until proto change is in google3 + // Documentation link for this profile. May be missing if the profile was + // generated by older code or code that did not bother to supply a link. + int64 doc_url = 15; // Index into string table. + // disable-diff-check:end } // ValueType describes the semantics and measurement units of a value. From 6f7ba6dbb61482c248d75bd840e55e89b89314b6 Mon Sep 17 00:00:00 2001 From: cloud-profiler-team Date: Fri, 30 Aug 2024 16:27:11 +0000 Subject: [PATCH 4/8] Pick up changes from pprof's copy of profile.proto PiperOrigin-RevId: 669350670 --- third_party/perftools/profiles/proto/profile.proto | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/third_party/perftools/profiles/proto/profile.proto b/third_party/perftools/profiles/proto/profile.proto index 640d9d1f..81050c26 100644 --- a/third_party/perftools/profiles/proto/profile.proto +++ b/third_party/perftools/profiles/proto/profile.proto @@ -93,11 +93,12 @@ message Profile { // Index into the string table of the type of the preferred sample // value. If unset, clients should default to the last sample value. int64 default_sample_type = 14; - // disable-diff-check:begin -- disabled until proto change is in google3 - // Documentation link for this profile. May be missing if the profile was - // generated by older code or code that did not bother to supply a link. + // Documentation link for this profile. The URL must be absolute, + // e.g., http://pprof.example.com/cpu-profile.html + // + // The URL may be missing if the profile was generated by older code or code + // that did not bother to supply a link. int64 doc_url = 15; // Index into string table. - // disable-diff-check:end } // ValueType describes the semantics and measurement units of a value. From 967f93dafa3e7419601bf42b84f3e8bac8e891c3 Mon Sep 17 00:00:00 2001 From: cloud-profiler-team Date: Tue, 10 Sep 2024 20:00:33 +0000 Subject: [PATCH 5/8] Add documentaion URL links to several generated profile types. PiperOrigin-RevId: 673073337 --- .../perftools/profiles/proto/builder.cc | 23 +++++++++++++++++++ .../perftools/profiles/proto/builder.h | 10 ++++++++ 2 files changed, 33 insertions(+) diff --git a/third_party/perftools/profiles/proto/builder.cc b/third_party/perftools/profiles/proto/builder.cc index 5572f8e6..a2ae1c96 100644 --- a/third_party/perftools/profiles/proto/builder.cc +++ b/third_party/perftools/profiles/proto/builder.cc @@ -25,6 +25,9 @@ #include #include +#include "third_party/absl/status/status.h" +#include "third_party/absl/strings/str_cat.h" + #include #include @@ -71,7 +74,10 @@ int64_t Builder::StringId(const char *str) { if (str == nullptr || !str[0]) { return 0; } + return InternalStringId(str); +} +int64_t Builder::InternalStringId(absl::string_view str) { const int64_t index = profile_->string_table_size(); const auto inserted = strings_.emplace(str, index); if (!inserted.second) { @@ -108,6 +114,18 @@ uint64_t Builder::FunctionId(const char *name, const char *system_name, return index; } +void Builder::SetDocURL(absl::string_view url) { + if (!url.empty() && !url.starts_with("http://") && + !url.starts_with("https://")) { + if (error_.ok()) { + error_ = absl::InternalError( + absl::StrCat("setting invalid profile doc URL '", url, "'")); + } + return; + } + profile_->set_doc_url(InternalStringId(url)); +} + bool Builder::Emit(std::string *output) { *output = ""; if (!profile_ || !Finalize()) { @@ -265,6 +283,11 @@ bool Builder::CheckValid(const Profile &profile) { // - Creates missing locations for unsymbolized profiles. // - Associates locations to the corresponding mappings. bool Builder::Finalize() { + if (!error_.ok()) { + // We really should be returning an absl::Status instead of logging here. + LOG(ERROR) << error_; + return false; + } if (profile_->location_size() == 0) { IndexMap address_to_id; address_to_id.reserve(profile_->sample_size()); diff --git a/third_party/perftools/profiles/proto/builder.h b/third_party/perftools/profiles/proto/builder.h index 719617b1..b6d961b4 100644 --- a/third_party/perftools/profiles/proto/builder.h +++ b/third_party/perftools/profiles/proto/builder.h @@ -24,6 +24,8 @@ #include #include +#include "third_party/absl/status/status.h" + #include namespace perftools { @@ -87,6 +89,9 @@ class Builder { // Adds mappings for the currently running binary to the profile. void AddCurrentMappings(); + // Add documentation URL. + void SetDocURL(absl::string_view url); + // Prepares the profile for encoding. Returns true on success. // If the profile has no locations, inserts location using the // location_ids from the samples as addresses. @@ -128,12 +133,17 @@ class Builder { Profile *mutable_profile() { return profile_.get(); } private: + int64_t InternalStringId(absl::string_view str); + // Maps to deduplicate strings and functions. StringIndexMap strings_; FunctionIndexMap functions_; // Actual profile being updated. std::unique_ptr profile_; + + // Any error that may have been encountered while building the profile. + absl::Status error_; }; } // namespace profiles From 8cf0ff6bdaa62d2e7aa429407ec7459145952f91 Mon Sep 17 00:00:00 2001 From: cloud-profiler-team Date: Tue, 10 Sep 2024 21:18:56 +0000 Subject: [PATCH 6/8] Replace starts_with with absl::StartsWith PiperOrigin-RevId: 673102808 --- third_party/perftools/profiles/proto/builder.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/third_party/perftools/profiles/proto/builder.cc b/third_party/perftools/profiles/proto/builder.cc index a2ae1c96..c81ec832 100644 --- a/third_party/perftools/profiles/proto/builder.cc +++ b/third_party/perftools/profiles/proto/builder.cc @@ -26,6 +26,7 @@ #include #include "third_party/absl/status/status.h" +#include "third_party/absl/strings/match.h" #include "third_party/absl/strings/str_cat.h" #include @@ -115,8 +116,8 @@ uint64_t Builder::FunctionId(const char *name, const char *system_name, } void Builder::SetDocURL(absl::string_view url) { - if (!url.empty() && !url.starts_with("http://") && - !url.starts_with("https://")) { + if (!url.empty() && !absl::StartsWith(url, "http://") && + !absl::StartsWith(url, "https://")) { if (error_.ok()) { error_ = absl::InternalError( absl::StrCat("setting invalid profile doc URL '", url, "'")); From 8c201137153edecb8d2ebd3f8e9c7fa756be082f Mon Sep 17 00:00:00 2001 From: cloud-profiler-team Date: Sun, 29 Sep 2024 18:48:45 +0000 Subject: [PATCH 7/8] Remove dependence on absl PiperOrigin-RevId: 680288149 --- .../perftools/profiles/proto/builder.cc | 24 +++++++++---------- .../perftools/profiles/proto/builder.h | 8 +++---- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/third_party/perftools/profiles/proto/builder.cc b/third_party/perftools/profiles/proto/builder.cc index c81ec832..a9c5084f 100644 --- a/third_party/perftools/profiles/proto/builder.cc +++ b/third_party/perftools/profiles/proto/builder.cc @@ -25,10 +25,6 @@ #include #include -#include "third_party/absl/status/status.h" -#include "third_party/absl/strings/match.h" -#include "third_party/absl/strings/str_cat.h" - #include #include @@ -78,7 +74,7 @@ int64_t Builder::StringId(const char *str) { return InternalStringId(str); } -int64_t Builder::InternalStringId(absl::string_view str) { +int64_t Builder::InternalStringId(const std::string &str) { const int64_t index = profile_->string_table_size(); const auto inserted = strings_.emplace(str, index); if (!inserted.second) { @@ -115,12 +111,16 @@ uint64_t Builder::FunctionId(const char *name, const char *system_name, return index; } -void Builder::SetDocURL(absl::string_view url) { - if (!url.empty() && !absl::StartsWith(url, "http://") && - !absl::StartsWith(url, "https://")) { - if (error_.ok()) { - error_ = absl::InternalError( - absl::StrCat("setting invalid profile doc URL '", url, "'")); +void Builder::SetDocURL(const std::string &url) { + const std::string kHttp = "http://"; + const std::string kHttps = "https://"; + + if (!url.empty() && url.compare(0, kHttp.size(), kHttp) != 0 && + url.compare(0, kHttps.size(), kHttps) != 0) { + if (error_.empty()) { + error_ = "setting invalid profile doc URL '"; + error_.append(url); + error_.append("'"); } return; } @@ -284,7 +284,7 @@ bool Builder::CheckValid(const Profile &profile) { // - Creates missing locations for unsymbolized profiles. // - Associates locations to the corresponding mappings. bool Builder::Finalize() { - if (!error_.ok()) { + if (!error_.empty()) { // We really should be returning an absl::Status instead of logging here. LOG(ERROR) << error_; return false; diff --git a/third_party/perftools/profiles/proto/builder.h b/third_party/perftools/profiles/proto/builder.h index b6d961b4..73fae393 100644 --- a/third_party/perftools/profiles/proto/builder.h +++ b/third_party/perftools/profiles/proto/builder.h @@ -24,8 +24,6 @@ #include #include -#include "third_party/absl/status/status.h" - #include namespace perftools { @@ -90,7 +88,7 @@ class Builder { void AddCurrentMappings(); // Add documentation URL. - void SetDocURL(absl::string_view url); + void SetDocURL(const std::string &url); // Prepares the profile for encoding. Returns true on success. // If the profile has no locations, inserts location using the @@ -133,7 +131,7 @@ class Builder { Profile *mutable_profile() { return profile_.get(); } private: - int64_t InternalStringId(absl::string_view str); + int64_t InternalStringId(const std::string &str); // Maps to deduplicate strings and functions. StringIndexMap strings_; @@ -143,7 +141,7 @@ class Builder { std::unique_ptr profile_; // Any error that may have been encountered while building the profile. - absl::Status error_; + std::string error_; }; } // namespace profiles From e667bd2cf568320208bda53201ec3b63d2884b3b Mon Sep 17 00:00:00 2001 From: sharmapranav Date: Fri, 25 Oct 2024 20:52:26 +0000 Subject: [PATCH 8/8] chore: Update cURL dependency to 8.10.1 PiperOrigin-RevId: 689900913 --- Dockerfile | 4 ++-- Dockerfile.alpine | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 13a22f18..8b09023c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -68,12 +68,12 @@ RUN mkdir /tmp/openssl && cd /tmp/openssl && \ cd ~ && rm -rf /tmp/openssl # curl -RUN git clone --depth=1 -b curl-7_69_1 https://github.com/curl/curl.git /tmp/curl && \ +RUN git clone --depth=1 -b curl-8_10_1 https://github.com/curl/curl.git /tmp/curl && \ cd /tmp/curl && \ ./buildconf && \ ./configure --disable-ldap --disable-shared --without-libssh2 \ --without-librtmp --without-libidn --enable-static \ - --without-libidn2 \ + --without-libidn2 --without-libpsl \ --with-pic --with-ssl=/usr/local/ssl/ && \ make -j && make install && \ cd ~ && rm -rf /tmp/curl diff --git a/Dockerfile.alpine b/Dockerfile.alpine index fd9aa528..90fcd9df 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -53,12 +53,12 @@ RUN mkdir /tmp/openssl && cd /tmp/openssl && \ cd ~ && rm -rf /tmp/openssl # curl -RUN git clone --depth=1 -b curl-7_69_1 https://github.com/curl/curl.git /tmp/curl && \ +RUN git clone --depth=1 -b curl-8_10_1 https://github.com/curl/curl.git /tmp/curl && \ cd /tmp/curl && \ ./buildconf && \ ./configure --disable-ldap --disable-shared --without-libssh2 \ --without-librtmp --without-libidn --enable-static \ - --without-libidn2 \ + --without-libidn2 --without-libpsl \ --with-pic --with-ssl=/usr/local/ssl/ && \ make -j && make install && \ cd ~ && rm -rf /tmp/curl