Skip to content

Commit

Permalink
Merge branch 'open-telemetry:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
tjcw authored Nov 7, 2024
2 parents e477abb + 84d4270 commit 01e5bcf
Show file tree
Hide file tree
Showing 14 changed files with 286 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ Important changes:
as the Jaeger propagator can be used without the (now removed)
Jaeger exporter.

* Upgrade to prometheus 1.3.0
[#3122](https://github.com/open-telemetry/opentelemetry-cpp/pull/3122)

## [1.17 2024-10-07]

* [CI] Add a clang-tidy build
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ option(
"Whether to include gzip compression for the OTLP http exporter in the SDK"
OFF)

option(WITH_CURL_LOGGING "Whether to enable select CURL verbosity in OTel logs"
OFF)

option(WITH_ZIPKIN "Whether to include the Zipkin exporter in the SDK" OFF)

option(WITH_PROMETHEUS "Whether to include the Prometheus Client in the SDK"
Expand Down
6 changes: 3 additions & 3 deletions bazel/repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ def opentelemetry_cpp_deps():
maybe(
http_archive,
name = "com_github_jupp0r_prometheus_cpp",
sha256 = "48dbad454d314b836cc667ec4def93ec4a6e4255fc8387c20cacb3b8b6faee30",
strip_prefix = "prometheus-cpp-1.2.4",
sha256 = "ac6e958405a29fbbea9db70b00fa3c420e16ad32e1baf941ab233ba031dd72ee",
strip_prefix = "prometheus-cpp-1.3.0",
urls = [
"https://github.com/jupp0r/prometheus-cpp/archive/refs/tags/v1.2.4.tar.gz",
"https://github.com/jupp0r/prometheus-cpp/archive/refs/tags/v1.3.0.tar.gz",
],
)

Expand Down
157 changes: 157 additions & 0 deletions docs/maintaining-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -442,3 +442,160 @@ Last, in some special case like name collisions for a given symbol,
the template itself may need to be adjusted for special logic.

See for example how `messaging.client_id` is treated.

## prometheus-cpp

### Comments (prometheus-cpp)

The `prometheus-cpp` library provides a C++ client for Prometheus,
facilitating the creation and registration of metrics that Prometheus scrapes.
`prometheus-cpp` is used as a git submodule under the `third_party` directory
for ease of inclusion in build system.

### Origin (prometheus-cpp)

The repository for `prometheus-cpp` can be found here:

* [repository](https://github.com/jupp0r/prometheus-cpp)

Check release notes at:

* [release-notes](https://github.com/jupp0r/prometheus-cpp/releases)

### Upgrade (prometheus-cpp)

When upgrading `prometheus-cpp` to a newer release,
you’ll need to update a few key files in the codebase to reflect the new version.

In this example, we upgrade from `v1.2.3` to `v1.2.4`.

#### Directory `third_party/prometheus-cpp`

`prometheus-cpp` is a `git submodule`,
so it needs to be pointed to the new release tag.

```shell
cd third_party/prometheus-cpp
git log -1
```

The current submodule should show something like:

```shell
commit abcdef1234567890abcdef1234567890abcdef12 (HEAD, tag: v1.2.3)
Author: John Doe <johndoe@example.com>
Date: Fri Apr 25 17:55:35 2024 +0200

Minor fixes for performance and compatibility
```

Pull new tags:

```shell
git pull --tag origin
```

Upgrade to the new tag:

```shell
git pull origin v1.2.4
```

Verify the new commit:

```shell
git log -1
commit 1234567890abcdef1234567890abcdef12345678 (HEAD, tag: v1.2.4)
Author: Jane Doe <janedoe@example.com>
Date: Thu Jun 28 08:19:11 2024 -0500

Improved metrics handling for high concurrency
```

Return to the root directory:

```shell
cd ../..
git status
```

The status should display:

```shell
On branch upgrade_prometheus_1.2.4
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: third_party/prometheus-cpp (new commits)
```

Add the upgraded submodule:

```shell
git add third_party/prometheus-cpp
```

File third_party_release
Update the line referencing the prometheus-cpp version.

```shell
prometheus-cpp=v1.2.4
```

Example change:

```shell
$ git diff third_party_release
diff --git a/third_party_release b/third_party_release
index abc1234..def5678 100644
--- a/third_party_release
+++ b/third_party_release
@@ -19,7 +19,7 @@ some-dependency=v0.8.3
another-dependency=1.14.0
prometheus-cpp=v1.2.3
+prometheus-cpp=v1.2.4
```

In file bazel/repository.bzl locate the entry for prometheus-cpp:

```shell
# C++ Prometheus Client library.
maybe(
http_archive,
name = "com_github_jupp0r_prometheus_cpp",
sha256 = "ac6e958405a29fbbea9db70b00fa3c420e16ad32e1baf941ab233ba031dd72ee",
strip_prefix = "prometheus-cpp-1.2.3",
urls = [
"https://github.com/jupp0r/prometheus-cpp/archive/refs/tags/v1.2.3.tar.gz",
],
)
```

Update the URL to the new tag:

```shell
urls = [
"https://github.com/jupp0r/prometheus-cpp/archive/v1.2.4.tar.gz",
],
```

Update strip_prefix to match the new version:

```shell
strip_prefix = "prometheus-cpp-1.2.4",
```

Download the new URL:

```shell
wget https://github.com/jupp0r/prometheus-cpp/archive/v1.2.4.tar.gz
```

Calculate the checksum:

```shell
sha256sum v1.2.4.tar.gz
abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234 v1.2.4.tar.gz
```

Update the `sha256`.
1 change: 1 addition & 0 deletions exporters/otlp/src/otlp_http_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,7 @@ OtlpHttpClient::createSession(
request->SetBody(body_vec);
request->ReplaceHeader("Content-Type", content_type);
request->ReplaceHeader("User-Agent", options_.user_agent);
request->EnableLogging(options_.console_debug);

if (options_.compression == "gzip")
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ class Request : public opentelemetry::ext::http::client::Request
compression_ = compression;
}

void EnableLogging(bool is_log_enabled) noexcept override { is_log_enabled_ = is_log_enabled; }

public:
opentelemetry::ext::http::client::Method method_;
opentelemetry::ext::http::client::HttpSslOptions ssl_options_;
Expand All @@ -111,6 +113,7 @@ class Request : public opentelemetry::ext::http::client::Request
std::chrono::milliseconds timeout_ms_{5000}; // ms
opentelemetry::ext::http::client::Compression compression_{
opentelemetry::ext::http::client::Compression::kNone};
bool is_log_enabled_{false};
};

class Response : public opentelemetry::ext::http::client::Response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ class HttpOperation

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

static int CurlLoggerCallback(const CURL * /* handle */,
curl_infotype type,
const char *data,
size_t size,
void * /* clientp */) noexcept;

#if LIBCURL_VERSION_NUM >= 0x075000
static int PreRequestCallback(void *clientp,
char *conn_primary_ip,
Expand Down Expand Up @@ -152,7 +158,8 @@ class HttpOperation
// Default connectivity and response size options
bool is_raw_response = false,
std::chrono::milliseconds http_conn_timeout = default_http_conn_timeout,
bool reuse_connection = false);
bool reuse_connection = false,
bool is_log_enabled = false);

/**
* Destroy CURL instance
Expand Down Expand Up @@ -300,6 +307,8 @@ class HttpOperation

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

const bool is_log_enabled_;

// Processed response headers and body
long response_code_;
std::vector<uint8_t> response_headers_;
Expand Down
2 changes: 2 additions & 0 deletions ext/include/opentelemetry/ext/http/client/http_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ class Request

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

virtual void EnableLogging(bool is_log_enabled) noexcept = 0;

virtual ~Request() = default;
};

Expand Down
5 changes: 5 additions & 0 deletions ext/src/http/client/curl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ else()
PRIVATE ${CURL_LIBRARIES})
endif()

if(WITH_CURL_LOGGING)
target_compile_definitions(opentelemetry_http_client_curl
PRIVATE ENABLE_CURL_LOGGING)
endif()

if(WITH_OTLP_HTTP_COMPRESSION)
if(TARGET ZLIB::ZLIB)
target_link_libraries(
Expand Down
8 changes: 4 additions & 4 deletions ext/src/http/client/curl/http_client_curl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ void Session::SendRequest(
#endif
}

curl_operation_.reset(new HttpOperation(http_request_->method_, url, http_request_->ssl_options_,
callback_ptr, http_request_->headers_,
http_request_->body_, http_request_->compression_, false,
http_request_->timeout_ms_, reuse_connection));
curl_operation_.reset(new HttpOperation(
http_request_->method_, url, http_request_->ssl_options_, callback_ptr,
http_request_->headers_, http_request_->body_, http_request_->compression_, false,
http_request_->timeout_ms_, reuse_connection, http_request_->is_log_enabled_));
bool success =
CURLE_OK == curl_operation_->SendAsync(this, [this, callback](HttpOperation &operation) {
if (operation.WasAborted())
Expand Down
Loading

0 comments on commit 01e5bcf

Please sign in to comment.