Skip to content

Commit

Permalink
Separate symbol visibility for core, push, and pull
Browse files Browse the repository at this point in the history
  • Loading branch information
gjasny committed Aug 3, 2019
1 parent ed7f79d commit eb9479c
Show file tree
Hide file tree
Showing 26 changed files with 69 additions and 59 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Expand Up @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.5 FATAL_ERROR)

project(prometheus-cpp VERSION 0.8.0)

include(GenerateExportHeader)
include(GNUInstallDirs)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
Expand Down
8 changes: 7 additions & 1 deletion core/CMakeLists.txt
Expand Up @@ -19,6 +19,11 @@ add_library(core

add_library(${PROJECT_NAME}::core ALIAS core)

generate_export_header(core
EXPORT_FILE_NAME include/prometheus/detail/core_export.h
PREFIX_NAME PROMETHEUS_CPP_
)

target_link_libraries(core
PRIVATE
Threads::Threads
Expand All @@ -28,6 +33,7 @@ target_link_libraries(core
target_include_directories(core
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
)

set_target_properties(core
Expand All @@ -47,7 +53,7 @@ install(
)

install(
DIRECTORY include/
DIRECTORY include/ ${CMAKE_CURRENT_BINARY_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

Expand Down
6 changes: 3 additions & 3 deletions core/include/prometheus/check_names.h
Expand Up @@ -2,10 +2,10 @@

#include <string>

#include "prometheus/detail/visibility.h"
#include "prometheus/detail/core_export.h"

namespace prometheus {

PROMETHEUSCPP_API bool CheckMetricName(const std::string& name);
PROMETHEUSCPP_API bool CheckLabelName(const std::string& name);
PROMETHEUS_CPP_CORE_EXPORT bool CheckMetricName(const std::string& name);
PROMETHEUS_CPP_CORE_EXPORT bool CheckLabelName(const std::string& name);
} // namespace prometheus
4 changes: 2 additions & 2 deletions core/include/prometheus/client_metric.h
Expand Up @@ -5,11 +5,11 @@
#include <tuple>
#include <vector>

#include "prometheus/detail/visibility.h"
#include "prometheus/detail/core_export.h"

namespace prometheus {

struct PROMETHEUSCPP_API ClientMetric {
struct PROMETHEUS_CPP_CORE_EXPORT ClientMetric {
// Label

struct Label {
Expand Down
4 changes: 2 additions & 2 deletions core/include/prometheus/collectable.h
Expand Up @@ -2,7 +2,7 @@

#include <vector>

#include "prometheus/detail/visibility.h"
#include "prometheus/detail/core_export.h"

namespace prometheus {
struct MetricFamily;
Expand All @@ -14,7 +14,7 @@ namespace prometheus {
/// collect metrics.
///
/// A Collectable has to be registered for collection. See Registry.
class PROMETHEUSCPP_API Collectable {
class PROMETHEUS_CPP_CORE_EXPORT Collectable {
public:
virtual ~Collectable() = default;

Expand Down
6 changes: 3 additions & 3 deletions core/include/prometheus/counter.h
@@ -1,8 +1,8 @@
#pragma once

#include "prometheus/client_metric.h"
#include "prometheus/detail/core_export.h"
#include "prometheus/detail/counter_builder.h"
#include "prometheus/detail/visibility.h"
#include "prometheus/gauge.h"
#include "prometheus/metric_type.h"

Expand All @@ -23,7 +23,7 @@ namespace prometheus {
///
/// The class is thread-safe. No concurrent call to any API of this type causes
/// a data race.
class PROMETHEUSCPP_API Counter {
class PROMETHEUS_CPP_CORE_EXPORT Counter {
public:
static const MetricType metric_type{MetricType::Counter};

Expand Down Expand Up @@ -77,6 +77,6 @@ class PROMETHEUSCPP_API Counter {
///
/// To finish the configuration of the Counter metric, register it with
/// Register(Registry&).
PROMETHEUSCPP_API detail::CounterBuilder BuildCounter();
PROMETHEUS_CPP_CORE_EXPORT detail::CounterBuilder BuildCounter();

} // namespace prometheus
4 changes: 2 additions & 2 deletions core/include/prometheus/detail/ckms_quantiles.h
Expand Up @@ -5,12 +5,12 @@
#include <functional>
#include <vector>

#include "prometheus/detail/visibility.h"
#include "prometheus/detail/core_export.h"

namespace prometheus {
namespace detail {

class PROMETHEUSCPP_API CKMSQuantiles {
class PROMETHEUS_CPP_CORE_EXPORT CKMSQuantiles {
public:
struct Quantile {
const double quantile;
Expand Down
4 changes: 2 additions & 2 deletions core/include/prometheus/detail/counter_builder.h
Expand Up @@ -3,7 +3,7 @@
#include <map>
#include <string>

#include "prometheus/detail/visibility.h"
#include "prometheus/detail/core_export.h"

namespace prometheus {

Expand All @@ -14,7 +14,7 @@ class Registry;

namespace detail {

class PROMETHEUSCPP_API CounterBuilder {
class PROMETHEUS_CPP_CORE_EXPORT CounterBuilder {
public:
CounterBuilder& Labels(const std::map<std::string, std::string>& labels);
CounterBuilder& Name(const std::string&);
Expand Down
4 changes: 2 additions & 2 deletions core/include/prometheus/detail/gauge_builder.h
Expand Up @@ -3,7 +3,7 @@
#include <map>
#include <string>

#include "prometheus/detail/visibility.h"
#include "prometheus/detail/core_export.h"

namespace prometheus {

Expand All @@ -14,7 +14,7 @@ class Registry;

namespace detail {

class PROMETHEUSCPP_API GaugeBuilder {
class PROMETHEUS_CPP_CORE_EXPORT GaugeBuilder {
public:
GaugeBuilder& Labels(const std::map<std::string, std::string>& labels);
GaugeBuilder& Name(const std::string&);
Expand Down
4 changes: 2 additions & 2 deletions core/include/prometheus/detail/histogram_builder.h
Expand Up @@ -3,7 +3,7 @@
#include <map>
#include <string>

#include "prometheus/detail/visibility.h"
#include "prometheus/detail/core_export.h"

namespace prometheus {

Expand All @@ -14,7 +14,7 @@ class Registry;

namespace detail {

class PROMETHEUSCPP_API HistogramBuilder {
class PROMETHEUS_CPP_CORE_EXPORT HistogramBuilder {
public:
HistogramBuilder& Labels(const std::map<std::string, std::string>& labels);
HistogramBuilder& Name(const std::string&);
Expand Down
4 changes: 2 additions & 2 deletions core/include/prometheus/detail/summary_builder.h
Expand Up @@ -3,7 +3,7 @@
#include <map>
#include <string>

#include "prometheus/detail/visibility.h"
#include "prometheus/detail/core_export.h"

namespace prometheus {

Expand All @@ -14,7 +14,7 @@ class Registry;

namespace detail {

class PROMETHEUSCPP_API SummaryBuilder {
class PROMETHEUS_CPP_CORE_EXPORT SummaryBuilder {
public:
SummaryBuilder& Labels(const std::map<std::string, std::string>& labels);
SummaryBuilder& Name(const std::string&);
Expand Down
4 changes: 2 additions & 2 deletions core/include/prometheus/detail/time_window_quantiles.h
Expand Up @@ -5,12 +5,12 @@
#include <vector>

#include "prometheus/detail/ckms_quantiles.h"
#include "prometheus/detail/visibility.h"
#include "prometheus/detail/core_export.h"

namespace prometheus {
namespace detail {

class PROMETHEUSCPP_API TimeWindowQuantiles {
class PROMETHEUS_CPP_CORE_EXPORT TimeWindowQuantiles {
using Clock = std::chrono::steady_clock;

public:
Expand Down
4 changes: 2 additions & 2 deletions core/include/prometheus/detail/utils.h
Expand Up @@ -4,7 +4,7 @@
#include <map>
#include <string>

#include "prometheus/detail/visibility.h"
#include "prometheus/detail/core_export.h"

namespace prometheus {

Expand All @@ -15,7 +15,7 @@ namespace detail {
/// \param labels The map that will be computed the hash value.
///
/// \returns The hash value of the given labels.
PROMETHEUSCPP_API std::size_t hash_labels(
PROMETHEUS_CPP_CORE_EXPORT std::size_t hash_labels(
const std::map<std::string, std::string>& labels);

} // namespace detail
Expand Down
9 changes: 0 additions & 9 deletions core/include/prometheus/detail/visibility.h

This file was deleted.

4 changes: 2 additions & 2 deletions core/include/prometheus/family.h
Expand Up @@ -15,9 +15,9 @@
#include "prometheus/check_names.h"
#include "prometheus/client_metric.h"
#include "prometheus/collectable.h"
#include "prometheus/detail/core_export.h"
#include "prometheus/detail/future_std.h"
#include "prometheus/detail/utils.h"
#include "prometheus/detail/visibility.h"
#include "prometheus/metric_family.h"

namespace prometheus {
Expand Down Expand Up @@ -59,7 +59,7 @@ namespace prometheus {
///
/// \tparam T One of the metric types Counter, Gauge, Histogram or Summary.
template <typename T>
class PROMETHEUSCPP_API Family : public Collectable {
class PROMETHEUS_CPP_CORE_EXPORT Family : public Collectable {
public:
/// \brief Create a new metric.
///
Expand Down
6 changes: 3 additions & 3 deletions core/include/prometheus/gauge.h
Expand Up @@ -3,8 +3,8 @@
#include <atomic>

#include "prometheus/client_metric.h"
#include "prometheus/detail/core_export.h"
#include "prometheus/detail/gauge_builder.h"
#include "prometheus/detail/visibility.h"
#include "prometheus/metric_type.h"

namespace prometheus {
Expand All @@ -21,7 +21,7 @@ namespace prometheus {
///
/// The class is thread-safe. No concurrent call to any API of this type causes
/// a data race.
class PROMETHEUSCPP_API Gauge {
class PROMETHEUS_CPP_CORE_EXPORT Gauge {
public:
static const MetricType metric_type{MetricType::Gauge};

Expand Down Expand Up @@ -89,6 +89,6 @@ class PROMETHEUSCPP_API Gauge {
///
/// To finish the configuration of the Gauge metric register it with
/// Register(Registry&).
PROMETHEUSCPP_API detail::GaugeBuilder BuildGauge();
PROMETHEUS_CPP_CORE_EXPORT detail::GaugeBuilder BuildGauge();

} // namespace prometheus
6 changes: 3 additions & 3 deletions core/include/prometheus/histogram.h
Expand Up @@ -4,8 +4,8 @@

#include "prometheus/client_metric.h"
#include "prometheus/counter.h"
#include "prometheus/detail/core_export.h"
#include "prometheus/detail/histogram_builder.h"
#include "prometheus/detail/visibility.h"
#include "prometheus/metric_type.h"

namespace prometheus {
Expand All @@ -26,7 +26,7 @@ namespace prometheus {
///
/// The class is thread-safe. No concurrent call to any API of this type causes
/// a data race.
class PROMETHEUSCPP_API Histogram {
class PROMETHEUS_CPP_CORE_EXPORT Histogram {
public:
using BucketBoundaries = std::vector<double>;

Expand Down Expand Up @@ -90,6 +90,6 @@ class PROMETHEUSCPP_API Histogram {
///
/// To finish the configuration of the Histogram metric register it with
/// Register(Registry&).
PROMETHEUSCPP_API detail::HistogramBuilder BuildHistogram();
PROMETHEUS_CPP_CORE_EXPORT detail::HistogramBuilder BuildHistogram();

} // namespace prometheus
4 changes: 2 additions & 2 deletions core/include/prometheus/metric_family.h
Expand Up @@ -4,12 +4,12 @@
#include <vector>

#include "prometheus/client_metric.h"
#include "prometheus/detail/visibility.h"
#include "prometheus/detail/core_export.h"
#include "prometheus/metric_type.h"

namespace prometheus {

struct PROMETHEUSCPP_API MetricFamily {
struct PROMETHEUS_CPP_CORE_EXPORT MetricFamily {
std::string name;
std::string help;
MetricType type = MetricType::Untyped;
Expand Down
4 changes: 2 additions & 2 deletions core/include/prometheus/registry.h
Expand Up @@ -8,12 +8,12 @@

#include "prometheus/collectable.h"
#include "prometheus/counter.h"
#include "prometheus/detail/core_export.h"
#include "prometheus/detail/counter_builder.h"
#include "prometheus/detail/future_std.h"
#include "prometheus/detail/gauge_builder.h"
#include "prometheus/detail/histogram_builder.h"
#include "prometheus/detail/summary_builder.h"
#include "prometheus/detail/visibility.h"
#include "prometheus/family.h"
#include "prometheus/gauge.h"
#include "prometheus/histogram.h"
Expand All @@ -35,7 +35,7 @@ namespace prometheus {
///
/// The class is thread-safe. No concurrent call to any API of this type causes
/// a data race.
class PROMETHEUSCPP_API Registry : public Collectable {
class PROMETHEUS_CPP_CORE_EXPORT Registry : public Collectable {
public:
/// \brief Returns a list of metrics and their samples.
///
Expand Down
4 changes: 2 additions & 2 deletions core/include/prometheus/serializer.h
Expand Up @@ -4,12 +4,12 @@
#include <string>
#include <vector>

#include "prometheus/detail/visibility.h"
#include "prometheus/detail/core_export.h"
#include "prometheus/metric_family.h"

namespace prometheus {

class PROMETHEUSCPP_API Serializer {
class PROMETHEUS_CPP_CORE_EXPORT Serializer {
public:
virtual ~Serializer() = default;
virtual std::string Serialize(const std::vector<MetricFamily>&) const;
Expand Down
6 changes: 3 additions & 3 deletions core/include/prometheus/summary.h
Expand Up @@ -7,9 +7,9 @@

#include "prometheus/client_metric.h"
#include "prometheus/detail/ckms_quantiles.h"
#include "prometheus/detail/core_export.h"
#include "prometheus/detail/summary_builder.h"
#include "prometheus/detail/time_window_quantiles.h"
#include "prometheus/detail/visibility.h"
#include "prometheus/metric_type.h"

namespace prometheus {
Expand Down Expand Up @@ -38,7 +38,7 @@ namespace prometheus {
///
/// The class is thread-safe. No concurrent call to any API of this type causes
/// a data race.
class PROMETHEUSCPP_API Summary {
class PROMETHEUS_CPP_CORE_EXPORT Summary {
public:
using Quantiles = std::vector<detail::CKMSQuantiles::Quantile>;

Expand Down Expand Up @@ -118,6 +118,6 @@ class PROMETHEUSCPP_API Summary {
///
/// To finish the configuration of the Summary metric register it with
/// Register(Registry&).
PROMETHEUSCPP_API detail::SummaryBuilder BuildSummary();
PROMETHEUS_CPP_CORE_EXPORT detail::SummaryBuilder BuildSummary();

} // namespace prometheus

0 comments on commit eb9479c

Please sign in to comment.