Skip to content

Commit d15da3b

Browse files
authored
[Code health] Include what you use cleanup, part 5 (open-telemetry#3140)
1 parent 8d45dec commit d15da3b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+502
-225
lines changed

.github/workflows/iwyu.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,16 @@ jobs:
6262

6363
- name: count warnings
6464
run: |
65+
set +e
6566
cd build
66-
COUNT=`grep -c "Warning:" iwyu.log`
67-
echo "include-what-you-use reported ${COUNT} warning(s)"
68-
67+
readonly WARNING_COUNT=`grep -c "include-what-you-use reported diagnostics:" iwyu.log`
68+
echo "include-what-you-use reported ${WARNING_COUNT} warning(s)"
69+
# Acceptable limit, to decrease over time down to 0
70+
readonly WARNING_LIMIT=10
71+
# FAIL the build if WARNING_COUNT > WARNING_LIMIT
72+
if [ $WARNING_COUNT -gt $WARNING_LIMIT ] ; then
73+
exit 1
74+
# WARN in annotations if WARNING_COUNT > 0
75+
elif [ $WARNING_COUNT -gt 0 ] ; then
76+
echo "::warning::include-what-you-use reported ${WARNING_COUNT} warning(s)"
77+
fi

.iwyu.imp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
[
77
# Work around for C++ STL
88
{ "include": ["<bits/chrono.h>", "private", "<chrono>", "public"] },
9+
{ "include": ["<bits/std_abs.h>", "private", "<cstdlib>", "public"] },
10+
{ "include": ["<ext/alloc_traits.h>", "private", "<memory>", "public"] },
11+
{ "include": ["<bits/types/struct_tm.h>", "private", "<time.h>", "public"] },
12+
{ "include": ["<bits/types/struct_FILE.h>", "private", "<stdio.h>", "public"] },
913

1014
# Local opentelemetry-cpp style
1115

@@ -14,6 +18,7 @@
1418
{ "include": ["<gtest/gtest-test-part.h>", "private", "<gtest/gtest.h>", "public"] },
1519
{ "include": ["<gtest/gtest-param-test.h>", "private", "<gtest/gtest.h>", "public"] },
1620
{ "include": ["<gtest/gtest_pred_impl.h>", "private", "<gtest/gtest.h>", "public"] },
21+
{ "include": ["<gtest/gtest-typed-test.h>", "private", "<gtest/gtest.h>", "public"] },
1722

1823
# We prefer to include <gmock/gmock.h> for simplicity
1924
{ "include": ["<gmock/gmock-function-mocker.h>", "private", "<gmock/gmock.h>", "public"] },

api/include/opentelemetry/nostd/variant.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,19 @@ OPENTELEMETRY_END_NAMESPACE
5454
# ifdef HAVE_ABSEIL
5555
# include "absl/types/variant.h"
5656
# else
57+
# include "opentelemetry/nostd/internal/absl/base/options.h"
58+
59+
namespace absl
60+
{
61+
namespace OTABSL_OPTION_NAMESPACE_NAME
62+
{
63+
template <class T>
64+
struct variant_size;
65+
template <typename... Ts>
66+
class variant;
67+
} // namespace OTABSL_OPTION_NAMESPACE_NAME
68+
} // namespace absl
69+
5770
# include "opentelemetry/nostd/internal/absl/types/variant.h"
5871
# endif
5972

api/test/trace/propagation/detail/string_test.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
#include <gtest/gtest.h>
5-
#include <opentelemetry/trace/propagation/b3_propagator.h>
6-
#include <string>
5+
#include <stddef.h>
6+
#include <ostream>
7+
#include <vector>
78

89
#include "opentelemetry/nostd/string_view.h"
10+
#include "opentelemetry/trace/propagation/detail/string.h"
911

1012
using namespace opentelemetry;
1113

exporters/memory/include/opentelemetry/exporters/memory/in_memory_metric_data.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,18 @@
33

44
#pragma once
55

6+
#include <stddef.h>
67
#include <map>
78
#include <memory>
89
#include <string>
910
#include <tuple>
1011

1112
#include "opentelemetry/exporters/memory/in_memory_data.h"
1213
#include "opentelemetry/sdk/metrics/data/metric_data.h"
14+
#include "opentelemetry/sdk/metrics/export/metric_producer.h"
15+
#include "opentelemetry/version.h"
1316

1417
OPENTELEMETRY_BEGIN_NAMESPACE
15-
namespace sdk
16-
{
17-
namespace metrics
18-
{
19-
struct ResourceMetrics;
20-
}
21-
} // namespace sdk
2218
namespace exporter
2319
{
2420
namespace memory

exporters/memory/include/opentelemetry/exporters/memory/in_memory_metric_exporter_factory.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,16 @@
55

66
#include <memory>
77

8+
#include "opentelemetry/exporters/memory/in_memory_metric_data.h"
89
#include "opentelemetry/sdk/metrics/instruments.h"
10+
#include "opentelemetry/sdk/metrics/push_metric_exporter.h"
911
#include "opentelemetry/version.h"
1012

1113
OPENTELEMETRY_BEGIN_NAMESPACE
12-
namespace sdk
13-
{
14-
namespace metrics
15-
{
16-
class PushMetricExporter;
17-
} // namespace metrics
18-
} // namespace sdk
1914
namespace exporter
2015
{
2116
namespace memory
2217
{
23-
class InMemoryMetricData;
2418

2519
/// A factory for InMemoryMetricExporter
2620
class InMemoryMetricExporterFactory

exporters/memory/src/in_memory_metric_data.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
// Copyright The OpenTelemetry Authors
22
// SPDX-License-Identifier: Apache-2.0
33

4+
#include <stddef.h>
5+
#include <map>
6+
#include <memory>
7+
#include <string>
8+
#include <tuple>
9+
#include <utility>
10+
#include <vector>
11+
12+
#include "opentelemetry/exporters/memory/in_memory_data.h"
413
#include "opentelemetry/exporters/memory/in_memory_metric_data.h"
14+
#include "opentelemetry/nostd/variant.h"
515
#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h"
16+
#include "opentelemetry/sdk/metrics/data/metric_data.h"
617
#include "opentelemetry/sdk/metrics/export/metric_producer.h"
18+
#include "opentelemetry/sdk/metrics/instruments.h"
19+
#include "opentelemetry/version.h"
720

821
OPENTELEMETRY_BEGIN_NAMESPACE
922
namespace exporter

exporters/memory/src/in_memory_metric_exporter_factory.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
// Copyright The OpenTelemetry Authors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
#include "opentelemetry/exporters/memory/in_memory_metric_exporter_factory.h"
4+
#include <atomic>
5+
#include <chrono>
6+
#include <memory>
7+
58
#include "opentelemetry/exporters/memory/in_memory_metric_data.h"
9+
#include "opentelemetry/exporters/memory/in_memory_metric_exporter_factory.h"
10+
#include "opentelemetry/sdk/common/exporter_utils.h"
611
#include "opentelemetry/sdk/common/global_log_handler.h"
712
#include "opentelemetry/sdk/metrics/export/metric_producer.h"
13+
#include "opentelemetry/sdk/metrics/instruments.h"
814
#include "opentelemetry/sdk/metrics/push_metric_exporter.h"
15+
#include "opentelemetry/version.h"
916

1017
OPENTELEMETRY_BEGIN_NAMESPACE
1118
namespace exporter

exporters/memory/test/in_memory_metric_data_test.cc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
// Copyright The OpenTelemetry Authors
22
// SPDX-License-Identifier: Apache-2.0
33

4+
#include <gtest/gtest.h>
5+
#include <algorithm>
6+
#include <map>
7+
#include <memory>
8+
#include <string>
9+
#include <utility>
10+
#include <vector>
11+
412
#include "opentelemetry/exporters/memory/in_memory_metric_data.h"
13+
#include "opentelemetry/nostd/variant.h"
514
#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h"
15+
#include "opentelemetry/sdk/metrics/data/metric_data.h"
16+
#include "opentelemetry/sdk/metrics/data/point_data.h"
617
#include "opentelemetry/sdk/metrics/export/metric_producer.h"
18+
#include "opentelemetry/sdk/metrics/instruments.h"
719
#include "opentelemetry/sdk/resource/resource.h"
820

9-
#include <gtest/gtest.h>
10-
11-
#include <vector>
12-
1321
using opentelemetry::exporter::memory::CircularBufferInMemoryMetricData;
1422
using opentelemetry::exporter::memory::SimpleAggregateInMemoryMetricData;
1523
using opentelemetry::sdk::metrics::MetricData;

exporters/memory/test/in_memory_metric_exporter_test.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
// Copyright The OpenTelemetry Authors
22
// SPDX-License-Identifier: Apache-2.0
33

4+
#include <gtest/gtest.h>
5+
#include <memory>
6+
#include <vector>
7+
48
#include "opentelemetry/exporters/memory/in_memory_metric_data.h"
59
#include "opentelemetry/exporters/memory/in_memory_metric_exporter_factory.h"
10+
#include "opentelemetry/sdk/common/exporter_utils.h"
611
#include "opentelemetry/sdk/metrics/export/metric_producer.h"
712
#include "opentelemetry/sdk/metrics/instruments.h"
813
#include "opentelemetry/sdk/metrics/push_metric_exporter.h"
914
#include "opentelemetry/sdk/resource/resource.h"
1015

11-
#include <gtest/gtest.h>
12-
1316
using opentelemetry::exporter::memory::CircularBufferInMemoryMetricData;
1417
using opentelemetry::exporter::memory::InMemoryMetricExporterFactory;
1518
using opentelemetry::sdk::common::ExportResult;

0 commit comments

Comments
 (0)