Skip to content

Commit 739862d

Browse files
authored
[CODE HEALTH] Fix clang-tidy misc-use-internal-linkage warnings (open-telemetry#3918)
1 parent 082620c commit 739862d

25 files changed

+242
-235
lines changed

.github/workflows/clang-tidy.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jobs:
1717
matrix:
1818
include:
1919
- cmake_options: all-options-abiv1-preview
20-
warning_limit: 490
20+
warning_limit: 330
2121
- cmake_options: all-options-abiv2-preview
22-
warning_limit: 492
22+
warning_limit: 332
2323
env:
2424
CC: /usr/bin/clang-18
2525
CXX: /usr/bin/clang++-18

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ Increment the:
3939
* [EXAMPLES] Deprecated semantic conventions used
4040
[#3905](https://github.com/open-telemetry/opentelemetry-cpp/pull/3905)
4141

42+
* [CODE HEALTH] Fix clang-tidy misc-use-internal-linkage warnings
43+
[#3600](https://github.com/open-telemetry/opentelemetry-cpp/pull/3600)
44+
4245
Important changes:
4346

4447
* [BUILD] Revisit EventLogger deprecation

api/test/baggage/baggage_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
using namespace opentelemetry::baggage;
1717

18-
std::string header_with_custom_entries(size_t num_entries)
18+
static std::string header_with_custom_entries(size_t num_entries)
1919
{
2020
std::string header;
2121
for (size_t i = 0; i < num_entries; i++)
@@ -31,7 +31,7 @@ std::string header_with_custom_entries(size_t num_entries)
3131
return header;
3232
}
3333

34-
std::string header_with_custom_size(size_t key_value_size, size_t num_entries)
34+
static std::string header_with_custom_size(size_t key_value_size, size_t num_entries)
3535
{
3636
std::string header = "";
3737
for (size_t i = 0; i < num_entries; i++)

api/test/nostd/function_ref_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88

99
using namespace opentelemetry::nostd;
1010

11-
int Call(function_ref<int()> f)
11+
static int Call(function_ref<int()> f)
1212
{
1313
return f();
1414
}
1515

16-
int Return3()
16+
static int Return3()
1717
{
1818
return 3;
1919
}

api/test/singleton/singleton_test.cc

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
using namespace opentelemetry;
3434

35-
void do_something()
35+
static void do_something()
3636
{
3737
do_something_in_a();
3838
do_something_in_b();
@@ -111,33 +111,33 @@ void do_something()
111111
#endif /* BAZEL_BUILD */
112112
}
113113

114-
int span_a_lib_count = 0;
115-
int span_a_f1_count = 0;
116-
int span_a_f2_count = 0;
117-
int span_b_lib_count = 0;
118-
int span_b_f1_count = 0;
119-
int span_b_f2_count = 0;
120-
int span_c_lib_count = 0;
121-
int span_c_f1_count = 0;
122-
int span_c_f2_count = 0;
123-
int span_d_lib_count = 0;
124-
int span_d_f1_count = 0;
125-
int span_d_f2_count = 0;
126-
int span_e_lib_count = 0;
127-
int span_e_f1_count = 0;
128-
int span_e_f2_count = 0;
129-
int span_f_lib_count = 0;
130-
int span_f_f1_count = 0;
131-
int span_f_f2_count = 0;
132-
int span_g_lib_count = 0;
133-
int span_g_f1_count = 0;
134-
int span_g_f2_count = 0;
135-
int span_h_lib_count = 0;
136-
int span_h_f1_count = 0;
137-
int span_h_f2_count = 0;
138-
int unknown_span_count = 0;
139-
140-
void reset_counts()
114+
static int span_a_lib_count = 0;
115+
static int span_a_f1_count = 0;
116+
static int span_a_f2_count = 0;
117+
static int span_b_lib_count = 0;
118+
static int span_b_f1_count = 0;
119+
static int span_b_f2_count = 0;
120+
static int span_c_lib_count = 0;
121+
static int span_c_f1_count = 0;
122+
static int span_c_f2_count = 0;
123+
static int span_d_lib_count = 0;
124+
static int span_d_f1_count = 0;
125+
static int span_d_f2_count = 0;
126+
static int span_e_lib_count = 0;
127+
static int span_e_f1_count = 0;
128+
static int span_e_f2_count = 0;
129+
static int span_f_lib_count = 0;
130+
static int span_f_f1_count = 0;
131+
static int span_f_f2_count = 0;
132+
static int span_g_lib_count = 0;
133+
static int span_g_f1_count = 0;
134+
static int span_g_f2_count = 0;
135+
static int span_h_lib_count = 0;
136+
static int span_h_f1_count = 0;
137+
static int span_h_f2_count = 0;
138+
static int unknown_span_count = 0;
139+
140+
static void reset_counts()
141141
{
142142
span_a_lib_count = 0;
143143
span_a_f1_count = 0;
@@ -331,7 +331,7 @@ class MyTracerProvider : public trace::TracerProvider
331331
#endif
332332
};
333333

334-
void setup_otel()
334+
static void setup_otel()
335335
{
336336
std::shared_ptr<opentelemetry::trace::TracerProvider> provider = MyTracerProvider::Create();
337337

@@ -343,7 +343,7 @@ void setup_otel()
343343
trace_api::Provider::SetTracerProvider(provider);
344344
}
345345

346-
void cleanup_otel()
346+
static void cleanup_otel()
347347
{
348348
std::shared_ptr<opentelemetry::trace::TracerProvider> provider(
349349
new opentelemetry::trace::NoopTracerProvider());

exporters/ostream/src/metric_exporter.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ namespace metrics
7676
{
7777

7878
template <typename Container>
79-
inline void printVec(std::ostream &os, Container &vec)
79+
static inline void printVec(std::ostream &os, Container &vec)
8080
{
8181
using T = typename std::decay<decltype(*vec.begin())>::type;
8282
os << '[';

exporters/ostream/src/span_exporter.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace exporter
4040
namespace trace
4141
{
4242

43-
std::ostream &operator<<(std::ostream &os, trace_api::SpanKind span_kind)
43+
static std::ostream &operator<<(std::ostream &os, trace_api::SpanKind span_kind)
4444
{
4545
switch (span_kind)
4646
{

exporters/otlp/test/otlp_http_exporter_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ static nostd::span<T, N> MakeSpan(T (&array)[N])
5656
return nostd::span<T, N>(array);
5757
}
5858

59-
OtlpHttpClientOptions MakeOtlpHttpClientOptions(HttpRequestContentType content_type,
60-
bool async_mode)
59+
static OtlpHttpClientOptions MakeOtlpHttpClientOptions(HttpRequestContentType content_type,
60+
bool async_mode)
6161
{
6262
std::shared_ptr<opentelemetry::sdk::common::ThreadInstrumentation> not_instrumented;
6363
OtlpHttpExporterOptions options;

exporters/otlp/test/otlp_http_log_record_exporter_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ static nostd::span<T, N> MakeSpan(T (&array)[N])
5151
return nostd::span<T, N>(array);
5252
}
5353

54-
OtlpHttpClientOptions MakeOtlpHttpClientOptions(HttpRequestContentType content_type,
55-
bool async_mode)
54+
static OtlpHttpClientOptions MakeOtlpHttpClientOptions(HttpRequestContentType content_type,
55+
bool async_mode)
5656
{
5757
std::shared_ptr<opentelemetry::sdk::common::ThreadInstrumentation> not_instrumented;
5858
OtlpHttpLogRecordExporterOptions options;

exporters/otlp/test/otlp_http_metric_exporter_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ static IntegerType JsonToInteger(nlohmann::json value)
7272
return value.get<IntegerType>();
7373
}
7474

75-
OtlpHttpClientOptions MakeOtlpHttpClientOptions(HttpRequestContentType content_type,
76-
bool async_mode)
75+
static OtlpHttpClientOptions MakeOtlpHttpClientOptions(HttpRequestContentType content_type,
76+
bool async_mode)
7777
{
7878
std::shared_ptr<opentelemetry::sdk::common::ThreadInstrumentation> not_instrumented;
7979
OtlpHttpMetricExporterOptions options;

0 commit comments

Comments
 (0)