Skip to content

Commit 3b6d64a

Browse files
authored
Merge branch 'main' into arm-yield
2 parents 05bc155 + 84d4270 commit 3b6d64a

File tree

14 files changed

+286
-11
lines changed

14 files changed

+286
-11
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ Important changes:
3232
as the Jaeger propagator can be used without the (now removed)
3333
Jaeger exporter.
3434

35+
* Upgrade to prometheus 1.3.0
36+
[#3122](https://github.com/open-telemetry/opentelemetry-cpp/pull/3122)
37+
3538
## [1.17 2024-10-07]
3639

3740
* [CI] Add a clang-tidy build

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ option(
215215
"Whether to include gzip compression for the OTLP http exporter in the SDK"
216216
OFF)
217217

218+
option(WITH_CURL_LOGGING "Whether to enable select CURL verbosity in OTel logs"
219+
OFF)
220+
218221
option(WITH_ZIPKIN "Whether to include the Zipkin exporter in the SDK" OFF)
219222

220223
option(WITH_PROMETHEUS "Whether to include the Prometheus Client in the SDK"

bazel/repository.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ def opentelemetry_cpp_deps():
110110
maybe(
111111
http_archive,
112112
name = "com_github_jupp0r_prometheus_cpp",
113-
sha256 = "48dbad454d314b836cc667ec4def93ec4a6e4255fc8387c20cacb3b8b6faee30",
114-
strip_prefix = "prometheus-cpp-1.2.4",
113+
sha256 = "ac6e958405a29fbbea9db70b00fa3c420e16ad32e1baf941ab233ba031dd72ee",
114+
strip_prefix = "prometheus-cpp-1.3.0",
115115
urls = [
116-
"https://github.com/jupp0r/prometheus-cpp/archive/refs/tags/v1.2.4.tar.gz",
116+
"https://github.com/jupp0r/prometheus-cpp/archive/refs/tags/v1.3.0.tar.gz",
117117
],
118118
)
119119

docs/maintaining-dependencies.md

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,3 +442,160 @@ Last, in some special case like name collisions for a given symbol,
442442
the template itself may need to be adjusted for special logic.
443443

444444
See for example how `messaging.client_id` is treated.
445+
446+
## prometheus-cpp
447+
448+
### Comments (prometheus-cpp)
449+
450+
The `prometheus-cpp` library provides a C++ client for Prometheus,
451+
facilitating the creation and registration of metrics that Prometheus scrapes.
452+
`prometheus-cpp` is used as a git submodule under the `third_party` directory
453+
for ease of inclusion in build system.
454+
455+
### Origin (prometheus-cpp)
456+
457+
The repository for `prometheus-cpp` can be found here:
458+
459+
* [repository](https://github.com/jupp0r/prometheus-cpp)
460+
461+
Check release notes at:
462+
463+
* [release-notes](https://github.com/jupp0r/prometheus-cpp/releases)
464+
465+
### Upgrade (prometheus-cpp)
466+
467+
When upgrading `prometheus-cpp` to a newer release,
468+
you’ll need to update a few key files in the codebase to reflect the new version.
469+
470+
In this example, we upgrade from `v1.2.3` to `v1.2.4`.
471+
472+
#### Directory `third_party/prometheus-cpp`
473+
474+
`prometheus-cpp` is a `git submodule`,
475+
so it needs to be pointed to the new release tag.
476+
477+
```shell
478+
cd third_party/prometheus-cpp
479+
git log -1
480+
```
481+
482+
The current submodule should show something like:
483+
484+
```shell
485+
commit abcdef1234567890abcdef1234567890abcdef12 (HEAD, tag: v1.2.3)
486+
Author: John Doe <[email protected]>
487+
Date: Fri Apr 25 17:55:35 2024 +0200
488+
489+
Minor fixes for performance and compatibility
490+
```
491+
492+
Pull new tags:
493+
494+
```shell
495+
git pull --tag origin
496+
```
497+
498+
Upgrade to the new tag:
499+
500+
```shell
501+
git pull origin v1.2.4
502+
```
503+
504+
Verify the new commit:
505+
506+
```shell
507+
git log -1
508+
commit 1234567890abcdef1234567890abcdef12345678 (HEAD, tag: v1.2.4)
509+
Author: Jane Doe <[email protected]>
510+
Date: Thu Jun 28 08:19:11 2024 -0500
511+
512+
Improved metrics handling for high concurrency
513+
```
514+
515+
Return to the root directory:
516+
517+
```shell
518+
cd ../..
519+
git status
520+
```
521+
522+
The status should display:
523+
524+
```shell
525+
On branch upgrade_prometheus_1.2.4
526+
Changes not staged for commit:
527+
(use "git add <file>..." to update what will be committed)
528+
(use "git restore <file>..." to discard changes in working directory)
529+
modified: third_party/prometheus-cpp (new commits)
530+
```
531+
532+
Add the upgraded submodule:
533+
534+
```shell
535+
git add third_party/prometheus-cpp
536+
```
537+
538+
File third_party_release
539+
Update the line referencing the prometheus-cpp version.
540+
541+
```shell
542+
prometheus-cpp=v1.2.4
543+
```
544+
545+
Example change:
546+
547+
```shell
548+
$ git diff third_party_release
549+
diff --git a/third_party_release b/third_party_release
550+
index abc1234..def5678 100644
551+
--- a/third_party_release
552+
+++ b/third_party_release
553+
@@ -19,7 +19,7 @@ some-dependency=v0.8.3
554+
another-dependency=1.14.0
555+
prometheus-cpp=v1.2.3
556+
+prometheus-cpp=v1.2.4
557+
```
558+
559+
In file bazel/repository.bzl locate the entry for prometheus-cpp:
560+
561+
```shell
562+
# C++ Prometheus Client library.
563+
maybe(
564+
http_archive,
565+
name = "com_github_jupp0r_prometheus_cpp",
566+
sha256 = "ac6e958405a29fbbea9db70b00fa3c420e16ad32e1baf941ab233ba031dd72ee",
567+
strip_prefix = "prometheus-cpp-1.2.3",
568+
urls = [
569+
"https://github.com/jupp0r/prometheus-cpp/archive/refs/tags/v1.2.3.tar.gz",
570+
],
571+
)
572+
```
573+
574+
Update the URL to the new tag:
575+
576+
```shell
577+
urls = [
578+
"https://github.com/jupp0r/prometheus-cpp/archive/v1.2.4.tar.gz",
579+
],
580+
```
581+
582+
Update strip_prefix to match the new version:
583+
584+
```shell
585+
strip_prefix = "prometheus-cpp-1.2.4",
586+
```
587+
588+
Download the new URL:
589+
590+
```shell
591+
wget https://github.com/jupp0r/prometheus-cpp/archive/v1.2.4.tar.gz
592+
```
593+
594+
Calculate the checksum:
595+
596+
```shell
597+
sha256sum v1.2.4.tar.gz
598+
abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234 v1.2.4.tar.gz
599+
```
600+
601+
Update the `sha256`.

exporters/otlp/src/otlp_http_client.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,7 @@ OtlpHttpClient::createSession(
989989
request->SetBody(body_vec);
990990
request->ReplaceHeader("Content-Type", content_type);
991991
request->ReplaceHeader("User-Agent", options_.user_agent);
992+
request->EnableLogging(options_.console_debug);
992993

993994
if (options_.compression == "gzip")
994995
{

ext/include/opentelemetry/ext/http/client/curl/http_client_curl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ class Request : public opentelemetry::ext::http::client::Request
102102
compression_ = compression;
103103
}
104104

105+
void EnableLogging(bool is_log_enabled) noexcept override { is_log_enabled_ = is_log_enabled; }
106+
105107
public:
106108
opentelemetry::ext::http::client::Method method_;
107109
opentelemetry::ext::http::client::HttpSslOptions ssl_options_;
@@ -111,6 +113,7 @@ class Request : public opentelemetry::ext::http::client::Request
111113
std::chrono::milliseconds timeout_ms_{5000}; // ms
112114
opentelemetry::ext::http::client::Compression compression_{
113115
opentelemetry::ext::http::client::Compression::kNone};
116+
bool is_log_enabled_{false};
114117
};
115118

116119
class Response : public opentelemetry::ext::http::client::Response

ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ class HttpOperation
102102

103103
static size_t ReadMemoryCallback(char *buffer, size_t size, size_t nitems, void *userp);
104104

105+
static int CurlLoggerCallback(const CURL * /* handle */,
106+
curl_infotype type,
107+
const char *data,
108+
size_t size,
109+
void * /* clientp */) noexcept;
110+
105111
#if LIBCURL_VERSION_NUM >= 0x075000
106112
static int PreRequestCallback(void *clientp,
107113
char *conn_primary_ip,
@@ -152,7 +158,8 @@ class HttpOperation
152158
// Default connectivity and response size options
153159
bool is_raw_response = false,
154160
std::chrono::milliseconds http_conn_timeout = default_http_conn_timeout,
155-
bool reuse_connection = false);
161+
bool reuse_connection = false,
162+
bool is_log_enabled = false);
156163

157164
/**
158165
* Destroy CURL instance
@@ -300,6 +307,8 @@ class HttpOperation
300307

301308
const opentelemetry::ext::http::client::Compression &compression_;
302309

310+
const bool is_log_enabled_;
311+
303312
// Processed response headers and body
304313
long response_code_;
305314
std::vector<uint8_t> response_headers_;

ext/include/opentelemetry/ext/http/client/http_client.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ class Request
245245

246246
virtual void SetCompression(const Compression &compression) noexcept = 0;
247247

248+
virtual void EnableLogging(bool is_log_enabled) noexcept = 0;
249+
248250
virtual ~Request() = default;
249251
};
250252

ext/src/http/client/curl/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ else()
2424
PRIVATE ${CURL_LIBRARIES})
2525
endif()
2626

27+
if(WITH_CURL_LOGGING)
28+
target_compile_definitions(opentelemetry_http_client_curl
29+
PRIVATE ENABLE_CURL_LOGGING)
30+
endif()
31+
2732
if(WITH_OTLP_HTTP_COMPRESSION)
2833
if(TARGET ZLIB::ZLIB)
2934
target_link_libraries(

ext/src/http/client/curl/http_client_curl.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ void Session::SendRequest(
116116
#endif
117117
}
118118

119-
curl_operation_.reset(new HttpOperation(http_request_->method_, url, http_request_->ssl_options_,
120-
callback_ptr, http_request_->headers_,
121-
http_request_->body_, http_request_->compression_, false,
122-
http_request_->timeout_ms_, reuse_connection));
119+
curl_operation_.reset(new HttpOperation(
120+
http_request_->method_, url, http_request_->ssl_options_, callback_ptr,
121+
http_request_->headers_, http_request_->body_, http_request_->compression_, false,
122+
http_request_->timeout_ms_, reuse_connection, http_request_->is_log_enabled_));
123123
bool success =
124124
CURLE_OK == curl_operation_->SendAsync(this, [this, callback](HttpOperation &operation) {
125125
if (operation.WasAborted())

0 commit comments

Comments
 (0)