Skip to content

Commit

Permalink
Rough version of dll support for opentelemetry-cpp. Add to each class…
Browse files Browse the repository at this point in the history
… OPENTELEMETRY_API=__declspec(dllexport). Fix cases wher holders of unique_ptr need deleted default copy-constructors, also add missing default constructors too. Still wrong as even when importing (dllimport) it's still doing dllexport, hence the singleton_test fails. Also prometheus tests fail too fails, and the variant one (?)
  • Loading branch information
malkia committed Jan 11, 2023
1 parent cb5e7b4 commit b9c1df7
Show file tree
Hide file tree
Showing 237 changed files with 448 additions and 406 deletions.
10 changes: 9 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
# Based on https://github.com/bazelment/trunk/blob/master/tools/bazel.rc

# Needed by gRPC to build on some platforms.
build --copt -DGRPC_BAZEL_BUILD
build --strip=never --cxxopt="-std:c++17" --host_cxxopt="-std:c++17"
build --action_env=BAZEL_VC_FULL_VERSION=14.29.30133
build --action_env=BAZEL_VC="C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC"
build --action_env=_CL_="/Z7 /guard:cf /Brepro /DOPENTELEMETRY_API=__declspec(dllexport) /DHAVE_CPP_STDLIB=1"
build --action_env=_LINK_="/guard:cf /CETCOMPAT /DEBUG:FULL /FUNCTIONPADMIN /SWAPRUN:NET,CD /Brepro /DEBUGTYPE:CV,PDATA,FIXUP"
build --host_action_env=BAZEL_VC_FULL_VERSION=14.29.30133
build --host_action_env=BAZEL_VC="C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC"
build --host_action_env=_CL_="/Z7 /guard:cf /Brepro /DOPENTELEMETRY_API=__declspec(dllexport) /DHAVE_CPP_STDLIB=1"
build --host_action_env=_LINK_="/guard:cf /CETCOMPAT /DEBUG:FULL /FUNCTIONPADMIN /SWAPRUN:NET,CD /Brepro /DEBUGTYPE:CV,PDATA,FIXUP"

# --config=asan : Address Sanitizer.
common:asan --copt -DADDRESS_SANITIZER
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/baggage/baggage.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ OPENTELEMETRY_BEGIN_NAMESPACE
namespace baggage
{

class Baggage
class OPENTELEMETRY_API Baggage
{
public:
static constexpr size_t kMaxKeyValuePairs = 180;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace baggage
namespace propagation
{

class BaggagePropagator : public opentelemetry::context::propagation::TextMapPropagator
class OPENTELEMETRY_API BaggagePropagator : public opentelemetry::context::propagation::TextMapPropagator
{
public:
void Inject(opentelemetry::context::propagation::TextMapCarrier &carrier,
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/common/key_value_iterable.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace common
/**
* Supports internal iteration over a collection of key-value pairs.
*/
class KeyValueIterable
class OPENTELEMETRY_API KeyValueIterable
{
public:
virtual ~KeyValueIterable() = default;
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/common/key_value_iterable_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct is_key_value_iterable
* 'non-standard' type to one of the standard types.
*/
template <class T>
class KeyValueIterableView final : public KeyValueIterable
class OPENTELEMETRY_API KeyValueIterableView final : public KeyValueIterable
{

public:
Expand Down
4 changes: 2 additions & 2 deletions api/include/opentelemetry/common/kv_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct KeyValueStringTokenizerOptions
};

// Tokenizer for key-value headers
class KeyValueStringTokenizer
class OPENTELEMETRY_API KeyValueStringTokenizer
{
public:
KeyValueStringTokenizer(
Expand Down Expand Up @@ -134,7 +134,7 @@ class KeyValueStringTokenizer
};

// Class to store fixed size array of key-value pairs of string type
class KeyValueProperties
class OPENTELEMETRY_API KeyValueProperties
{
// Class to store key-value pairs of string types
public:
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/common/spin_lock_mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ constexpr int SPINLOCK_SLEEP_MS = 1;
* This class implements the `BasicLockable` specification:
* https://en.cppreference.com/w/cpp/named_req/BasicLockable
*/
class SpinLockMutex
class OPENTELEMETRY_API SpinLockMutex
{
public:
SpinLockMutex() noexcept {}
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/common/string_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ OPENTELEMETRY_BEGIN_NAMESPACE
namespace common
{

class StringUtil
class OPENTELEMETRY_API StringUtil
{
public:
static nostd::string_view Trim(nostd::string_view str, size_t left, size_t right) noexcept
Expand Down
6 changes: 3 additions & 3 deletions api/include/opentelemetry/common/timestamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace common
*
* This is used for marking the beginning and end of an operation.
*/
class SystemTimestamp
class OPENTELEMETRY_API SystemTimestamp
{
public:
/**
Expand Down Expand Up @@ -96,7 +96,7 @@ class SystemTimestamp
*
* This is used for calculating the duration of an operation.
*/
class SteadyTimestamp
class OPENTELEMETRY_API SteadyTimestamp
{
public:
/**
Expand Down Expand Up @@ -170,7 +170,7 @@ class SteadyTimestamp
int64_t nanos_since_epoch_;
};

class DurationUtil
class OPENTELEMETRY_API DurationUtil
{
public:
template <class Rep, class Period>
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/context/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace context
// of DataList nodes and each context holds a shared_ptr to a place within
// the list that determines which keys and values it has access to. All that
// come before and none that come after.
class Context
class OPENTELEMETRY_API Context
{

public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ namespace context
namespace propagation
{

class CompositePropagator : public TextMapPropagator
class OPENTELEMETRY_API CompositePropagator : public TextMapPropagator
{
public:
CompositePropagator(std::vector<std::unique_ptr<TextMapPropagator>> propagators)
: propagators_(std::move(propagators))
{}

// https://stackoverflow.com/a/51033485/743263
CompositePropagator(const CompositePropagator &) = delete;
CompositePropagator &operator=(const CompositePropagator &) = delete;

/**
* Run each of the configured propagators with the given context and carrier.
* Propagators are run in the order they are configured, so if multiple
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace propagation

/* Stores the singleton TextMapPropagator */

class GlobalTextMapPropagator
class OPENTELEMETRY_API GlobalTextMapPropagator
{
public:
static nostd::shared_ptr<TextMapPropagator> GetGlobalPropagator() noexcept
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace propagation
/**
* No-op implementation TextMapPropagator
*/
class NoOpPropagator : public TextMapPropagator
class OPENTELEMETRY_API NoOpPropagator : public TextMapPropagator
{
public:
/** Noop extract function does nothing and returns the input context */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace propagation
{

// TextMapCarrier is the storage medium used by TextMapPropagator.
class TextMapCarrier
class OPENTELEMETRY_API TextMapCarrier
{
public:
// returns the value associated with the passed key.
Expand All @@ -39,7 +39,7 @@ class TextMapCarrier
// headers, and a getter and setter function for the extraction and
// injection of values, respectively.

class TextMapPropagator
class OPENTELEMETRY_API TextMapPropagator
{
public:
// Returns the context that is stored in the carrier with the TextMapCarrier as extractor.
Expand Down
8 changes: 4 additions & 4 deletions api/include/opentelemetry/context/runtime_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace context
// RuntimeContext object and is associated with a context object, and
// can be provided to the RuntimeContext Detach method to remove the
// associated context from the RuntimeContext.
class Token
class OPENTELEMETRY_API Token
{
public:
bool operator==(const Context &other) const noexcept { return context_ == other; }
Expand All @@ -37,7 +37,7 @@ class Token
* this class and passing an initialized RuntimeContextStorage object to
* RuntimeContext::SetRuntimeContextStorage.
*/
class RuntimeContextStorage
class OPENTELEMETRY_API RuntimeContextStorage
{
public:
/**
Expand Down Expand Up @@ -78,7 +78,7 @@ static RuntimeContextStorage *GetDefaultStorage() noexcept;
// Provides a wrapper for propagating the context object globally.
//
// By default, a thread-local runtime context storage is used.
class RuntimeContext
class OPENTELEMETRY_API RuntimeContext
{
public:
// Return the current context.
Expand Down Expand Up @@ -183,7 +183,7 @@ inline Token::~Token() noexcept
// RuntimeContextStorage and provides a wrapper for propagating context through
// cpp thread locally. This file must be included to use the RuntimeContext
// class if another implementation has not been registered.
class ThreadLocalContextStorage : public RuntimeContextStorage
class OPENTELEMETRY_API ThreadLocalContextStorage : public RuntimeContextStorage
{
public:
ThreadLocalContextStorage() noexcept = default;
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/logs/log_record.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace logs
*
* This class is thread-compatible.
*/
class LogRecord
class OPENTELEMETRY_API LogRecord
{
public:
virtual ~LogRecord() = default;
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/logs/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace logs
/**
* Handles log record creation.
**/
class Logger
class OPENTELEMETRY_API Logger
{
public:
virtual ~Logger() = default;
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/logs/logger_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace logs
/**
* Creates new Logger instances.
*/
class LoggerProvider
class OPENTELEMETRY_API LoggerProvider
{
public:
virtual ~LoggerProvider() = default;
Expand Down
4 changes: 2 additions & 2 deletions api/include/opentelemetry/logs/noop.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace logs
* No-op implementation of Logger. This class should not be used directly. It should only be
* instantiated using a LoggerProvider's GetLogger() call.
*/
class NoopLogger final : public Logger
class OPENTELEMETRY_API NoopLogger final : public Logger
{
public:
const nostd::string_view GetName() noexcept override { return "noop logger"; }
Expand All @@ -51,7 +51,7 @@ class NoopLogger final : public Logger
/**
* No-op implementation of a LoggerProvider.
*/
class NoopLoggerProvider final : public opentelemetry::logs::LoggerProvider
class OPENTELEMETRY_API NoopLoggerProvider final : public opentelemetry::logs::LoggerProvider
{
public:
NoopLoggerProvider()
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/logs/provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace logs
/**
* Stores the singleton global LoggerProvider.
*/
class Provider
class OPENTELEMETRY_API Provider
{
public:
/**
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/metrics/async_instruments.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace metrics

using ObservableCallbackPtr = void (*)(ObserverResult, void *);

class ObservableInstrument
class OPENTELEMETRY_API ObservableInstrument
{
public:
ObservableInstrument() = default;
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/metrics/meter.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace metrics
* measurements from all instruments.
*
*/
class Meter
class OPENTELEMETRY_API Meter
{
public:
virtual ~Meter() = default;
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/metrics/meter_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace metrics
/**
* Creates new Meter instances.
*/
class MeterProvider
class OPENTELEMETRY_API MeterProvider
{
public:
virtual ~MeterProvider() = default;
Expand Down
12 changes: 6 additions & 6 deletions api/include/opentelemetry/metrics/noop.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace metrics
{

template <class T>
class NoopCounter : public Counter<T>
class OPENTELEMETRY_API NoopCounter : public Counter<T>
{
public:
NoopCounter(nostd::string_view /* name */,
Expand All @@ -33,7 +33,7 @@ class NoopCounter : public Counter<T>
};

template <class T>
class NoopHistogram : public Histogram<T>
class OPENTELEMETRY_API NoopHistogram : public Histogram<T>
{
public:
NoopHistogram(nostd::string_view /* name */,
Expand All @@ -50,7 +50,7 @@ class NoopHistogram : public Histogram<T>
};

template <class T>
class NoopUpDownCounter : public UpDownCounter<T>
class OPENTELEMETRY_API NoopUpDownCounter : public UpDownCounter<T>
{
public:
NoopUpDownCounter(nostd::string_view /* name */,
Expand All @@ -68,7 +68,7 @@ class NoopUpDownCounter : public UpDownCounter<T>
{}
};

class NoopObservableInstrument : public ObservableInstrument
class OPENTELEMETRY_API NoopObservableInstrument : public ObservableInstrument
{
public:
NoopObservableInstrument(nostd::string_view /* name */,
Expand All @@ -83,7 +83,7 @@ class NoopObservableInstrument : public ObservableInstrument
/**
* No-op implementation of Meter.
*/
class NoopMeter final : public Meter
class OPENTELEMETRY_API NoopMeter final : public Meter
{
public:
nostd::unique_ptr<Counter<uint64_t>> CreateUInt64Counter(
Expand Down Expand Up @@ -195,7 +195,7 @@ class NoopMeter final : public Meter
/**
* No-op implementation of a MeterProvider.
*/
class NoopMeterProvider final : public MeterProvider
class OPENTELEMETRY_API NoopMeterProvider final : public MeterProvider
{
public:
NoopMeterProvider() : meter_{nostd::shared_ptr<Meter>(new NoopMeter)} {}
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/metrics/observer_result.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace metrics
* instrument use.
*/
template <class T>
class ObserverResultT
class OPENTELEMETRY_API ObserverResultT
{

public:
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/metrics/provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace metrics
/**
* Stores the singleton global MeterProvider.
*/
class Provider
class OPENTELEMETRY_API Provider
{
public:
/**
Expand Down
Loading

0 comments on commit b9c1df7

Please sign in to comment.