Merge branch 'master' into maxgolov/cs4_support

This commit is contained in:
Max Golovanov 2020-01-31 18:56:39 -08:00 коммит произвёл GitHub
Родитель efa6a2d27a 1c3b666c5d
Коммит 915b4aa954
24 изменённых файлов: 244 добавлений и 57 удалений

53
.github/ISSUE_TEMPLATE/question.md поставляемый Normal file
Просмотреть файл

@ -0,0 +1,53 @@
---
name: Question
about: Create a question to help us improve our knowledgebase and documentation
labels: question
---
# Is your question about how to consume a C++ library?
Please refer to some of these handy resources first:
- [Consuming libraries and components](https://docs.microsoft.com/en-us/cpp/build/adding-references-in-visual-cpp-projects?view=vs-2019)
- [Consuming C++ libraries in UWP applications](https://docs.microsoft.com/en-us/cpp/porting/how-to-use-existing-cpp-code-in-a-universal-windows-platform-app?view=vs-2019)
- [Creating and using a static library](https://docs.microsoft.com/en-us/cpp/build/walkthrough-creating-and-using-a-static-library-cpp?view=vs-2019)
- [How to create a native C++ code nuget package](https://docs.microsoft.com/en-us/nuget/guides/native-packages)
- [Using cmake projects in Visual Studio](https://docs.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio?view=vs-2019)
# Is your question about specific 1DS SDK APIs or Features?
Please check if you can find the answer by following these three steps below:
## Step 1. Check our SDK Doxygen documentation
You can generate the SDK HTML classes documentation [using this script](https://github.com/microsoft/cpp_client_telemetry/blob/master/tools/gen-docs.cmd).
## Step 2. Check our Markdown documents collection
Documents describing various SDK features are [available here](https://github.com/microsoft/cpp_client_telemetry/tree/master/docs). We are not indexing that knowledge base yet. We will adopt the [docs.microsoft.com](http://docs.microsoft.com/) after 1DS SDK Project becomes Public OSS.
## Step 3. Learn by example
Clone the repo and search for clues in:
- [Examples directory](https://github.com/microsoft/cpp_client_telemetry/tree/master/examples)
- [API Functional tests](https://github.com/microsoft/cpp_client_telemetry/blob/master/tests/functests/APITest.cpp)
Both are good resources that showcase most of the SDK features and typical use-cases.
## If you have not found the answer in Doxygen docs, Markdown nor Examples...
Please:
- Describe your scenario.
- Describe your environment: SDK version, platform, OS version, compiler type, etc.
- Describe the focus area: transmission controls, offline storage, backend routing controls, reliability, performance, etc.
- Add any other additional context.
We will review your question during our weekly community meeting or sooner.
---
Additional channels for ad-hoc help:
- **1DS Questions** DL
- **1ds.sdk.cpp** Public Group
- **MS Teams chat**
If you get your answer via those additional ad-hoc support channels, then please consider contributing it back - share your knowledge as docs contribution in a Markdown format in this git repo.

Просмотреть файл

@ -141,7 +141,7 @@ endif()
set(SDK_VERSION_PREFIX "EVT")
add_definitions("-DMATSDK_VERSION_PREFIX=\"${SDK_VERSION_PREFIX}\"")
set(MATSDK_API_VERSION "3.2")
set(MATSDK_API_VERSION "3.3")
string(TIMESTAMP DAYNUMBER "%j")
string(REGEX REPLACE "^00" "" DAYNUMBER ${DAYNUMBER})
string(REGEX REPLACE "^0" "" DAYNUMBER ${DAYNUMBER})

Просмотреть файл

@ -901,7 +901,7 @@ Global
{39DBD601-4D79-49F9-AD18-065404DBA273}.Debug|ARM.ActiveCfg = Debug|ARM
{39DBD601-4D79-49F9-AD18-065404DBA273}.Debug|ARM.Build.0 = Debug|ARM
{39DBD601-4D79-49F9-AD18-065404DBA273}.Debug|ARM.Deploy.0 = Debug|ARM
{39DBD601-4D79-49F9-AD18-065404DBA273}.Debug|ARM64.ActiveCfg = Debug|Win32
{39DBD601-4D79-49F9-AD18-065404DBA273}.Debug|ARM64.ActiveCfg = Debug|ARM64
{39DBD601-4D79-49F9-AD18-065404DBA273}.Debug|Win32.ActiveCfg = Debug|Win32
{39DBD601-4D79-49F9-AD18-065404DBA273}.Debug|Win32.Build.0 = Debug|Win32
{39DBD601-4D79-49F9-AD18-065404DBA273}.Debug|Win32.Deploy.0 = Debug|Win32
@ -935,7 +935,8 @@ Global
{39DBD601-4D79-49F9-AD18-065404DBA273}.Release|ARM.ActiveCfg = Release|ARM
{39DBD601-4D79-49F9-AD18-065404DBA273}.Release|ARM.Build.0 = Release|ARM
{39DBD601-4D79-49F9-AD18-065404DBA273}.Release|ARM.Deploy.0 = Release|ARM
{39DBD601-4D79-49F9-AD18-065404DBA273}.Release|ARM64.ActiveCfg = Release|Win32
{39DBD601-4D79-49F9-AD18-065404DBA273}.Release|ARM64.ActiveCfg = Release|ARM64
{39DBD601-4D79-49F9-AD18-065404DBA273}.Release|ARM64.Build.0 = Release|ARM64
{39DBD601-4D79-49F9-AD18-065404DBA273}.Release|Win32.ActiveCfg = Release|Win32
{39DBD601-4D79-49F9-AD18-065404DBA273}.Release|Win32.Build.0 = Release|Win32
{39DBD601-4D79-49F9-AD18-065404DBA273}.Release|Win32.Deploy.0 = Release|Win32

Просмотреть файл

@ -0,0 +1,24 @@
# Offline storage configurations
There are several configurations that can alter the offline storage handler behaviour.
## Configurations
| Configuration | Type | Default value | Description |
| ------------- | ---- | ------------- | -------------|
| CFG_INT_CACHE_FILE_SIZE | int | 3145728 | Sets size limit for the cache file.
| CFG_INT_STORAGE_FULL_PCT | int | 75 | Sets the notification threshold (percentage) for storage full notifications. If the cache file size excceds CFG_INT_STORAGE_FULL_PCT percent, an EVT_STORAGE_FULL debug event will be fired.
| CFG_BOOL_ENABLE_DB_DROP_IF_FULL | bool | false | When set to true, trim events if cache size reaches CFG_INT_CACHE_FILE_SIZE
| CFG_STR_CACHE_FILE_PATH | string | %TEMP% | Sets the path for the cache file
## Deprecated configurations
| Configuration |
| ------------- |
| CFG_BOOL_ENABLE_DB_COMPRESS |
| CFG_BOOL_ENABLE_WAL_JOURNAL |
| CFG_INT_RAM_QUEUE_BUFFERS |
| CFG_STR_PRAGMA_JOURNAL_MODE |
| CFG_STR_PRAGMA_SYNCHRONOUS |

Просмотреть файл

@ -18,6 +18,10 @@
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
@ -30,6 +34,10 @@
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
@ -49,6 +57,11 @@
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
@ -66,6 +79,12 @@
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
@ -82,9 +101,15 @@
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
@ -101,10 +126,18 @@
<CodeAnalysisRuleSet>C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\Rule Sets\NativeRecommendedRules.ruleset</CodeAnalysisRuleSet>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<CodeAnalysisRuleSet>C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\Rule Sets\NativeRecommendedRules.ruleset</CodeAnalysisRuleSet>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<CodeAnalysisRuleSet>C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\Rule Sets\NativeRecommendedRules.ruleset</CodeAnalysisRuleSet>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<CodeAnalysisRuleSet>C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\Rule Sets\NativeRecommendedRules.ruleset</CodeAnalysisRuleSet>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<ClCompile>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
@ -117,6 +150,19 @@
<PrecompiledHeaderFile />
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<ClCompile>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(SolutionDir)\..\lib\include\public;$(ProjectDir);$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1;%(ClCompile.PreprocessorDefinitions)</PreprocessorDefinitions>
<CallingConvention>Cdecl</CallingConvention>
<EnablePREfast>true</EnablePREfast>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<ClCompile>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
@ -131,6 +177,21 @@
<PrecompiledHeaderFile />
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<ClCompile>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(SolutionDir)\..\lib\include\public;$(ProjectDir);$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1;%(ClCompile.PreprocessorDefinitions)</PreprocessorDefinitions>
<Optimization>MinSpace</Optimization>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<CallingConvention>Cdecl</CallingConvention>
<EnablePREfast>true</EnablePREfast>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>

Просмотреть файл

@ -16,6 +16,7 @@ namespace ARIASDK_NS_BEGIN {
{ CFG_INT_CACHE_FILE_SIZE, 3145728 },
{ CFG_INT_RAM_QUEUE_SIZE, 524288 },
{ CFG_BOOL_ENABLE_MULTITENANT, true },
{ CFG_BOOL_ENABLE_DB_DROP_IF_FULL, false },
{ CFG_INT_MAX_TEARDOWN_TIME, 0 },
{ CFG_INT_MAX_PENDING_REQ, 4 },
{ CFG_INT_RAM_QUEUE_BUFFERS, 3 },

Просмотреть файл

@ -97,9 +97,9 @@ namespace ARIASDK_NS_BEGIN
}
LogManagerImpl::LogManagerImpl(ILogConfiguration& configuration, bool deferSystemStart)
: m_bandwidthController(nullptr),
m_offlineStorage(nullptr),
m_logConfiguration(configuration)
: m_logConfiguration(configuration),
m_bandwidthController(nullptr),
m_offlineStorage(nullptr)
{
m_httpClient = std::static_pointer_cast<IHttpClient>(configuration.GetModule(CFG_MODULE_HTTP_CLIENT));
m_taskDispatcher = std::static_pointer_cast<ITaskDispatcher>(configuration.GetModule(CFG_MODULE_TASK_DISPATCHER));

Просмотреть файл

@ -9,21 +9,22 @@ namespace ARIASDK_NS_BEGIN {
static ILogConfiguration defaultRuntimeConfig
{
{ CFG_INT_TRACE_LEVEL_MIN, ACTTraceLevel::ACTTraceLevel_Error },
{ CFG_INT_SDK_MODE, SdkModeTypes::SdkModeTypes_CS },
{ CFG_BOOL_ENABLE_ANALYTICS, false },
{ CFG_INT_CACHE_FILE_SIZE, 3145728 },
{ CFG_INT_RAM_QUEUE_SIZE, 524288 },
{ CFG_BOOL_ENABLE_MULTITENANT, true },
{ CFG_INT_MAX_TEARDOWN_TIME, 1 },
{ CFG_INT_MAX_PENDING_REQ, 4 },
{ CFG_INT_RAM_QUEUE_BUFFERS, 3 },
{ CFG_INT_TRACE_LEVEL_MASK, 0 },
{ CFG_BOOL_ENABLE_TRACE, true },
{ CFG_STR_COLLECTOR_URL, COLLECTOR_URL_PROD },
{ CFG_INT_STORAGE_FULL_PCT, 75 },
{ CFG_INT_RAMCACHE_FULL_PCT, 75 },
{ CFG_BOOL_ENABLE_NET_DETECT, true },
{ CFG_INT_TRACE_LEVEL_MIN, ACTTraceLevel::ACTTraceLevel_Error },
{ CFG_INT_SDK_MODE, SdkModeTypes::SdkModeTypes_CS },
{ CFG_BOOL_ENABLE_ANALYTICS, false },
{ CFG_INT_CACHE_FILE_SIZE, 3145728 },
{ CFG_INT_RAM_QUEUE_SIZE, 524288 },
{ CFG_BOOL_ENABLE_MULTITENANT, true },
{ CFG_BOOL_ENABLE_DB_DROP_IF_FULL, false },
{ CFG_INT_MAX_TEARDOWN_TIME, 1 },
{ CFG_INT_MAX_PENDING_REQ, 4 },
{ CFG_INT_RAM_QUEUE_BUFFERS, 3 },
{ CFG_INT_TRACE_LEVEL_MASK, 0 },
{ CFG_BOOL_ENABLE_TRACE, true },
{ CFG_STR_COLLECTOR_URL, COLLECTOR_URL_PROD },
{ CFG_INT_STORAGE_FULL_PCT, 75 },
{ CFG_INT_RAMCACHE_FULL_PCT, 75 },
{ CFG_BOOL_ENABLE_NET_DETECT, true },
{ "stats",
{
/* Parameter that allows to split stats events by tenant */

Просмотреть файл

@ -23,7 +23,7 @@ namespace ARIASDK_NS_BEGIN
virtual bool Empty() const noexcept override;
protected:
std::atomic<size_t> m_size;
std::atomic<size_t> m_size { 0 };
mutable std::mutex m_filterLock;
std::vector<std::unique_ptr<IEventFilter>> m_filters;
};

Просмотреть файл

@ -27,7 +27,6 @@
#include "pal/PAL.hpp"
#define HTTP_CONN_TIMEOUT 5L
#define HTTP_READ_TIMEOUT 5L
#define HTTP_STATUS_REGEXP "HTTP\\/\\d\\.\\d (\\d+)\\ .*"
#define HTTP_HEADER_REGEXP "(.*)\\: (.*)\\n*"
@ -84,8 +83,7 @@ public:
const std::vector<uint8_t>& requestBody = std::vector<uint8_t>(),
// Default connectivity and response size options
bool rawResponse = false,
size_t httpConnTimeout = HTTP_CONN_TIMEOUT,
size_t httpReadTimeout = HTTP_READ_TIMEOUT) :
size_t httpConnTimeout = HTTP_CONN_TIMEOUT) :
//
m_method(method),
@ -98,7 +96,6 @@ public:
// Optional connection params
rawResponse(rawResponse),
httpConnTimeout(httpConnTimeout),
httpReadTimeout(httpReadTimeout),
// Result
res(CURLE_OK),
sockfd(0),
@ -257,7 +254,8 @@ public:
goto cleanup;
}
curl_easy_setopt(curl, CURLOPT_TIMEOUT, httpReadTimeout);
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 30L);
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 4096);
DispatchEvent(OnSending);
res = curl_easy_perform(curl);
if(CURLE_OK != res)
@ -405,7 +403,6 @@ cleanup:
protected:
const bool rawResponse; // Do not split response headers from response body
const size_t httpConnTimeout; // Timeout for connect. Default: 5s
const size_t httpReadTimeout; // Timeout for read. Default: 5s
CURL *curl; // Local curl instance
CURLcode res; // Curl result OR HTTP status code if successful

Просмотреть файл

@ -82,6 +82,11 @@ namespace ARIASDK_NS_BEGIN
/// </summary>
static constexpr const char* const CFG_BOOL_ENABLE_HMAC = "enableHMAC";
/// <summary>
/// Enable dropping events if DB file size exceeds its limit.
/// </summary>
static constexpr const char* const CFG_BOOL_ENABLE_DB_DROP_IF_FULL = "enableDbDropIfFull";
/// <summary>
/// Enable database compression.
/// </summary>

Просмотреть файл

@ -8,9 +8,9 @@ namespace ARIASDK_NS_BEGIN {
MATSDK_LOG_INST_COMPONENT_CLASS(MemoryStorage, "EventsSDK.MemoryStorage", "Events telemetry client - MemoryStorage class");
MemoryStorage::MemoryStorage(ILogManager & logManager, IRuntimeConfig & runtimeConfig) :
m_observer(nullptr),
m_config(runtimeConfig),
m_logManager(logManager),
m_observer(nullptr),
m_size(0),
m_lastReadCount(0)
{

Просмотреть файл

@ -24,6 +24,7 @@ namespace ARIASDK_NS_BEGIN {
m_taskDispatcher(taskDispatcher),
m_killSwitchManager(),
m_clockSkewManager(),
m_flushPending(false),
m_offlineStorageMemory(nullptr),
m_offlineStorageDisk(nullptr),
m_readFromMemory(false),
@ -31,8 +32,7 @@ namespace ARIASDK_NS_BEGIN {
m_shutdownStarted(false),
m_memoryDbSize(0),
m_queryDbSize(0),
m_isStorageFullNotificationSend(false),
m_flushPending(false)
m_isStorageFullNotificationSend(false)
{
// FIXME: [MG] - this code seems redundant / suspicious because OfflineStorage_SQLite.cpp is doing the same thing...
uint32_t percentage = m_config[CFG_INT_RAMCACHE_FULL_PCT];

Просмотреть файл

@ -56,8 +56,8 @@ namespace ARIASDK_NS_BEGIN {
}
OfflineStorage_SQLite::OfflineStorage_SQLite(ILogManager & logManager, IRuntimeConfig& runtimeConfig, bool inMemory)
: m_logManager(logManager),
m_config(runtimeConfig)
: m_config(runtimeConfig)
, m_logManager(logManager)
{
uint32_t percentage = (inMemory) ? m_config[CFG_INT_RAMCACHE_FULL_PCT] : m_config[CFG_INT_STORAGE_FULL_PCT];
m_DbSizeLimit = (inMemory) ? static_cast<uint32_t>(m_config[CFG_INT_RAM_QUEUE_SIZE]) : static_cast<uint32_t>(m_config[CFG_INT_CACHE_FILE_SIZE]);
@ -168,7 +168,7 @@ namespace ARIASDK_NS_BEGIN {
m_DbSizeEstimate += record.id.size() + record.tenantToken.size() + record.blob.size();
}
if ((m_DbSizeLimit != 0) && (m_DbSizeEstimate>m_DbSizeLimit))
if ((m_DbSizeNotificationLimit != 0) && (m_DbSizeEstimate>m_DbSizeNotificationLimit))
{
auto now = PAL::getMonotonicTimeMs();
if (std::abs(static_cast<long>(now-m_isStorageFullNotificationSendTime)) > static_cast<long>(DB_FULL_CHECK_TIME_MS))
@ -183,6 +183,21 @@ namespace ARIASDK_NS_BEGIN {
}
}
if ((m_DbSizeLimit != 0) && (m_DbSizeEstimate > m_DbSizeLimit))
{
auto shouldResize = m_config[CFG_BOOL_ENABLE_DB_DROP_IF_FULL] && !m_resizing;
if (shouldResize)
{
LOCKGUARD(m_resizeLock); //Serialize resize operations
m_resizing = true;
if (m_DbSizeEstimate > m_DbSizeLimit)
{
ResizeDb();
}
m_resizing = false;
}
}
return true;
}
@ -775,14 +790,8 @@ namespace ARIASDK_NS_BEGIN {
return pageCount * m_pageSize;
}
size_t OfflineStorage_SQLite::GetRecordCount(EventLatency latency = EventLatency_Unspecified) const
size_t OfflineStorage_SQLite::GetRecordCountUnsafe(EventLatency latency) const
{
if (!m_db) {
LOG_ERROR("Failed to get DB size: database is not open");
return 0;
}
LOCKGUARD(m_lock);
int count = 0;
if (latency == EventLatency_Unspecified)
{
@ -801,6 +810,17 @@ namespace ARIASDK_NS_BEGIN {
return count;
}
size_t OfflineStorage_SQLite::GetRecordCount(EventLatency latency = EventLatency_Unspecified) const
{
if (!m_db) {
LOG_ERROR("Failed to get DB size: database is not open");
return 0;
}
LOCKGUARD(m_lock);
return OfflineStorage_SQLite::GetRecordCountUnsafe(latency);
}
bool OfflineStorage_SQLite::ResizeDb()
{
if (!m_db) {
@ -808,6 +828,7 @@ namespace ARIASDK_NS_BEGIN {
return false;
}
size_t eventsDropped = 0;
m_DbSizeEstimate = GetSize();
if (m_DbSizeEstimate <= m_DbSizeLimit)
return false;
@ -822,6 +843,7 @@ namespace ARIASDK_NS_BEGIN {
return false;
}
#endif
auto count = GetRecordCountUnsafe(EventLatency::EventLatency_Unspecified);
if (m_DbSizeEstimate > 2 * m_DbSizeLimit)
{
LOG_TRACE("DB is too big, deleting...");
@ -837,8 +859,17 @@ namespace ARIASDK_NS_BEGIN {
LOG_TRACE("Evict all non-critical");
Execute("DELETE FROM " TABLE_NAME_EVENTS " WHERE persistence=1");
}
eventsDropped = count - GetRecordCountUnsafe(EventLatency::EventLatency_Unspecified);
LOG_TRACE("Db resized, events dropeed: %d", eventsDropped);
trimStmt.reset();
}
m_DbSizeEstimate = GetSize();
DebugEvent evt(DebugEventType::EVT_DROPPED);
evt.param1 = eventsDropped;
evt.size = eventsDropped;
m_logManager.DispatchEvent(evt);
return true;
}

Просмотреть файл

@ -72,6 +72,9 @@ namespace ARIASDK_NS_BEGIN {
bool m_skipInitAndShutdown {};
bool m_isOpened {};
std::mutex m_resizeLock{};
std::atomic<bool> m_resizing{false};
size_t m_stmtBeginTransaction {};
size_t m_stmtCommitTransaction {};
size_t m_stmtRollbackTransaction {};
@ -98,11 +101,14 @@ namespace ARIASDK_NS_BEGIN {
unsigned m_DbSizeNotificationLimit {};
size_t m_DbSizeHeapLimit {};
size_t m_DbSizeLimit {};
size_t m_DbSizeEstimate {};
std::atomic<size_t> m_DbSizeEstimate {};
uint64_t m_isStorageFullNotificationSendTime {};
protected:
MATSDK_LOG_DECL_COMPONENT_CLASS();
private:
size_t GetRecordCountUnsafe(EventLatency latency) const;
};

Просмотреть файл

@ -10,11 +10,11 @@
namespace ARIASDK_NS_BEGIN {
Statistics::Statistics(ITelemetrySystem& telemetrySystem, ITaskDispatcher& taskDispatcher) :
m_metaStats(telemetrySystem.getConfig()),
m_iTelemetrySystem(telemetrySystem),
m_taskDispatcher(taskDispatcher),
m_logManager(telemetrySystem.getLogManager()),
m_metaStats(telemetrySystem.getConfig()),
m_config(telemetrySystem.getConfig()),
m_logManager(telemetrySystem.getLogManager()),
m_baseDecorator(m_logManager),
m_semanticContextDecorator(m_logManager),
m_isStarted(false)

Просмотреть файл

@ -10,11 +10,6 @@
namespace testing {
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4263) // Method does not override base function doesn't play nice with googlemock macros.
#pragma warning(disable:4264) // Method does not override base function doesn't play nice with googlemock macros.
#endif
class MockILogManagerInternal : public MAT::ILogManagerInternal
{
public:
@ -46,10 +41,9 @@ namespace testing {
MOCK_METHOD3(SetContext, MAT::status_t(const std::string&, bool, MAT::PiiKind));
MOCK_METHOD3(SetContext, MAT::status_t(const std::string&, MAT::time_ticks_t, MAT::PiiKind));
MOCK_METHOD3(SetContext, MAT::status_t(const std::string&, MAT::GUID_t, MAT::PiiKind));
using MAT::ILogManagerInternal::GetLogger;
MOCK_METHOD4(GetLogger, MAT::ILogger * (std::string const &, MAT::ContextFieldsProvider*, std::string const &, std::string const &));
MOCK_METHOD1(sendEvent, void(MAT::IncomingEventContextPtr const &));
};
#ifdef _MSC_VER
#pragma warning(pop)
#endif
} // namespace testing

Просмотреть файл

@ -12,7 +12,7 @@ class CompliantByDefaultEventFilterModuleTests : public CompliantByDefaultEventF
{
public:
CompliantByDefaultEventFilterModuleTests() noexcept
: m_logManager(m_logConfiguration, nullptr) { }
: m_logManager(m_logConfiguration, static_cast<bool>(nullptr)) { }
ILogConfiguration m_logConfiguration;
LogManagerImpl m_logManager;

Просмотреть файл

@ -37,6 +37,18 @@ TEST(EventFilterCollectionTests, Constructor_DefaultConstructed_NoRegisteredFilt
EXPECT_EQ(collection.m_filters.size(), size_t { 0 });
}
TEST(EventFilterCollectionTests, Empty_ZeroRegisteredFilters_ReturnsTrue)
{
EventFilterCollection collection;
EXPECT_TRUE(collection.Empty());
}
TEST(EventFilterCollectionTests, Size_ZeroRegisteredFilters_ReturnsZero)
{
EventFilterCollection collection;
EXPECT_EQ(collection.Size(), size_t{0});
}
TEST(EventFilterCollectionTests, RegisterEventFilter_NullptrFilter_ThrowsArgumentException)
{
TestEventFilterCollection collection;

Просмотреть файл

@ -10,7 +10,7 @@ set(CPACK_PACKAGING_INSTALL_PREFIX "/usr/local")
set(CPACK_GENERATOR "DEB")
set(MAJOR_VERSION "3")
set(MINOR_VERSION "2")
set(MINOR_VERSION "3")
string(TIMESTAMP DAYNUMBER "%j")
set(PATCH_VERSION "${DAYNUMBER}")

Просмотреть файл

@ -8,7 +8,7 @@ set(CPACK_RPM_PACKAGE_DESCRIPTION_SUMMARY "Microsoft Applications Telemetry SDK
set(CPACK_RPM_PACKAGE_CONTACT "1ds.sdk.cpp@service.microsoft.com")
set(MAJOR_VERSION "3")
set(MINOR_VERSION "2")
set(MINOR_VERSION "3")
string(TIMESTAMP DAYNUMBER "%j")
set(PATCH_VERSION "${DAYNUMBER}")

Просмотреть файл

@ -7,7 +7,7 @@ set(CPACK_PACKAGING_INSTALL_PREFIX "/usr/local")
set(CPACK_GENERATOR "TGZ")
set(MAJOR_VERSION "3")
set(MINOR_VERSION "2")
set(MINOR_VERSION "3")
string(TIMESTAMP DAYNUMBER "%j")
set(PATCH_VERSION "${DAYNUMBER}")

Просмотреть файл

@ -9,7 +9,7 @@ NSMutableDictionary<NSString *, id> * _properties;
-(instancetype)initWithName:(nonnull NSString *)name
{
return [self initWithName:name aproperties:[[NSMutableDictionary alloc] init]];
return [self initWithName:name properties:[[NSMutableDictionary alloc] init]];
}
-(instancetype)initWithName:(nonnull NSString *)name

Просмотреть файл

@ -5,6 +5,7 @@
using namespace MAT;
using namespace Microsoft::Applications::Events;
LOGMANAGER_INSTANCE
@implementation ODWLogManager