Skip to content

Commit

Permalink
[Metrics SDK] Cleanup ENABLE_METRICS_PREVIEW (#1735)
Browse files Browse the repository at this point in the history
  • Loading branch information
esigo authored Nov 6, 2022
1 parent 7efeeab commit b8b715f
Show file tree
Hide file tree
Showing 146 changed files with 1,007 additions and 1,411 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ option(
OFF)
option(WITH_EXAMPLES "Whether to build examples" ON)

option(WITH_METRICS_PREVIEW "Whether to build metrics preview" OFF)
option(WITH_LOGS_PREVIEW "Whether to build logs preview" OFF)
option(WITH_ASYNC_EXPORT_PREVIEW "Whether enable async export" OFF)
# Exemplar specs status is experimental, so behind feature flag by default
Expand Down
11 changes: 1 addition & 10 deletions api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,12 @@ if(NOT WITH_LOGS_PREVIEW)
set(LOGS_EXCLUDE_PATTERN "logs")
endif()

set(METRICS_EXCLUDE_PATTERN "")
if(NOT WITH_METRICS_PREVIEW)
set(METRICS_EXCLUDE_PATTERN "metrics")
endif()

install(
DIRECTORY include/opentelemetry
DESTINATION include
FILES_MATCHING
PATTERN "*.h"
PATTERN "${METRICS_EXCLUDE_PATTERN}" EXCLUDE)
PATTERN "metrics" EXCLUDE)

install(
DIRECTORY include/opentelemetry
Expand Down Expand Up @@ -74,10 +69,6 @@ if(WITH_GSL)
endif()
endif()

if(WITH_METRICS_PREVIEW)
target_compile_definitions(opentelemetry_api INTERFACE ENABLE_METRICS_PREVIEW)
endif()

if(WITH_LOGS_PREVIEW)
target_compile_definitions(opentelemetry_api INTERFACE ENABLE_LOGS_PREVIEW)
endif()
Expand Down
4 changes: 1 addition & 3 deletions api/include/opentelemetry/metrics/async_instruments.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
// SPDX-License-Identifier: Apache-2.0

#pragma once
#ifndef ENABLE_METRICS_PREVIEW

# include "opentelemetry/metrics/observer_result.h"
#include "opentelemetry/metrics/observer_result.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace metrics
Expand All @@ -31,4 +30,3 @@ class ObservableInstrument

} // namespace metrics
OPENTELEMETRY_END_NAMESPACE
#endif
16 changes: 7 additions & 9 deletions api/include/opentelemetry/metrics/meter.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
// SPDX-License-Identifier: Apache-2.0

#pragma once
#ifndef ENABLE_METRICS_PREVIEW

# include "opentelemetry/metrics/async_instruments.h"
# include "opentelemetry/metrics/sync_instruments.h"
# include "opentelemetry/nostd/shared_ptr.h"
# include "opentelemetry/nostd/span.h"
# include "opentelemetry/nostd/string_view.h"
# include "opentelemetry/nostd/unique_ptr.h"
# include "opentelemetry/version.h"
#include "opentelemetry/metrics/async_instruments.h"
#include "opentelemetry/metrics/sync_instruments.h"
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/nostd/span.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/nostd/unique_ptr.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace metrics
Expand Down Expand Up @@ -140,4 +139,3 @@ class Meter
};
} // namespace metrics
OPENTELEMETRY_END_NAMESPACE
#endif
8 changes: 3 additions & 5 deletions api/include/opentelemetry/metrics/meter_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
// SPDX-License-Identifier: Apache-2.0

#pragma once
#ifndef ENABLE_METRICS_PREVIEW

# include "opentelemetry/metrics/meter.h"
# include "opentelemetry/nostd/shared_ptr.h"
# include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/metrics/meter.h"
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/nostd/string_view.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace metrics
Expand All @@ -30,4 +29,3 @@ class MeterProvider
};
} // namespace metrics
OPENTELEMETRY_END_NAMESPACE
#endif
14 changes: 6 additions & 8 deletions api/include/opentelemetry/metrics/noop.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
// SPDX-License-Identifier: Apache-2.0

#pragma once
#ifndef ENABLE_METRICS_PREVIEW

# include "opentelemetry/metrics/async_instruments.h"
# include "opentelemetry/metrics/meter.h"
# include "opentelemetry/metrics/meter_provider.h"
# include "opentelemetry/metrics/observer_result.h"
# include "opentelemetry/metrics/sync_instruments.h"
# include "opentelemetry/version.h"
#include "opentelemetry/metrics/async_instruments.h"
#include "opentelemetry/metrics/meter.h"
#include "opentelemetry/metrics/meter_provider.h"
#include "opentelemetry/metrics/observer_result.h"
#include "opentelemetry/metrics/sync_instruments.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace metrics
Expand Down Expand Up @@ -213,4 +212,3 @@ class NoopMeterProvider final : public MeterProvider
};
} // namespace metrics
OPENTELEMETRY_END_NAMESPACE
#endif
14 changes: 6 additions & 8 deletions api/include/opentelemetry/metrics/observer_result.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
// SPDX-License-Identifier: Apache-2.0

#pragma once
#ifndef ENABLE_METRICS_PREVIEW

# include "opentelemetry/common/attribute_value.h"
# include "opentelemetry/common/key_value_iterable_view.h"
# include "opentelemetry/nostd/shared_ptr.h"
# include "opentelemetry/nostd/span.h"
# include "opentelemetry/nostd/string_view.h"
# include "opentelemetry/nostd/type_traits.h"
#include "opentelemetry/common/attribute_value.h"
#include "opentelemetry/common/key_value_iterable_view.h"
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/nostd/span.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/nostd/type_traits.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace metrics
Expand Down Expand Up @@ -51,4 +50,3 @@ using ObserverResult = nostd::variant<nostd::shared_ptr<ObserverResultT<int64_t>

} // namespace metrics
OPENTELEMETRY_END_NAMESPACE
#endif
14 changes: 6 additions & 8 deletions api/include/opentelemetry/metrics/provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
// SPDX-License-Identifier: Apache-2.0

#pragma once
#ifndef ENABLE_METRICS_PREVIEW

# include <mutex>
#include <mutex>

# include "opentelemetry/common/macros.h"
# include "opentelemetry/common/spin_lock_mutex.h"
# include "opentelemetry/metrics/meter_provider.h"
# include "opentelemetry/metrics/noop.h"
# include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/common/macros.h"
#include "opentelemetry/common/spin_lock_mutex.h"
#include "opentelemetry/metrics/meter_provider.h"
#include "opentelemetry/metrics/noop.h"
#include "opentelemetry/nostd/shared_ptr.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace metrics
Expand Down Expand Up @@ -58,4 +57,3 @@ class Provider

} // namespace metrics
OPENTELEMETRY_END_NAMESPACE
#endif
14 changes: 6 additions & 8 deletions api/include/opentelemetry/metrics/sync_instruments.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
// SPDX-License-Identifier: Apache-2.0

#pragma once
#ifndef ENABLE_METRICS_PREVIEW

# include "opentelemetry/common/attribute_value.h"
# include "opentelemetry/common/key_value_iterable_view.h"
# include "opentelemetry/context/context.h"
# include "opentelemetry/nostd/span.h"
# include "opentelemetry/nostd/string_view.h"
# include "opentelemetry/nostd/type_traits.h"
#include "opentelemetry/common/attribute_value.h"
#include "opentelemetry/common/key_value_iterable_view.h"
#include "opentelemetry/context/context.h"
#include "opentelemetry/nostd/span.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/nostd/type_traits.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace metrics
Expand Down Expand Up @@ -196,4 +195,3 @@ class UpDownCounter : public SynchronousInstrument

} // namespace metrics
OPENTELEMETRY_END_NAMESPACE
#endif
11 changes: 4 additions & 7 deletions api/test/metrics/meter_provider_test.cc
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#ifndef ENABLE_METRICS_PREVIEW

# include <gtest/gtest.h>
# include "opentelemetry/metrics/noop.h"
# include "opentelemetry/metrics/provider.h"
# include "opentelemetry/nostd/shared_ptr.h"
#include <gtest/gtest.h>
#include "opentelemetry/metrics/noop.h"
#include "opentelemetry/metrics/provider.h"
#include "opentelemetry/nostd/shared_ptr.h"

using opentelemetry::metrics::Meter;
using opentelemetry::metrics::MeterProvider;
Expand Down Expand Up @@ -35,4 +33,3 @@ TEST(Provider, MultipleMeterProviders)

ASSERT_NE(Provider::GetMeterProvider(), tf);
}
#endif
10 changes: 3 additions & 7 deletions api/test/metrics/noop_sync_instrument_test.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#ifndef ENABLE_METRICS_PREVIEW

# include <gtest/gtest.h>
# include <map>
# include "opentelemetry/metrics/noop.h"
#include <gtest/gtest.h>
#include <map>
#include "opentelemetry/metrics/noop.h"

TEST(Counter, Add)
{
Expand Down Expand Up @@ -46,5 +44,3 @@ TEST(UpDownCountr, Record)
counter->Add(10, {{"k1", "1"}, {"k2", 2}});
counter->Add(10, {{"k1", "1"}, {"k2", 2}}, opentelemetry::context::Context{});
}

#endif
5 changes: 0 additions & 5 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ if [[ "$1" == "cmake.test" ]]; then
-DWITH_ZIPKIN=ON \
-DWITH_JAEGER=ON \
-DWITH_ELASTICSEARCH=ON \
-DWITH_METRICS_PREVIEW=OFF \
-DWITH_METRICS_EXEMPLAR_PREVIEW=ON \
-DWITH_LOGS_PREVIEW=ON \
-DCMAKE_CXX_FLAGS="-Werror" \
Expand All @@ -99,7 +98,6 @@ elif [[ "$1" == "cmake.maintainer.test" ]]; then
-DWITH_JAEGER=ON \
-DWITH_ELASTICSEARCH=ON \
-DWITH_LOGS_PREVIEW=ON \
-DWITH_METRICS_PREVIEW=OFF \
-DWITH_METRICS_EXEMPLAR_PREVIEW=ON \
-DWITH_ASYNC_EXPORT_PREVIEW=ON \
-DOTELCPP_MAINTAINER_MODE=ON \
Expand All @@ -115,7 +113,6 @@ elif [[ "$1" == "cmake.with_async_export.test" ]]; then
-DWITH_ZIPKIN=ON \
-DWITH_JAEGER=ON \
-DWITH_ELASTICSEARCH=ON \
-DWITH_METRICS_PREVIEW=OFF \
-DWITH_METRICS_EXEMPLAR_PREVIEW=ON \
-DWITH_LOGS_PREVIEW=ON \
-DCMAKE_CXX_FLAGS="-Werror" \
Expand All @@ -128,7 +125,6 @@ elif [[ "$1" == "cmake.abseil.test" ]]; then
cd "${BUILD_DIR}"
rm -rf *
cmake -DCMAKE_BUILD_TYPE=Debug \
-DWITH_METRICS_PREVIEW=OFF \
-DWITH_METRICS_EXEMPLAR_PREVIEW=ON \
-DWITH_LOGS_PREVIEW=ON \
-DCMAKE_CXX_FLAGS="-Werror" \
Expand All @@ -153,7 +149,6 @@ elif [[ "$1" == "cmake.c++20.stl.test" ]]; then
cd "${BUILD_DIR}"
rm -rf *
cmake -DCMAKE_BUILD_TYPE=Debug \
-DWITH_METRICS_PREVIEW=OFF \
-DWITH_METRICS_EXEMPLAR_PREVIEW=ON \
-DWITH_LOGS_PREVIEW=ON \
-DCMAKE_CXX_FLAGS="-Werror" \
Expand Down
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ endif()
if(WITH_ZIPKIN)
add_subdirectory(zipkin)
endif()
if(WITH_PROMETHEUS AND NOT WITH_METRICS_PREVIEW)
if(WITH_PROMETHEUS)
add_subdirectory(prometheus)
endif()
add_subdirectory(plugin)
Expand Down
21 changes: 9 additions & 12 deletions examples/common/metrics_foo_library/foo_library.cc
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#ifndef ENABLE_METRICS_PREVIEW
# include "foo_library.h"
# include <chrono>
# include <map>
# include <memory>
# include <thread>
# include <vector>
# include "opentelemetry/context/context.h"
# include "opentelemetry/metrics/provider.h"
# include "opentelemetry/nostd/shared_ptr.h"
#include "foo_library.h"
#include <chrono>
#include <map>
#include <memory>
#include <thread>
#include <vector>
#include "opentelemetry/context/context.h"
#include "opentelemetry/metrics/provider.h"
#include "opentelemetry/nostd/shared_ptr.h"

namespace nostd = opentelemetry::nostd;
namespace metrics_api = opentelemetry::metrics;
Expand Down Expand Up @@ -95,5 +94,3 @@ void foo_library::histogram_example(const std::string &name)
std::this_thread::sleep_for(std::chrono::milliseconds(250));
}
}

#endif
5 changes: 2 additions & 3 deletions examples/common/metrics_foo_library/foo_library.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-License-Identifier: Apache-2.0

#pragma once
#ifndef ENABLE_METRICS_PREVIEW
# include <string>

#include <string>

class foo_library
{
Expand All @@ -12,4 +12,3 @@ class foo_library
static void histogram_example(const std::string &name);
static void observable_counter_example(const std::string &name);
};
#endif
17 changes: 5 additions & 12 deletions examples/metrics_simple/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
include_directories(${CMAKE_SOURCE_DIR}/exporters/ostream/include)
if(WITH_METRICS_PREVIEW)
add_executable(simple_metrics main.cc)
target_link_libraries(
simple_metrics ${CMAKE_THREAD_LIBS_INIT} opentelemetry_metrics_deprecated
opentelemetry_exporter_ostream_metrics_deprecated)
else()
add_executable(metrics_ostream_example metrics_ostream.cc)
target_link_libraries(
metrics_ostream_example ${CMAKE_THREAD_LIBS_INIT} opentelemetry_metrics
opentelemetry_exporter_ostream_metrics opentelemetry_resources
common_metrics_foo_library)
endif()
add_executable(metrics_ostream_example metrics_ostream.cc)
target_link_libraries(
metrics_ostream_example ${CMAKE_THREAD_LIBS_INIT} opentelemetry_metrics
opentelemetry_exporter_ostream_metrics opentelemetry_resources
common_metrics_foo_library)
Loading

0 comments on commit b8b715f

Please sign in to comment.