Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/clang-tidy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
matrix:
include:
- cmake_options: all-options-abiv1-preview
warning_limit: 216
warning_limit: 163
- cmake_options: all-options-abiv2-preview
warning_limit: 226
warning_limit: 173
env:
CC: /usr/bin/clang-22
CXX: /usr/bin/clang++-22
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ Increment the:

## [Unreleased]

* [CODE HEALTH] Fix more clang tidy warnings (member initialization)
[#4270](https://github.com/open-telemetry/opentelemetry-cpp/pull/4270)

* docs: update supported development platforms
[#4260](https://github.com/open-telemetry/opentelemetry-cpp/pull/4260)

Expand Down
6 changes: 3 additions & 3 deletions api/include/opentelemetry/baggage/baggage.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class OPENTELEMETRY_EXPORT Baggage
value = value.substr(0, metadata_separator);
}

bool err = 0;
bool err = false;
auto key_str = UrlDecode(common::StringUtil::Trim(key), err);
auto value_str = UrlDecode(common::StringUtil::Trim(value), err);

Expand Down Expand Up @@ -264,7 +264,7 @@ class OPENTELEMETRY_EXPORT Baggage
{
if (i + 2 >= str.size() || !IsHex(str[i + 1]) || !IsHex(str[i + 2]))
{
err = 1;
err = true;
return "";
}
ret.push_back(static_cast<char>(from_hex(str[i + 1]) << 4 | from_hex(str[i + 2])));
Expand All @@ -286,7 +286,7 @@ class OPENTELEMETRY_EXPORT Baggage
}
else
{
err = 1;
err = true;
return "";
}
}
Expand Down
4 changes: 2 additions & 2 deletions api/include/opentelemetry/trace/span_id.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class SpanId final
static constexpr size_t kSize = 8;

// An invalid SpanId (all zeros).
SpanId() noexcept : rep_{0} {}
SpanId() noexcept = default;

// Creates a SpanId with the given ID.
explicit SpanId(nostd::span<const uint8_t, kSize> id) noexcept { memcpy(rep_, id.data(), kSize); }
Expand Down Expand Up @@ -60,7 +60,7 @@ class SpanId final
}

private:
uint8_t rep_[kSize];
uint8_t rep_[kSize]{};
};

} // namespace trace
Expand Down
4 changes: 2 additions & 2 deletions api/include/opentelemetry/trace/trace_id.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class TraceId final
static constexpr size_t kSize = 16;

// An invalid TraceId (all zeros).
TraceId() noexcept : rep_{0} {}
TraceId() noexcept = default;

// Creates a TraceId with the given ID.
explicit TraceId(nostd::span<const uint8_t, kSize> id) noexcept
Expand Down Expand Up @@ -65,7 +65,7 @@ class TraceId final
}

private:
uint8_t rep_[kSize];
uint8_t rep_[kSize]{};
};

} // namespace trace
Expand Down
2 changes: 1 addition & 1 deletion examples/http/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ int main(int argc, char *argv[])
Scope scope(root_span);
http_server.Start();
std::cout << "Server is running..Press ctrl-c to exit...\n";
while (1)
while (true)
{
std::this_thread::sleep_for(std::chrono::seconds(100));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct OtlpGrpcClientOptions
#endif

/** Export timeout. */
std::chrono::system_clock::duration timeout;
std::chrono::system_clock::duration timeout{};

/** Additional HTTP headers. */
OtlpHeaders metadata;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ struct OPENTELEMETRY_EXPORT OtlpGrpcMetricExporterOptions : public OtlpGrpcClien
~OtlpGrpcMetricExporterOptions() override;

/** Preferred Aggregation Temporality. */
PreferredAggregationTemporality aggregation_temporality;
PreferredAggregationTemporality aggregation_temporality{
PreferredAggregationTemporality::kCumulative};
};

} // namespace otlp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct OtlpHttpClientOptions
// Whether to print the status of the HTTP client in the console
bool console_debug = false;

std::chrono::system_clock::duration timeout;
std::chrono::system_clock::duration timeout{};

// Additional HTTP headers
OtlpHeaders http_headers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,40 +47,40 @@ struct OPENTELEMETRY_EXPORT OtlpHttpExporterOptions
std::string url;

/** HTTP content type. */
HttpRequestContentType content_type;
HttpRequestContentType content_type{HttpRequestContentType::kBinary};

/**
Json byte mapping.

Used only for HttpRequestContentType::kJson.
Convert bytes to hex / base64.
*/
JsonBytesMappingKind json_bytes_mapping;
JsonBytesMappingKind json_bytes_mapping{JsonBytesMappingKind::kHexId};

/**
Use json names (true) or protobuf field names (false) to set the json key.
*/
bool use_json_name;
bool use_json_name{false};

/** Print debug messages. */
bool console_debug;
bool console_debug{false};

/** Export timeout. */
std::chrono::system_clock::duration timeout;
std::chrono::system_clock::duration timeout{};

/** Additional HTTP headers. */
OtlpHeaders http_headers;

#ifdef ENABLE_ASYNC_EXPORT
/** Max number of concurrent requests. */
std::size_t max_concurrent_requests;
std::size_t max_concurrent_requests{64};

/** Max number of requests per connection. */
std::size_t max_requests_per_connection;
std::size_t max_requests_per_connection{8};
#endif

/** True do disable SSL. */
bool ssl_insecure_skip_verify;
bool ssl_insecure_skip_verify{};

/** CA CERT, path to a file. */
std::string ssl_ca_cert_path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,40 +46,40 @@ struct OPENTELEMETRY_EXPORT OtlpHttpLogRecordExporterOptions
std::string url;

/** HTTP content type. */
HttpRequestContentType content_type;
HttpRequestContentType content_type{HttpRequestContentType::kBinary};

/**
Json byte mapping.

Used only for HttpRequestContentType::kJson.
Convert bytes to hex / base64.
*/
JsonBytesMappingKind json_bytes_mapping;
JsonBytesMappingKind json_bytes_mapping{JsonBytesMappingKind::kHexId};

/**
Use json names (true) or protobuf field names (false) to set the json key.
*/
bool use_json_name;
bool use_json_name{false};

/** Print debug messages. */
bool console_debug;
bool console_debug{false};

/** Export timeout. */
std::chrono::system_clock::duration timeout;
std::chrono::system_clock::duration timeout{};

/** Additional HTTP headers. */
OtlpHeaders http_headers;

#ifdef ENABLE_ASYNC_EXPORT
/** Max number of concurrent requests. */
std::size_t max_concurrent_requests;
std::size_t max_concurrent_requests{64};

/** Max number of requests per connection. */
std::size_t max_requests_per_connection;
std::size_t max_requests_per_connection{8};
#endif

/** True do disable SSL. */
bool ssl_insecure_skip_verify;
bool ssl_insecure_skip_verify{};

/** CA CERT, path to a file. */
std::string ssl_ca_cert_path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,42 +47,43 @@ struct OPENTELEMETRY_EXPORT OtlpHttpMetricExporterOptions
std::string url;

/** HTTP content type. */
HttpRequestContentType content_type;
HttpRequestContentType content_type{HttpRequestContentType::kBinary};

/**
Json byte mapping.

Used only for HttpRequestContentType::kJson.
Convert bytes to hex / base64.
*/
JsonBytesMappingKind json_bytes_mapping;
JsonBytesMappingKind json_bytes_mapping{JsonBytesMappingKind::kHexId};

/**
Use json names (true) or protobuf field names (false) to set the json key.
*/
bool use_json_name;
bool use_json_name{false};

/** Print debug messages. */
bool console_debug;
bool console_debug{false};

/** Export timeout. */
std::chrono::system_clock::duration timeout;
std::chrono::system_clock::duration timeout{};

/** Additional HTTP headers. */
OtlpHeaders http_headers;

PreferredAggregationTemporality aggregation_temporality;
PreferredAggregationTemporality aggregation_temporality{
PreferredAggregationTemporality::kCumulative};

#ifdef ENABLE_ASYNC_EXPORT
/** Max number of concurrent requests. */
std::size_t max_concurrent_requests;
std::size_t max_concurrent_requests{64};

/** Max number of requests per connection. */
std::size_t max_requests_per_connection;
std::size_t max_requests_per_connection{8};
#endif

/** True do disable SSL. */
bool ssl_insecure_skip_verify;
bool ssl_insecure_skip_verify{};

/** CA CERT, path to a file. */
std::string ssl_ca_cert_path;
Expand Down
14 changes: 7 additions & 7 deletions exporters/otlp/src/otlp_file_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1569,16 +1569,16 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileSystemBackend : public OtlpFileAppender

struct FileStats
{
std::atomic<bool> is_shutdown;
std::size_t rotate_index;
std::size_t written_size;
std::size_t left_flush_record_count;
std::atomic<bool> is_shutdown{false};
std::size_t rotate_index{0};
std::size_t written_size{0};
std::size_t left_flush_record_count{0};
std::shared_ptr<std::FILE> current_file;
std::mutex file_lock;
std::time_t last_checkpoint;
std::time_t last_checkpoint{0};
std::string file_path;
std::atomic<std::size_t> record_count;
std::atomic<std::size_t> flushed_record_count;
std::atomic<std::size_t> record_count{0};
std::atomic<std::size_t> flushed_record_count{0};

std::unique_ptr<std::thread> background_flush_thread;
std::mutex background_thread_lock;
Expand Down
3 changes: 0 additions & 3 deletions exporters/otlp/src/otlp_grpc_metric_exporter_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#include "opentelemetry/exporters/otlp/otlp_environment.h"
#include "opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h"
#include "opentelemetry/exporters/otlp/otlp_preferred_temporality.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
Expand All @@ -16,7 +15,6 @@ namespace otlp
{

OtlpGrpcMetricExporterOptions::OtlpGrpcMetricExporterOptions()
: aggregation_temporality(PreferredAggregationTemporality::kCumulative)
{
endpoint = GetOtlpDefaultGrpcMetricsEndpoint();
use_ssl_credentials = !GetOtlpDefaultGrpcMetricsIsInsecure(); /* negation intended. */
Expand Down Expand Up @@ -48,7 +46,6 @@ OtlpGrpcMetricExporterOptions::OtlpGrpcMetricExporterOptions()
}

OtlpGrpcMetricExporterOptions::OtlpGrpcMetricExporterOptions(void *)
: aggregation_temporality(PreferredAggregationTemporality::kCumulative)
{
use_ssl_credentials = true;
max_threads = 0;
Expand Down
21 changes: 1 addition & 20 deletions exporters/otlp/src/otlp_http_exporter_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,8 @@ namespace otlp
OtlpHttpExporterOptions::OtlpHttpExporterOptions()
: url(GetOtlpDefaultHttpTracesEndpoint()),
content_type(GetOtlpHttpProtocolFromString(GetOtlpDefaultHttpTracesProtocol())),
json_bytes_mapping(JsonBytesMappingKind::kHexId),
use_json_name(false),
console_debug(false),
timeout(GetOtlpDefaultTracesTimeout()),
http_headers(GetOtlpDefaultTracesHeaders()),
#ifdef ENABLE_ASYNC_EXPORT
max_concurrent_requests{64},
max_requests_per_connection{8},
#endif
ssl_insecure_skip_verify(false),
ssl_ca_cert_path(GetOtlpDefaultTracesSslCertificatePath()),
ssl_ca_cert_string(GetOtlpDefaultTracesSslCertificateString()),
ssl_client_key_path(GetOtlpDefaultTracesSslClientKeyPath()),
Expand All @@ -42,18 +34,7 @@ OtlpHttpExporterOptions::OtlpHttpExporterOptions()
retry_policy_backoff_multiplier(GetOtlpDefaultTracesRetryBackoffMultiplier())
{}

OtlpHttpExporterOptions::OtlpHttpExporterOptions(void *)
: url(),
content_type(HttpRequestContentType::kBinary),
json_bytes_mapping(JsonBytesMappingKind::kHexId),
use_json_name(false),
console_debug(false),
#ifdef ENABLE_ASYNC_EXPORT
max_concurrent_requests{64},
max_requests_per_connection{8},
#endif
ssl_insecure_skip_verify(false)
{}
OtlpHttpExporterOptions::OtlpHttpExporterOptions(void *) {}

OtlpHttpExporterOptions::~OtlpHttpExporterOptions() {}

Expand Down
21 changes: 1 addition & 20 deletions exporters/otlp/src/otlp_http_log_record_exporter_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,8 @@ namespace otlp
OtlpHttpLogRecordExporterOptions::OtlpHttpLogRecordExporterOptions()
: url(GetOtlpDefaultHttpLogsEndpoint()),
content_type(GetOtlpHttpProtocolFromString(GetOtlpDefaultHttpLogsProtocol())),
json_bytes_mapping(JsonBytesMappingKind::kHexId),
use_json_name(false),
console_debug(false),
timeout(GetOtlpDefaultLogsTimeout()),
http_headers(GetOtlpDefaultLogsHeaders()),
#ifdef ENABLE_ASYNC_EXPORT
max_concurrent_requests{64},
max_requests_per_connection{8},
#endif
ssl_insecure_skip_verify(false),
ssl_ca_cert_path(GetOtlpDefaultLogsSslCertificatePath()),
ssl_ca_cert_string(GetOtlpDefaultLogsSslCertificateString()),
ssl_client_key_path(GetOtlpDefaultLogsSslClientKeyPath()),
Expand All @@ -42,18 +34,7 @@ OtlpHttpLogRecordExporterOptions::OtlpHttpLogRecordExporterOptions()
retry_policy_backoff_multiplier(GetOtlpDefaultLogsRetryBackoffMultiplier())
{}

OtlpHttpLogRecordExporterOptions::OtlpHttpLogRecordExporterOptions(void *)
: url(),
content_type(exporter::otlp::HttpRequestContentType::kBinary),
json_bytes_mapping(JsonBytesMappingKind::kHexId),
use_json_name(false),
console_debug(false),
#ifdef ENABLE_ASYNC_EXPORT
max_concurrent_requests{64},
max_requests_per_connection{8},
#endif
ssl_insecure_skip_verify(false)
{}
OtlpHttpLogRecordExporterOptions::OtlpHttpLogRecordExporterOptions(void *) {}

OtlpHttpLogRecordExporterOptions::~OtlpHttpLogRecordExporterOptions() {}

Expand Down
Loading
Loading