Skip to content

Commit

Permalink
[Metrics SDK] Implement Forceflush for Periodic Metric Reader (open-t…
Browse files Browse the repository at this point in the history
  • Loading branch information
lalitb authored and Pasaoglu, Cengizhan (DI FA CTR SVC PRC3) committed Mar 28, 2023
1 parent bd7a3c7 commit a1efe35
Show file tree
Hide file tree
Showing 222 changed files with 902 additions and 455 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,16 @@ tags

# Temporary dir used when generating semconv
./buildscripts/semantic-convention/opentelemetry-specification

# Generated Windows files or directories
*.vcxproj
*.vcxproj.filters
*.sln

# CMake generated files or directories
**/CMakeFiles
**/cmake_install.cmake
**/CTestTestfile.cmake
CMakeCache.txt
DartConfiguration.tcl
/cmake
3 changes: 1 addition & 2 deletions api/include/opentelemetry/common/kv_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "opentelemetry/common/key_value_iterable_view.h"
#include "opentelemetry/common/string_util.h"
#include "opentelemetry/nostd/function_ref.h"
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/nostd/unique_ptr.h"
#include "opentelemetry/version.h"
Expand Down Expand Up @@ -159,7 +158,7 @@ class KeyValueProperties
}

// Move contructor and assignment operator
Entry(Entry &&other) = default;
Entry(Entry &&other) = default;
Entry &operator=(Entry &&other) = default;

// Creates an Entry for a given key-value pair.
Expand Down
4 changes: 1 addition & 3 deletions api/include/opentelemetry/common/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
// GCC 9 has likely attribute but do not support declare it at the beginning of statement
# if defined(__has_cpp_attribute) && (defined(__clang__) || !defined(__GNUC__) || __GNUC__ > 9)
# if __has_cpp_attribute(likely)
# define OPENTELEMETRY_LIKELY_IF(...) \
if (__VA_ARGS__) \
[[likely]]
# define OPENTELEMETRY_LIKELY_IF(...) if (__VA_ARGS__) [[likely]]
# endif
# endif
#endif
Expand Down
11 changes: 7 additions & 4 deletions api/include/opentelemetry/common/spin_lock_mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ class SpinLockMutex
{
public:
SpinLockMutex() noexcept {}
~SpinLockMutex() noexcept = default;
SpinLockMutex(const SpinLockMutex &) = delete;
SpinLockMutex &operator=(const SpinLockMutex &) = delete;
~SpinLockMutex() noexcept = default;
SpinLockMutex(const SpinLockMutex &) = delete;
SpinLockMutex &operator=(const SpinLockMutex &) = delete;
SpinLockMutex &operator=(const SpinLockMutex &) volatile = delete;

static inline void fast_yield() noexcept
Expand Down Expand Up @@ -125,7 +125,10 @@ class SpinLockMutex
return;
}
/** Releases the lock held by the execution agent. Throws no exceptions. */
void unlock() noexcept { flag_.store(false, std::memory_order_release); }
void unlock() noexcept
{
flag_.store(false, std::memory_order_release);
}

private:
std::atomic<bool> flag_{false};
Expand Down
1 change: 1 addition & 0 deletions api/include/opentelemetry/common/string_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

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

OPENTELEMETRY_BEGIN_NAMESPACE
namespace common
Expand Down
1 change: 0 additions & 1 deletion api/include/opentelemetry/common/timestamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#pragma once

#include <algorithm>
#include <chrono>
#include <cstdint>

Expand Down
7 changes: 1 addition & 6 deletions api/include/opentelemetry/logs/event_logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,10 @@
#pragma once
#ifdef ENABLE_LOGS_PREVIEW

# include <chrono>
# include <map>
# include <vector>

# include "opentelemetry/common/macros.h"
# include "opentelemetry/logs/log_record.h"
# include "opentelemetry/logs/logger.h"
# include "opentelemetry/logs/logger_type_traits.h"
# include "opentelemetry/logs/severity.h"
# include "opentelemetry/nostd/shared_ptr.h"
# include "opentelemetry/nostd/string_view.h"
# include "opentelemetry/nostd/unique_ptr.h"
Expand Down Expand Up @@ -63,7 +58,7 @@ class EventLogger
* span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes)
*/
template <class... ArgumentType>
void EmitEvent(nostd::string_view event_name, ArgumentType &&... args)
void EmitEvent(nostd::string_view event_name, ArgumentType &&...args)
{
nostd::shared_ptr<Logger> delegate_logger = GetDelegateLogger();
if (!delegate_logger)
Expand Down
9 changes: 5 additions & 4 deletions api/include/opentelemetry/logs/event_logger_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
#pragma once
#ifdef ENABLE_LOGS_PREVIEW

# include "opentelemetry/common/key_value_iterable.h"
# include "opentelemetry/common/key_value_iterable_view.h"
# include "opentelemetry/logs/event_logger.h"
# include "opentelemetry/logs/logger.h"
# include "opentelemetry/nostd/shared_ptr.h"
# include "opentelemetry/nostd/string_view.h"
# include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace logs
{

class EventLogger;
class Logger;

/**
* Creates new EventLogger instances.
*/
Expand Down
11 changes: 7 additions & 4 deletions api/include/opentelemetry/logs/log_record.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@
#ifdef ENABLE_LOGS_PREVIEW

# include "opentelemetry/common/attribute_value.h"
# include "opentelemetry/common/key_value_iterable.h"
# include "opentelemetry/common/timestamp.h"
# include "opentelemetry/logs/severity.h"
# include "opentelemetry/trace/span_id.h"
# include "opentelemetry/trace/trace_flags.h"
# include "opentelemetry/trace/trace_id.h"
# include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace trace
{
class SpanId;
class TraceId;
class TraceFlags;
} // namespace trace

namespace logs
{
/**
Expand Down
20 changes: 11 additions & 9 deletions api/include/opentelemetry/logs/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#ifdef ENABLE_LOGS_PREVIEW

# include "opentelemetry/common/key_value_iterable.h"
# include "opentelemetry/logs/log_record.h"
# include "opentelemetry/logs/logger_type_traits.h"
# include "opentelemetry/logs/severity.h"
# include "opentelemetry/nostd/string_view.h"
Expand All @@ -15,6 +14,9 @@
OPENTELEMETRY_BEGIN_NAMESPACE
namespace logs
{

class LogRecord;

/**
* Handles log record creation.
**/
Expand Down Expand Up @@ -59,7 +61,7 @@ class Logger
* span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes)
*/
template <class... ArgumentType>
void EmitLogRecord(nostd::unique_ptr<LogRecord> &&log_record, ArgumentType &&... args)
void EmitLogRecord(nostd::unique_ptr<LogRecord> &&log_record, ArgumentType &&...args)
{
if (!log_record)
{
Expand Down Expand Up @@ -91,7 +93,7 @@ class Logger
* span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes)
*/
template <class... ArgumentType>
void EmitLogRecord(ArgumentType &&... args)
void EmitLogRecord(ArgumentType &&...args)
{
nostd::unique_ptr<LogRecord> log_record = CreateLogRecord();
if (!log_record)
Expand All @@ -118,7 +120,7 @@ class Logger
* span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes)
*/
template <class... ArgumentType>
void Trace(ArgumentType &&... args) noexcept
void Trace(ArgumentType &&...args) noexcept
{
static_assert(
!detail::LogRecordHasType<Severity, typename std::decay<ArgumentType>::type...>::value,
Expand All @@ -142,7 +144,7 @@ class Logger
* span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes)
*/
template <class... ArgumentType>
void Debug(ArgumentType &&... args) noexcept
void Debug(ArgumentType &&...args) noexcept
{
static_assert(
!detail::LogRecordHasType<Severity, typename std::decay<ArgumentType>::type...>::value,
Expand All @@ -166,7 +168,7 @@ class Logger
* span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes)
*/
template <class... ArgumentType>
void Info(ArgumentType &&... args) noexcept
void Info(ArgumentType &&...args) noexcept
{
static_assert(
!detail::LogRecordHasType<Severity, typename std::decay<ArgumentType>::type...>::value,
Expand All @@ -190,7 +192,7 @@ class Logger
* span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes)
*/
template <class... ArgumentType>
void Warn(ArgumentType &&... args) noexcept
void Warn(ArgumentType &&...args) noexcept
{
static_assert(
!detail::LogRecordHasType<Severity, typename std::decay<ArgumentType>::type...>::value,
Expand All @@ -214,7 +216,7 @@ class Logger
* span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes)
*/
template <class... ArgumentType>
void Error(ArgumentType &&... args) noexcept
void Error(ArgumentType &&...args) noexcept
{
static_assert(
!detail::LogRecordHasType<Severity, typename std::decay<ArgumentType>::type...>::value,
Expand All @@ -238,7 +240,7 @@ class Logger
* span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes)
*/
template <class... ArgumentType>
void Fatal(ArgumentType &&... args) noexcept
void Fatal(ArgumentType &&...args) noexcept
{
static_assert(
!detail::LogRecordHasType<Severity, typename std::decay<ArgumentType>::type...>::value,
Expand Down
2 changes: 2 additions & 0 deletions api/include/opentelemetry/logs/logger_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
# include "opentelemetry/common/key_value_iterable_view.h"
# include "opentelemetry/logs/logger.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 logs
Expand Down
3 changes: 0 additions & 3 deletions api/include/opentelemetry/logs/logger_type_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@
# include "opentelemetry/common/timestamp.h"
# include "opentelemetry/logs/log_record.h"
# include "opentelemetry/logs/severity.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/nostd/unique_ptr.h"
# include "opentelemetry/trace/span_context.h"
# include "opentelemetry/trace/span_id.h"
# include "opentelemetry/trace/trace_flags.h"
Expand Down
3 changes: 1 addition & 2 deletions api/include/opentelemetry/logs/noop.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# include "opentelemetry/common/key_value_iterable.h"
# include "opentelemetry/common/timestamp.h"
# include "opentelemetry/context/runtime_context.h"
# include "opentelemetry/logs/event_logger.h"
# include "opentelemetry/logs/event_logger_provider.h"
# include "opentelemetry/logs/logger.h"
# include "opentelemetry/logs/logger_provider.h"
Expand All @@ -28,8 +29,6 @@
# include "opentelemetry/trace/trace_id.h"
# include "opentelemetry/version.h"

# include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace logs
{
Expand Down
1 change: 1 addition & 0 deletions api/include/opentelemetry/metrics/async_instruments.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

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

OPENTELEMETRY_BEGIN_NAMESPACE
namespace metrics
Expand Down
14 changes: 11 additions & 3 deletions api/include/opentelemetry/metrics/meter.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,25 @@

#pragma once

#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
{
template <class T>
class Counter;

template <class T>
class Histogram;

template <class T>
class UpDownCounter;

class ObservableInstrument;

/**
* Handles instrument creation and provides a facility for batch recording.
*
Expand Down
5 changes: 4 additions & 1 deletion api/include/opentelemetry/metrics/meter_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@

#pragma once

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

OPENTELEMETRY_BEGIN_NAMESPACE
namespace metrics
{

class Meter;

/**
* Creates new Meter instances.
*/
Expand Down
2 changes: 2 additions & 0 deletions api/include/opentelemetry/metrics/observer_result.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "opentelemetry/nostd/span.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/nostd/type_traits.h"
#include "opentelemetry/nostd/variant.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace metrics
Expand Down
1 change: 0 additions & 1 deletion api/include/opentelemetry/metrics/provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#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"

Expand Down
7 changes: 5 additions & 2 deletions api/include/opentelemetry/nostd/detail/functional.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@

#include "opentelemetry/version.h"

#define OPENTELEMETRY_RETURN(...) \
noexcept(noexcept(__VA_ARGS__))->decltype(__VA_ARGS__) { return __VA_ARGS__; }
#define OPENTELEMETRY_RETURN(...) \
noexcept(noexcept(__VA_ARGS__))->decltype(__VA_ARGS__) \
{ \
return __VA_ARGS__; \
}

OPENTELEMETRY_BEGIN_NAMESPACE
namespace nostd
Expand Down
Loading

0 comments on commit a1efe35

Please sign in to comment.