Skip to content

Commit 22879b3

Browse files
committed
Merged from upstream
1 parent 2bd211e commit 22879b3

File tree

23 files changed

+287
-58
lines changed

23 files changed

+287
-58
lines changed

.gitmodules

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +0,0 @@
1-
[submodule "third_party/prometheus-cpp"]
2-
path = third_party/prometheus-cpp
3-
url = https://github.com/jupp0r/prometheus-cpp
4-
branch = master
5-
6-
[submodule "tools/vcpkg"]
7-
path = tools/vcpkg
8-
url = https://github.com/Microsoft/vcpkg
9-
branch = master
10-
11-
[submodule "third_party/ms-gsl"]
12-
path = third_party/ms-gsl
13-
url = https://github.com/microsoft/GSL
14-
branch = main
15-
16-
[submodule "third_party/googletest"]
17-
path = third_party/googletest
18-
url = https://github.com/google/googletest
19-
branch = main
20-
21-
[submodule "third_party/benchmark"]
22-
path = third_party/benchmark
23-
url = https://github.com/google/benchmark
24-
branch = main
25-
26-
[submodule "third_party/opentelemetry-proto"]
27-
path = third_party/opentelemetry-proto
28-
url = https://github.com/open-telemetry/opentelemetry-proto
29-
branch = main
30-
31-
[submodule "third_party/nlohmann-json"]
32-
path = third_party/nlohmann-json
33-
url = https://github.com/nlohmann/json
34-
branch = master
35-
36-
[submodule "third_party/opentracing-cpp"]
37-
path = third_party/opentracing-cpp
38-
url = https://github.com/opentracing/opentracing-cpp.git
39-
branch = master

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"

MODULE.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ single_version_override(
2323

2424
bazel_dep(name = "nlohmann_json", version = "3.11.3.bcr.1")
2525
bazel_dep(name = "platforms", version = "0.0.10")
26-
bazel_dep(name = "rules_cc", version = "0.0.13")
26+
bazel_dep(name = "rules_cc", version = "0.0.13") # Issues with 0.0.14 and grpc/protobuf
2727
bazel_dep(name = "rules_pkg", version = "1.0.1")
28-
bazel_dep(name = "rules_proto", version = "6.0.2")
28+
bazel_dep(name = "rules_proto", version = "6.0.2") # Issues with 7.0.0 and grpc/protobuf
2929
bazel_dep(name = "zlib", version = "1.3.1.bcr.3")
3030
bazel_dep(name = "opentracing-cpp", version = "1.6.0")
3131
bazel_dep(name = "rules_multitool", version = "0.13.0")

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
@@ -990,6 +990,7 @@ OtlpHttpClient::createSession(
990990
request->SetBody(body_vec);
991991
request->ReplaceHeader("Content-Type", content_type);
992992
request->ReplaceHeader("User-Agent", options_.user_agent);
993+
request->EnableLogging(options_.console_debug);
993994

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

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 OPENTELEMETRY_EXPORT_TYPE 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 OPENTELEMETRY_EXPORT_TYPE 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 OPENTELEMETRY_EXPORT_TYPE 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/BUILD

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ otel_cc_library(
1212
"http_client_factory_curl.cc",
1313
"http_operation_curl.cc",
1414
],
15-
copts = [
16-
"-DWITH_CURL",
15+
local_defines = [
16+
"WITH_CURL",
17+
"ENABLE_CURL_LOGGING",
1718
],
1819
include_prefix = "src/http/client/curl",
1920
linkopts = select({

0 commit comments

Comments
 (0)