Skip to content

Commit

Permalink
Merge eb9479c into d83dd68
Browse files Browse the repository at this point in the history
  • Loading branch information
gjasny committed Aug 3, 2019
2 parents d83dd68 + eb9479c commit 6c1870b
Show file tree
Hide file tree
Showing 25 changed files with 105 additions and 33 deletions.
10 changes: 9 additions & 1 deletion CMakeLists.txt
@@ -1,8 +1,9 @@

cmake_minimum_required(VERSION 3.5 FATAL_ERROR)

project(prometheus-cpp)
project(prometheus-cpp VERSION 0.8.0)

include(GenerateExportHeader)
include(GNUInstallDirs)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
Expand All @@ -20,6 +21,13 @@ if(OVERRIDE_CXX_STANDARD_FLAGS)
set(CMAKE_CXX_EXTENSIONS Off)
endif()

# Hide things by default for shared libraries
if(BUILD_SHARED_LIBS)
set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN YES)
endif()

set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads)

Expand Down
15 changes: 13 additions & 2 deletions 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,9 +33,15 @@ 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 PROPERTIES OUTPUT_NAME ${PROJECT_NAME}-core)
set_target_properties(core
PROPERTIES
OUTPUT_NAME ${PROJECT_NAME}-core
VERSION "${PROJECT_VERSION}"
SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
)

install(
TARGETS core
Expand All @@ -42,7 +53,7 @@ install(
)

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

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

#include <string>

#include "prometheus/detail/core_export.h"

namespace prometheus {

bool CheckMetricName(const std::string& name);
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: 3 additions & 1 deletion core/include/prometheus/client_metric.h
Expand Up @@ -5,9 +5,11 @@
#include <tuple>
#include <vector>

#include "prometheus/detail/core_export.h"

namespace prometheus {

struct ClientMetric {
struct PROMETHEUS_CPP_CORE_EXPORT ClientMetric {
// Label

struct Label {
Expand Down
4 changes: 3 additions & 1 deletion core/include/prometheus/collectable.h
Expand Up @@ -2,6 +2,8 @@

#include <vector>

#include "prometheus/detail/core_export.h"

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

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

#include "prometheus/client_metric.h"
#include "prometheus/detail/core_export.h"
#include "prometheus/detail/counter_builder.h"
#include "prometheus/gauge.h"
#include "prometheus/metric_type.h"
Expand All @@ -22,7 +23,7 @@ namespace prometheus {
///
/// The class is thread-safe. No concurrent call to any API of this type causes
/// a data race.
class Counter {
class PROMETHEUS_CPP_CORE_EXPORT Counter {
public:
static const MetricType metric_type{MetricType::Counter};

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

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

#include "prometheus/detail/core_export.h"

namespace prometheus {
namespace detail {

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

#include "prometheus/detail/core_export.h"

namespace prometheus {

template <typename T>
Expand All @@ -12,7 +14,7 @@ class Registry;

namespace detail {

class 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: 3 additions & 1 deletion core/include/prometheus/detail/gauge_builder.h
Expand Up @@ -3,6 +3,8 @@
#include <map>
#include <string>

#include "prometheus/detail/core_export.h"

namespace prometheus {

template <typename T>
Expand All @@ -12,7 +14,7 @@ class Registry;

namespace detail {

class 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: 3 additions & 1 deletion core/include/prometheus/detail/histogram_builder.h
Expand Up @@ -3,6 +3,8 @@
#include <map>
#include <string>

#include "prometheus/detail/core_export.h"

namespace prometheus {

template <typename T>
Expand All @@ -12,7 +14,7 @@ class Registry;

namespace detail {

class 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: 3 additions & 1 deletion core/include/prometheus/detail/summary_builder.h
Expand Up @@ -3,6 +3,8 @@
#include <map>
#include <string>

#include "prometheus/detail/core_export.h"

namespace prometheus {

template <typename T>
Expand All @@ -12,7 +14,7 @@ class Registry;

namespace detail {

class 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
3 changes: 2 additions & 1 deletion core/include/prometheus/detail/time_window_quantiles.h
Expand Up @@ -5,11 +5,12 @@
#include <vector>

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

namespace prometheus {
namespace detail {

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

public:
Expand Down
5 changes: 4 additions & 1 deletion core/include/prometheus/detail/utils.h
Expand Up @@ -4,6 +4,8 @@
#include <map>
#include <string>

#include "prometheus/detail/core_export.h"

namespace prometheus {

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

} // namespace detail

Expand Down
3 changes: 2 additions & 1 deletion core/include/prometheus/family.h
Expand Up @@ -15,6 +15,7 @@
#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/metric_family.h"
Expand Down Expand Up @@ -58,7 +59,7 @@ namespace prometheus {
///
/// \tparam T One of the metric types Counter, Gauge, Histogram or Summary.
template <typename T>
class Family : public Collectable {
class PROMETHEUS_CPP_CORE_EXPORT Family : public Collectable {
public:
/// \brief Create a new metric.
///
Expand Down
5 changes: 3 additions & 2 deletions core/include/prometheus/gauge.h
Expand Up @@ -3,6 +3,7 @@
#include <atomic>

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

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

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

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

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

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

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

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

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

namespace prometheus {

struct MetricFamily {
struct PROMETHEUS_CPP_CORE_EXPORT MetricFamily {
std::string name;
std::string help;
MetricType type = MetricType::Untyped;
Expand Down
3 changes: 2 additions & 1 deletion core/include/prometheus/registry.h
Expand Up @@ -8,6 +8,7 @@

#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"
Expand All @@ -34,7 +35,7 @@ namespace prometheus {
///
/// The class is thread-safe. No concurrent call to any API of this type causes
/// a data race.
class Registry : public Collectable {
class PROMETHEUS_CPP_CORE_EXPORT Registry : public Collectable {
public:
/// \brief Returns a list of metrics and their samples.
///
Expand Down
3 changes: 2 additions & 1 deletion core/include/prometheus/serializer.h
Expand Up @@ -4,11 +4,12 @@
#include <string>
#include <vector>

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

namespace prometheus {

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

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

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

} // namespace prometheus

0 comments on commit 6c1870b

Please sign in to comment.