Skip to content

Commit 948c6c5

Browse files
committed
Define observability interface between core SDK and the wrapper
1 parent 577ab57 commit 948c6c5

23 files changed

+3604
-0
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ set(couchbase_cxx_client_FILES
8181
core/app_telemetry_meter.cxx
8282
core/app_telemetry_reporter.cxx
8383
core/bucket.cxx
84+
core/chrono_utils.cxx
8485
core/cluster.cxx
8586
core/cluster_agent.cxx
8687
core/cluster_agent_config.cxx
@@ -102,6 +103,7 @@ set(couchbase_cxx_client_FILES
102103
core/dispatcher.cxx
103104
core/document_id.cxx
104105
core/error_context/key_value.cxx
106+
core/file_signal_sink.cxx
105107
core/free_form_http_request.cxx
106108
core/http_component.cxx
107109
core/impl/analytics.cxx
@@ -233,6 +235,7 @@ set(couchbase_cxx_client_FILES
233235
core/io/mcbp_session.cxx
234236
core/io/streams.cxx
235237
core/key_value_config.cxx
238+
core/log_entry.cxx
236239
core/logger/custom_rotating_file_sink.cxx
237240
core/logger/logger.cxx
238241
core/management/analytics_link_azure_blob_external.cxx
@@ -249,6 +252,7 @@ set(couchbase_cxx_client_FILES
249252
core/mcbp/queue_request.cxx
250253
core/mcbp/server_duration.cxx
251254
core/meta/version.cxx
255+
core/metric_measurement.cxx
252256
core/metrics/logging_meter.cxx
253257
core/metrics/meter_wrapper.cxx
254258
core/n1ql_query_options.cxx
@@ -402,8 +406,11 @@ set(couchbase_cxx_client_FILES
402406
core/scan_result.cxx
403407
core/search_query_options.cxx
404408
core/seed_config.cxx
409+
core/signal_bridge.cxx
410+
core/signal_data.cxx
405411
core/topology/capabilities.cxx
406412
core/topology/configuration.cxx
413+
core/trace_span.cxx
407414
core/tracing/threshold_logging_tracer.cxx
408415
core/tracing/tracer_wrapper.cxx
409416
core/tracing/wrapper_sdk_tracer.cxx

core/chrono_utils.cxx

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2+
/*
3+
* Copyright 2025-Current Couchbase, Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#include "chrono_utils.hxx"
19+
20+
#include <array>
21+
#include <chrono>
22+
#include <stdexcept>
23+
24+
namespace couchbase::core
25+
{
26+
auto
27+
to_iso8601_utc(std::time_t time_in_seconds, std::int64_t microseconds) -> std::string
28+
{
29+
std::tm tm{};
30+
#if defined(_MSC_VER)
31+
gmtime_s(&tm, &time_in_seconds);
32+
#else
33+
gmtime_r(&time_in_seconds, &tm);
34+
#endif
35+
36+
std::array<char, 100> buffer{};
37+
auto rc = std::snprintf(buffer.data(),
38+
buffer.size(),
39+
"%04d-%02d-%02dT%02d:%02d:%02d.%06lldZ",
40+
tm.tm_year + 1900,
41+
tm.tm_mon + 1,
42+
tm.tm_mday,
43+
tm.tm_hour,
44+
tm.tm_min,
45+
tm.tm_sec,
46+
static_cast<long long>(microseconds));
47+
auto bytes_written = static_cast<std::size_t>(rc);
48+
if (rc < 0 || bytes_written >= buffer.size()) {
49+
throw std::range_error("unable to format date: not enough memory in the buffer");
50+
}
51+
return { buffer.data(), bytes_written };
52+
}
53+
54+
auto
55+
to_iso8601_utc(const std::chrono::system_clock::time_point& time_point) -> std::string
56+
{
57+
const auto duration{ time_point.time_since_epoch() };
58+
const auto seconds{ std::chrono::duration_cast<std::chrono::seconds>(duration) };
59+
const auto micros{ std::chrono::duration_cast<std::chrono::microseconds>(duration - seconds) };
60+
61+
return to_iso8601_utc(std::chrono::system_clock::to_time_t(time_point), micros.count());
62+
}
63+
} // namespace couchbase::core

core/chrono_utils.hxx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2+
/*
3+
* Copyright 2025-Current Couchbase, Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#pragma once
19+
20+
#include <chrono>
21+
#include <string>
22+
23+
namespace couchbase::core
24+
{
25+
auto
26+
to_iso8601_utc(std::time_t time_in_seconds, std::int64_t microseconds = 0) -> std::string;
27+
28+
auto
29+
to_iso8601_utc(const std::chrono::system_clock::time_point& time_point) -> std::string;
30+
} // namespace couchbase::core

0 commit comments

Comments
 (0)