Skip to content

Commit

Permalink
[CI] include-what-you-use (open-telemetry#2629)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcalff authored May 29, 2024
1 parent 277190d commit 0dd64e0
Show file tree
Hide file tree
Showing 54 changed files with 333 additions and 157 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/iwyu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

name: include-what-you-use

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
iwyu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: setup dependencies
run: |
sudo apt update -y
sudo apt install -y --no-install-recommends --no-install-suggests \
build-essential \
iwyu \
cmake \
ninja-build \
libssl-dev \
libcurl4-openssl-dev \
libprotobuf-dev \
protobuf-compiler \
libgmock-dev \
libgtest-dev \
libbenchmark-dev
- name: Prepare CMake
run: |
TOPDIR=`pwd`
mkdir build && cd build
CC="clang" CXX="clang++" cmake \
-DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="include-what-you-use;-w;-Xiwyu;--mapping_file=${TOPDIR}/.iwyu.imp;" \
-DBUILD_TESTING=OFF \
-DBUILD_W3CTRACECONTEXT_TEST=OFF \
..
- name: iwyu_tool
run: |
cd build
make -k 2>&1 | tee -a iwyu.log
- uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: Logs (include-what-you-use)
path: ./build/*.log

- name: count warnings
run: |
cd build
COUNT=`grep -c "Warning:" iwyu.log`
echo "include-what-you-use reported ${COUNT} warning(s)"
13 changes: 13 additions & 0 deletions .iwyu.imp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

# include-what-you-use mapping file

[
# Work around for C++ STL
{ "include": ["<bits/chrono.h>", "private", "<chrono>", "public"] },

# Local opentelemetry-cpp

]

2 changes: 1 addition & 1 deletion api/include/opentelemetry/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#pragma once

#include "opentelemetry/common/macros.h"
#include "opentelemetry/common/macros.h" // IWYU pragma: export
#include "opentelemetry/detail/preprocessor.h"

#ifndef OPENTELEMETRY_ABI_VERSION_NO
Expand Down
1 change: 0 additions & 1 deletion sdk/include/opentelemetry/sdk/common/base64.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#include <string>

#include "opentelemetry/common/macros.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/version.h"

Expand Down
3 changes: 2 additions & 1 deletion sdk/include/opentelemetry/sdk/common/global_log_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

#pragma once

#include <sstream>
#include <sstream> // IWYU pragma: keep
#include <string>
#include <utility>

#include "opentelemetry/nostd/shared_ptr.h"
Expand Down
6 changes: 2 additions & 4 deletions sdk/include/opentelemetry/sdk/metrics/async_instruments.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
#include <memory>

#include "opentelemetry/metrics/async_instruments.h"
#include "opentelemetry/metrics/observer_result.h"
#include "opentelemetry/sdk/metrics/instruments.h"
#include "opentelemetry/sdk/metrics/state/metric_storage.h"
#include "opentelemetry/sdk/metrics/state/observable_registry.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
Expand All @@ -16,9 +17,6 @@ namespace sdk
namespace metrics
{

class AsyncWritableMetricStorage;
class ObservableRegistry;

class ObservableInstrument : public opentelemetry::metrics::ObservableInstrument
{
public:
Expand Down
23 changes: 9 additions & 14 deletions sdk/include/opentelemetry/sdk/metrics/meter_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,29 @@
#include <memory>
#include <mutex>

#include "opentelemetry/metrics/meter.h"
#include "opentelemetry/metrics/meter_provider.h"
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/sdk/metrics/meter_context.h"
#include "opentelemetry/sdk/metrics/metric_reader.h"
#include "opentelemetry/sdk/metrics/view/instrument_selector.h"
#include "opentelemetry/sdk/metrics/view/meter_selector.h"
#include "opentelemetry/sdk/metrics/view/view.h"
#include "opentelemetry/sdk/metrics/view/view_registry.h"
#include "opentelemetry/sdk/resource/resource.h"
#include "opentelemetry/version.h"

#ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW
# include "opentelemetry/sdk/metrics/exemplar/filter_type.h"
#endif

#include "opentelemetry/sdk/metrics/view/view_registry.h"
#include "opentelemetry/sdk/resource/resource.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace metrics
{
class Meter;
} // namespace metrics

namespace sdk
{
namespace metrics
{

// forward declaration
class MeterContext;
class MetricCollector;
class MetricReader;

class OPENTELEMETRY_EXPORT MeterProvider final : public opentelemetry::metrics::MeterProvider
{
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
#pragma once

#include <memory>
#include <mutex>
#include <vector>
#include "opentelemetry/metrics/meter.h"

#include "opentelemetry/metrics/meter_provider.h"
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/sdk/metrics/meter.h"
#include "opentelemetry/sdk/metrics/meter_context.h"
#include "opentelemetry/sdk/metrics/view/view_registry.h"
#include "opentelemetry/sdk/resource/resource.h"
#include "opentelemetry/version.h"

Expand Down
8 changes: 6 additions & 2 deletions sdk/include/opentelemetry/sdk/trace/batch_span_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,28 @@

#pragma once

#include <stddef.h>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <cstdint>
#include <memory>
#include <mutex>
#include <thread>

#include "opentelemetry/sdk/common/circular_buffer.h"
#include "opentelemetry/sdk/trace/batch_span_processor_options.h"
#include "opentelemetry/sdk/trace/exporter.h"
#include "opentelemetry/sdk/trace/processor.h"
#include "opentelemetry/sdk/trace/recordable.h"
#include "opentelemetry/trace/span_context.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace trace
{
class SpanExporter;
struct BatchSpanProcessorOptions;

/**
* This is an implementation of the SpanProcessor which creates batches of finished spans and passes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

#include <memory>

#include "opentelemetry/sdk/trace/batch_span_processor_options.h"
#include "opentelemetry/sdk/trace/exporter.h"
#include "opentelemetry/sdk/trace/processor.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace trace
{
class SpanExporter;
class SpanProcessor;
struct BatchSpanProcessorOptions;

/**
* Factory class for BatchSpanProcessor.
Expand Down
2 changes: 1 addition & 1 deletion sdk/include/opentelemetry/sdk/trace/exporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

#include "opentelemetry/nostd/span.h"
#include "opentelemetry/sdk/common/exporter_utils.h"
#include "opentelemetry/sdk/trace/recordable.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace trace
{
class Recordable;

/**
* SpanExporter defines the interface that protocol-specific span exporters must
Expand Down
2 changes: 2 additions & 0 deletions sdk/include/opentelemetry/sdk/trace/random_id_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#pragma once

#include "opentelemetry/sdk/trace/id_generator.h"
#include "opentelemetry/trace/span_id.h"
#include "opentelemetry/trace/trace_id.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

#include <memory>

#include "opentelemetry/sdk/trace/id_generator.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace trace
{
class IdGenerator;

/**
* Factory class for RandomIdGenerator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

#include <memory>

#include "opentelemetry/sdk/trace/sampler.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace trace
{
class Sampler;

/**
* Factory class for AlwaysOffSampler.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

#include <memory>

#include "opentelemetry/sdk/trace/sampler.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace trace
{
class Sampler;

/**
* Factory class for AlwaysOnSampler.
Expand Down
18 changes: 6 additions & 12 deletions sdk/include/opentelemetry/sdk/trace/samplers/parent.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,22 @@
#pragma once

#include <memory>
#include <string>

#include "opentelemetry/common/key_value_iterable.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/sdk/trace/sampler.h"
#include "opentelemetry/trace/span_context.h"
#include "opentelemetry/trace/span_metadata.h"
#include "opentelemetry/trace/trace_id.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace common
{
class KeyValueIterable;
} // namespace common

namespace trace
{
class SpanContext;
class SpanContextKeyValueIterable;
class TraceState;
} // namespace trace

namespace sdk
{
namespace trace
{

/**
* The ParentBased sampler is a composite sampler. ParentBased(delegateSampler) either respects
* the parent span's sampling decision or delegates to delegateSampler for root spans.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

#include <memory>

#include "opentelemetry/sdk/trace/sampler.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace trace
{
class Sampler;

/**
* Factory class for ParentBasedSampler.
Expand Down
13 changes: 1 addition & 12 deletions sdk/include/opentelemetry/sdk/trace/samplers/trace_id_ratio.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#pragma once

#include <stdint.h>
#include <string>

#include "opentelemetry/nostd/string_view.h"
Expand All @@ -12,18 +13,6 @@
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace common
{
class KeyValueIterable;
} // namespace common

namespace trace
{
class SpanContext;
class SpanContextKeyValueIterable;
class TraceState;
} // namespace trace

namespace sdk
{
namespace trace
Expand Down
Loading

0 comments on commit 0dd64e0

Please sign in to comment.