From 92f4a33682130691a4de07acb2bc0eb23e17675d Mon Sep 17 00:00:00 2001 From: "David Brown (XBOX)" Date: Thu, 13 Jun 2019 17:42:07 +0000 Subject: [PATCH 01/15] Merged PR 1073018: Convert WindowsEnvironmentInfo.cpp/.h into a header-only .hpp Convert WindowsEnvironmentInfo.cpp/.h into a header-only .hpp to support Office Universal build from source --- .../Clienttelemetry/Clienttelemetry.vcxitems | 3 +- .../Clienttelemetry.vcxitems.filters | 5 +- .../WindowsDesktopDeviceInformationImpl.cpp | 2 +- .../WindowsDesktopSystemInformationImpl.cpp | 2 +- lib/pal/desktop/WindowsEnvironmentInfo.cpp | 58 ----------------- lib/pal/desktop/WindowsEnvironmentInfo.h | 16 ----- lib/pal/desktop/WindowsEnvironmentInfo.hpp | 65 +++++++++++++++++++ .../WindowsRuntimeDeviceInformationImpl.cpp | 2 +- .../WindowsRuntimeSystemInformationImpl.cpp | 2 +- 9 files changed, 71 insertions(+), 84 deletions(-) delete mode 100644 lib/pal/desktop/WindowsEnvironmentInfo.cpp delete mode 100644 lib/pal/desktop/WindowsEnvironmentInfo.h create mode 100644 lib/pal/desktop/WindowsEnvironmentInfo.hpp diff --git a/Solutions/Clienttelemetry/Clienttelemetry.vcxitems b/Solutions/Clienttelemetry/Clienttelemetry.vcxitems index 2dbff68d8..f37987b12 100644 --- a/Solutions/Clienttelemetry/Clienttelemetry.vcxitems +++ b/Solutions/Clienttelemetry/Clienttelemetry.vcxitems @@ -47,7 +47,6 @@ - @@ -159,7 +158,7 @@ - + diff --git a/Solutions/Clienttelemetry/Clienttelemetry.vcxitems.filters b/Solutions/Clienttelemetry/Clienttelemetry.vcxitems.filters index 337dff50a..76032a0bf 100644 --- a/Solutions/Clienttelemetry/Clienttelemetry.vcxitems.filters +++ b/Solutions/Clienttelemetry/Clienttelemetry.vcxitems.filters @@ -201,9 +201,6 @@ pal - - pal\desktop - @@ -530,7 +527,7 @@ include\mat - + pal\desktop diff --git a/lib/pal/desktop/WindowsDesktopDeviceInformationImpl.cpp b/lib/pal/desktop/WindowsDesktopDeviceInformationImpl.cpp index 2cb7b48a5..d48bda3be 100644 --- a/lib/pal/desktop/WindowsDesktopDeviceInformationImpl.cpp +++ b/lib/pal/desktop/WindowsDesktopDeviceInformationImpl.cpp @@ -4,7 +4,7 @@ #endif #include "pal/PAL.hpp" #include "pal/DeviceInformationImpl.hpp" -#include "WindowsEnvironmentInfo.h" +#include "WindowsEnvironmentInfo.hpp" MATSDK_LOG_INST_COMPONENT_NS("DeviceInfo", "Win32 Desktop Device Information") diff --git a/lib/pal/desktop/WindowsDesktopSystemInformationImpl.cpp b/lib/pal/desktop/WindowsDesktopSystemInformationImpl.cpp index c4847e2c3..be33dd3a1 100644 --- a/lib/pal/desktop/WindowsDesktopSystemInformationImpl.cpp +++ b/lib/pal/desktop/WindowsDesktopSystemInformationImpl.cpp @@ -22,7 +22,7 @@ #include "ISystemInformation.hpp" #include "pal/SystemInformationImpl.hpp" -#include "WindowsEnvironmentInfo.h" +#include "WindowsEnvironmentInfo.hpp" #include diff --git a/lib/pal/desktop/WindowsEnvironmentInfo.cpp b/lib/pal/desktop/WindowsEnvironmentInfo.cpp deleted file mode 100644 index e5c3406a4..000000000 --- a/lib/pal/desktop/WindowsEnvironmentInfo.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. -#include "Version.hpp" -#include "WindowsEnvironmentInfo.h" -#include - -namespace ARIASDK_NS_BEGIN -{ - // Convert a bias in minutes to the ISO 8601 time zone representaiton. - // ISO 8601 examples: +01:30, -08 - std::string TimeZoneBiasToISO8601(long bias) - { - auto hours = (long long)abs(bias) / 60; - auto minutes = (long long)abs(bias) % 60; - - // UTC = local time + bias; bias sign should be interved. - return std::string(bias <= 0 ? "+" : "-") + (hours >= 10 ? "" : "0") + std::to_string(hours) + ":" - + (minutes >= 10 ? "" : "0") + std::to_string(minutes); - } - - // Retrieves the processor architecture. - OsArchitectureType WindowsEnvironmentInfo::GetProcessorArchitecture() - { - _SYSTEM_INFO sysinfo = {}; - GetNativeSystemInfo(&sysinfo); - - switch (sysinfo.wProcessorArchitecture) - { - case PROCESSOR_ARCHITECTURE_AMD64: - case PROCESSOR_ARCHITECTURE_IA64: - return OsArchitectureType_X64; - - case PROCESSOR_ARCHITECTURE_ARM: - return OsArchitectureType_Arm; - - case PROCESSOR_ARCHITECTURE_INTEL: - return OsArchitectureType_X86; - - default: - return OsArchitectureType_Unknown; - } - } - - std::string WindowsEnvironmentInfo::GetTimeZone() - { - TIME_ZONE_INFORMATION timeZone = {}; - if (GetTimeZoneInformation(&timeZone) == TIME_ZONE_ID_DAYLIGHT) - { - return TimeZoneBiasToISO8601(timeZone.Bias + timeZone.DaylightBias); - } - else - { - // TODO: [MG] - fix this benign compiler warning - // Warning C6102 Using 'timeZone' from failed function call at line '46' - return TimeZoneBiasToISO8601(timeZone.Bias + timeZone.StandardBias); - } - } - -} ARIASDK_NS_END diff --git a/lib/pal/desktop/WindowsEnvironmentInfo.h b/lib/pal/desktop/WindowsEnvironmentInfo.h deleted file mode 100644 index d1a02eda5..000000000 --- a/lib/pal/desktop/WindowsEnvironmentInfo.h +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. -#pragma once -#include "Enums.hpp" -#include -#include - -namespace ARIASDK_NS_BEGIN { - - class WindowsEnvironmentInfo - { - public: - static OsArchitectureType GetProcessorArchitecture(); - static std::string GetTimeZone(); - }; - -} ARIASDK_NS_END diff --git a/lib/pal/desktop/WindowsEnvironmentInfo.hpp b/lib/pal/desktop/WindowsEnvironmentInfo.hpp new file mode 100644 index 000000000..5040997d3 --- /dev/null +++ b/lib/pal/desktop/WindowsEnvironmentInfo.hpp @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft. All rights reserved. +#ifndef WINDOWSENVIRONMENTINFO_HPP +#define WINDOWSENVIRONMENTINFO_HPP + +#include "Enums.hpp" +#include +#include + +namespace ARIASDK_NS_BEGIN { + + class WindowsEnvironmentInfo + { + public: + static OsArchitectureType GetProcessorArchitecture() + { + _SYSTEM_INFO sysinfo = {}; + GetNativeSystemInfo(&sysinfo); + + switch (sysinfo.wProcessorArchitecture) + { + case PROCESSOR_ARCHITECTURE_AMD64: + case PROCESSOR_ARCHITECTURE_IA64: + return OsArchitectureType_X64; + + case PROCESSOR_ARCHITECTURE_ARM: + return OsArchitectureType_Arm; + + case PROCESSOR_ARCHITECTURE_INTEL: + return OsArchitectureType_X86; + + default: + return OsArchitectureType_Unknown; + } + }; + + static std::string GetTimeZone() + { + TIME_ZONE_INFORMATION timeZone = {}; + if (GetTimeZoneInformation(&timeZone) == TIME_ZONE_ID_DAYLIGHT) + { + return TimeZoneBiasToISO8601(timeZone.Bias + timeZone.DaylightBias); + } + else + { + // TODO: [MG] - fix this benign compiler warning + // Warning C6102 Using 'timeZone' from failed function call at line '46' + return TimeZoneBiasToISO8601(timeZone.Bias + timeZone.StandardBias); + } + }; + protected: + // Convert a bias in minutes to the ISO 8601 time zone representaiton. + // ISO 8601 examples: +01:30, -08 + static std::string TimeZoneBiasToISO8601(long bias) + { + auto hours = (long long)abs(bias) / 60; + auto minutes = (long long)abs(bias) % 60; + + // UTC = local time + bias; bias sign should be interved. + return std::string(bias <= 0 ? "+" : "-") + (hours >= 10 ? "" : "0") + std::to_string(hours) + ":" + + (minutes >= 10 ? "" : "0") + std::to_string(minutes); + } + }; + +} ARIASDK_NS_END +#endif diff --git a/lib/pal/universal/WindowsRuntimeDeviceInformationImpl.cpp b/lib/pal/universal/WindowsRuntimeDeviceInformationImpl.cpp index 03de6f1c3..0398c816f 100644 --- a/lib/pal/universal/WindowsRuntimeDeviceInformationImpl.cpp +++ b/lib/pal/universal/WindowsRuntimeDeviceInformationImpl.cpp @@ -3,7 +3,7 @@ #include "pal/PAL.hpp" #include "pal/DeviceInformationImpl.hpp" -#include "pal/desktop/WindowsEnvironmentInfo.h" +#include "pal/desktop/WindowsEnvironmentInfo.hpp" #include "PlatformHelpers.h" #include diff --git a/lib/pal/universal/WindowsRuntimeSystemInformationImpl.cpp b/lib/pal/universal/WindowsRuntimeSystemInformationImpl.cpp index 66979ef16..d8bcb18b1 100644 --- a/lib/pal/universal/WindowsRuntimeSystemInformationImpl.cpp +++ b/lib/pal/universal/WindowsRuntimeSystemInformationImpl.cpp @@ -4,7 +4,7 @@ #include "ISystemInformation.hpp" #include "pal/SystemInformationImpl.hpp" -#include "pal/desktop/WindowsEnvironmentInfo.h" +#include "pal/desktop/WindowsEnvironmentInfo.hpp" #include "PlatformHelpers.h" using namespace std; From 409c139c7579a7cf426a85810fc3bb80c4de4c52 Mon Sep 17 00:00:00 2001 From: Miguel Casillas Date: Mon, 17 Jun 2019 22:30:49 +0000 Subject: [PATCH 02/15] Merged PR 1075428: Support payloads larger than 64K Send large events to UTC, two options: - Tag a Logger to send large events using logger->AllowLargeEvents(true), this logger will use only RPC mechanism to pass events to UTC. - Auto size detection for events sent to UTC, UTCTelemetrySystem checks the size of the event and uses the right path. Related work items: #1782870 --- .../Clienttelemetry/Clienttelemetry.vcxitems | 2 + .../Clienttelemetry.vcxitems.filters | 6 + .../SampleCppLogManagers.vcxproj | 4 +- examples/cpp/SampleCppUTC/main.cpp | 12 ++ lib/api/Logger.cpp | 21 +- lib/api/Logger.hpp | 3 + lib/include/public/ILogger.hpp | 7 + lib/include/public/NullObjects.hpp | 2 + lib/modules/utc/UtcTelemetrySystem.cpp | 81 ++++++-- lib/modules/utc/UtcTelemetrySystem.hpp | 1 + lib/system/Contexts.hpp | 10 +- lib/system/JsonFormatter.cpp | 184 ++++++++++++++++++ lib/system/JsonFormatter.hpp | 26 +++ 13 files changed, 332 insertions(+), 27 deletions(-) create mode 100644 lib/system/JsonFormatter.cpp create mode 100644 lib/system/JsonFormatter.hpp diff --git a/Solutions/Clienttelemetry/Clienttelemetry.vcxitems b/Solutions/Clienttelemetry/Clienttelemetry.vcxitems index f37987b12..e2eb677a8 100644 --- a/Solutions/Clienttelemetry/Clienttelemetry.vcxitems +++ b/Solutions/Clienttelemetry/Clienttelemetry.vcxitems @@ -51,6 +51,7 @@ + @@ -165,6 +166,7 @@ + diff --git a/Solutions/Clienttelemetry/Clienttelemetry.vcxitems.filters b/Solutions/Clienttelemetry/Clienttelemetry.vcxitems.filters index 76032a0bf..10cd091c6 100644 --- a/Solutions/Clienttelemetry/Clienttelemetry.vcxitems.filters +++ b/Solutions/Clienttelemetry/Clienttelemetry.vcxitems.filters @@ -201,6 +201,9 @@ pal + + system + @@ -554,6 +557,9 @@ bond\generated + + system + diff --git a/examples/cpp/SampleCppLogManagers/SampleCppLogManagers.vcxproj b/examples/cpp/SampleCppLogManagers/SampleCppLogManagers.vcxproj index 7ae71d806..be49c0cfb 100644 --- a/examples/cpp/SampleCppLogManagers/SampleCppLogManagers.vcxproj +++ b/examples/cpp/SampleCppLogManagers/SampleCppLogManagers.vcxproj @@ -113,7 +113,7 @@ - Use + NotUsing Level3 Disabled true @@ -159,7 +159,7 @@ - Use + NotUsing Level3 MaxSpeed true diff --git a/examples/cpp/SampleCppUTC/main.cpp b/examples/cpp/SampleCppUTC/main.cpp index 1aa224900..5647108e6 100644 --- a/examples/cpp/SampleCppUTC/main.cpp +++ b/examples/cpp/SampleCppUTC/main.cpp @@ -15,6 +15,17 @@ using namespace MAT; #define TENANT_TOKEN "99999999999999999999999999999999-99999999-9999-9999-9999-999999999999-9999" +std::string getRandomStringWithSize(int size) +{ + std::string alpha = "abcdefghijklmnopqrstuvwxyz"; + std::string ans; + for (size_t i = 0; i < size; i++) + { + ans += alpha[rand() % 26]; + } + return ans; +} + void forwardEventToUTC() { printf("LogManager init\n"); @@ -57,6 +68,7 @@ void forwardEventToUTC() event.SetProperty(COMMONFIELDS_METADATA_VIEWINGEXTRA1, "ExtraDataField1"); event.SetProperty(COMMONFIELDS_METADATA_VIEWINGEXTRA2, "ExtraDataField2"); event.SetProperty(COMMONFIELDS_METADATA_VIEWINGEXTRA3, "ExtraDataField3"); + event.SetProperty(COMMONFIELDS_EVENT_PRIVTAGS, PDT_ProductAndServicePerformance); logger->LogEvent(event); } diff --git a/lib/api/Logger.cpp b/lib/api/Logger.cpp index 38a1213b7..12bf84797 100644 --- a/lib/api/Logger.cpp +++ b/lib/api/Logger.cpp @@ -40,7 +40,8 @@ namespace ARIASDK_NS_BEGIN m_semanticApiDecorators(logManager), m_sessionStartTime(0), - m_allowDotsInType(false) + m_allowDotsInType(false), + m_sendLargeEvents(false) { std::string tenantId = tenantTokenToId(m_tenantToken); LOG_TRACE("%p: New instance (tenantId=%s)", this, tenantId.c_str()); @@ -348,12 +349,8 @@ namespace ARIASDK_NS_BEGIN } record.iKey = m_iKey; - // TODO: [MG] - optimize this code - bool result = true; - result &= m_baseDecorator.decorate(record); - result &= m_semanticContextDecorator.decorate(record); - result &= m_eventPropertiesDecorator.decorate(record, latency, properties); - return result; + return m_baseDecorator.decorate(record) && m_semanticContextDecorator.decorate(record) + && m_eventPropertiesDecorator.decorate(record, latency, properties); } @@ -421,6 +418,11 @@ namespace ARIASDK_NS_BEGIN // TODO: [MG] - check if optimization is possible in generateUuidString IncomingEventContext event(PAL::generateUuidString(), m_tenantToken, latency, persistence, &record); event.policyBitFlags = policyBitFlags; + + // TODO: [MC] - maybe UTC_MODE validation is necessary + if (m_sendLargeEvents) + event.isLargeEvent = true; + m_logManager.sendEvent(&event); } @@ -658,4 +660,9 @@ namespace ARIASDK_NS_BEGIN m_level = level; } + void Logger::AllowLargeEvents(bool flag) + { + m_sendLargeEvents = flag; + } + } ARIASDK_NS_END \ No newline at end of file diff --git a/lib/api/Logger.hpp b/lib/api/Logger.hpp index e209decf4..9f8a6873b 100644 --- a/lib/api/Logger.hpp +++ b/lib/api/Logger.hpp @@ -79,6 +79,8 @@ namespace ARIASDK_NS_BEGIN { virtual void SetLevel(uint8_t level) override; + virtual void AllowLargeEvents(bool flag) override; + virtual ISemanticContext* GetSemanticContext() const override; virtual void SetParentContext(ISemanticContext* context) override; @@ -200,6 +202,7 @@ namespace ARIASDK_NS_BEGIN { SemanticApiDecorators m_semanticApiDecorators; bool m_allowDotsInType; + bool m_sendLargeEvents; }; } ARIASDK_NS_END diff --git a/lib/include/public/ILogger.hpp b/lib/include/public/ILogger.hpp index d604d6a8d..3f2a8e468 100644 --- a/lib/include/public/ILogger.hpp +++ b/lib/include/public/ILogger.hpp @@ -585,6 +585,13 @@ namespace ARIASDK_NS_BEGIN /// /// Diagnostic level. virtual void SetLevel(uint8_t level) = 0; + + /// + /// Set the boolean flag for allowing events with payload + /// larger than 64K to be sent to UTC + /// + /// Diagnostic level. + virtual void AllowLargeEvents(bool flag) = 0; }; diff --git a/lib/include/public/NullObjects.hpp b/lib/include/public/NullObjects.hpp index b7da41e8e..d0defd9d3 100644 --- a/lib/include/public/NullObjects.hpp +++ b/lib/include/public/NullObjects.hpp @@ -107,6 +107,8 @@ namespace ARIASDK_NS_BEGIN virtual void SetLevel(uint8_t level) override {}; + virtual void AllowLargeEvents(bool flag) override {}; + }; class NullLogManager : public ILogManager diff --git a/lib/modules/utc/UtcTelemetrySystem.cpp b/lib/modules/utc/UtcTelemetrySystem.cpp index e39bf3afb..dab721e48 100644 --- a/lib/modules/utc/UtcTelemetrySystem.cpp +++ b/lib/modules/utc/UtcTelemetrySystem.cpp @@ -25,6 +25,8 @@ namespace ARIASDK_NS_BEGIN static const unsigned char InvalidHexDigit = 0xFF; + static const unsigned int LargeEventSizeKB = 62; + unsigned char getHexToInt(char ch) { unsigned char temp = 0; @@ -187,6 +189,27 @@ namespace ARIASDK_NS_BEGIN return temp; } + HRESULT RPCWriteEvent( + REGHANDLE hProvider, + EVENT_DESCRIPTOR const& eventDescriptor, + UINT8 const* pProviderMetadata, + UINT8 const* pEventMetadata, + ULONG cDataDescriptors, + EVENT_DATA_DESCRIPTOR* pDataDescriptors, + LPCGUID pActivityId = 0, + LPCGUID pRelatedActivityId = 0) + { + (void)cDataDescriptors; + (void)eventDescriptor; + (void)hProvider; + (void)pActivityId; + (void)pRelatedActivityId; + (void)pDataDescriptors; + (void)pEventMetadata; + (void)pProviderMetadata; + return -1; + } + UtcTelemetrySystem::UtcTelemetrySystem(ILogManager& logManager, IRuntimeConfig& runtimeConfig) : TelemetrySystemBase(logManager, runtimeConfig) @@ -196,7 +219,7 @@ namespace ARIASDK_NS_BEGIN // onStart = stats.onStart; - onStop = stats.onStop; + onStop = stats.onStop; #if 0 /* XXX: [MG] - don't use RouteSink for that. It's an overkill */ this->started >> stats.onStart; @@ -286,7 +309,6 @@ namespace ARIASDK_NS_BEGIN eventCtx->source->data[0].properties.erase(COMMONFIELDS_EVENT_SOURCE); eventCtx->source->data[0].properties.erase(COMMONFIELDS_USER_ADVERTISINGID); eventCtx->source->data[0].properties.erase(COMMONFIELDS_APP_EXPERIMENTETAG); - //eventCtx->source->data[0].properties.erase(COMMONFIELDS_EVENT_PRIVTAGS); //eventCtx->source->data[0].properties.erase(SESSION_ID); //eventCtx->source->data[0].properties.erase(SESSION_STATE); @@ -307,10 +329,10 @@ namespace ARIASDK_NS_BEGIN if (eventCtx->source->data[0].properties.find(COMMONFIELDS_EVENT_PRIVTAGS) != eventCtx->source->data[0].properties.end()) { // UTC mode sends privacy tag in ext.metadata.privTags - builder.AddField("PartA_PrivTags", TypeUInt64); + builder.AddField(UTC_PARTA_METADATA_PRIVTAGS, TypeUInt64); int64_t value = eventCtx->source->data[0].properties[COMMONFIELDS_EVENT_PRIVTAGS].longValue; dbuilder.AddValue(value); - } + } //PartA_Exts_CommonFields builder.AddField(UTC_PARTA_IKEY, TypeMbcsString); @@ -352,15 +374,15 @@ namespace ARIASDK_NS_BEGIN dbuilder.AddString(deviceInfoNetworkType.c_str()); } -/* - std::string eventInfoSequence = eventCtx->source->Extension[EventInfo_Sequence]; - eventCtx->source->Extension.erase(EventInfo_Sequence); - if (!eventInfoSequence.empty()) - { - builder.AddField(UTC_PARTA_APP_SEQ_NUM, TypeMbcsString); - dbuilder.AddString(eventInfoSequence.c_str()); - } -*/ + /* + std::string eventInfoSequence = eventCtx->source->Extension[EventInfo_Sequence]; + eventCtx->source->Extension.erase(EventInfo_Sequence); + if (!eventInfoSequence.empty()) + { + builder.AddField(UTC_PARTA_APP_SEQ_NUM, TypeMbcsString); + dbuilder.AddString(eventInfoSequence.c_str()); + } + */ std::string sdkUserId(eventCtx->source->extUser[0].localId); if (!sdkUserId.empty()) { @@ -487,8 +509,39 @@ namespace ARIASDK_NS_BEGIN EVENT_DATA_DESCRIPTOR pDataDescriptors[3]; EventDataDescCreate(&pDataDescriptors[2], byteDataVector.data(), static_cast(byteDataVector.size())); + + // if the event does not come from a logger that sends large events + // auto size detection is needed + if (!eventCtx->isLargeEvent) + { + int64_t eventByteSize = byteDataVector.size() + byteVector.size() + + providerdata.providerMetaVector.size(); + int64_t eventKBSize = (eventByteSize + 1024 - 1) / 1024; + eventCtx->isLargeEvent = eventKBSize >= LargeEventSizeKB; + } + + if (!eventCtx->isLargeEvent) + { + HRESULT writeResponse = tld::WriteEvent( + providerdata.providerHandle, + eventDescriptor, + providerdata.providerMetaVector.data(), + byteVector.data(), + 3, + pDataDescriptors); + if (writeResponse == 0) + return 0; + else if (writeResponse == HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW)) + eventCtx->isLargeEvent = true; + else + return -1; + } + // if event comes from a tagged logger, or size is larger than LargeEventSizeKB + // or was sent to ETW and the response was STATUS_INTEGER_OVERFLOW + if(eventCtx->isLargeEvent) { - if (0 != tld::WriteEvent( + // Use RPC path for 64KB+ events + if (0 != RPCWriteEvent( providerdata.providerHandle, eventDescriptor, providerdata.providerMetaVector.data(), diff --git a/lib/modules/utc/UtcTelemetrySystem.hpp b/lib/modules/utc/UtcTelemetrySystem.hpp index 820de06b2..94b5175ab 100644 --- a/lib/modules/utc/UtcTelemetrySystem.hpp +++ b/lib/modules/utc/UtcTelemetrySystem.hpp @@ -47,6 +47,7 @@ namespace ARIASDK_NS_BEGIN const char* const UTC_PARTA_USER_AUTH_ID = "PartA_Ext_User_AuthId"; const char* const UTC_PARTA_ARIA_METADATA = "PartA_Ext_AriaMD"; const char* const UTC_PARTA_ARIA_METADATA_FIELDS = "fields"; + const char* const UTC_PARTA_METADATA_PRIVTAGS = "PartA_PrivTags"; enum AriaType : UINT16 { diff --git a/lib/system/Contexts.hpp b/lib/system/Contexts.hpp index e91b62caf..6ca2bd893 100644 --- a/lib/system/Contexts.hpp +++ b/lib/system/Contexts.hpp @@ -18,13 +18,15 @@ namespace ARIASDK_NS_BEGIN { class IncomingEventContext { public: ::CsProtocol::Record* source; - StorageRecord record; - std::uint64_t policyBitFlags; + StorageRecord record; + std::uint64_t policyBitFlags; + bool isLargeEvent; public: IncomingEventContext() : - policyBitFlags(0), - source(nullptr) + policyBitFlags(0), + source(nullptr), + isLargeEvent(false) { } diff --git a/lib/system/JsonFormatter.cpp b/lib/system/JsonFormatter.cpp new file mode 100644 index 000000000..adffff336 --- /dev/null +++ b/lib/system/JsonFormatter.cpp @@ -0,0 +1,184 @@ +#include "JsonFormatter.hpp" +#include "CorrelationVector.hpp" +#include "json.hpp" + +using json = nlohmann::json; + +namespace ARIASDK_NS_BEGIN +{ + + JsonFormatter::JsonFormatter() + { + + } + + JsonFormatter::~JsonFormatter() + { + + } + + void addExtApp(json& object, std::vector<::CsProtocol::App>& extApp) + { + if (!extApp[0].id.empty()) + { + object["ext"]["extApp"]["name"] = extApp[0].id; + } + if (!extApp[0].expId.empty()) + { + object["ext"]["extApp"]["expId"] = extApp[0].id; + } + } + + void addExtNet(json& object, std::vector<::CsProtocol::Net>& extNet) + { + if (!extNet[0].cost.empty()) + { + object["ext"]["extNet"]["cost"] = extNet[0].cost; + } + if (!extNet[0].type.empty()) + { + object["ext"]["extNet"]["type"] = extNet[0].type; + } + } + + void addData(json& object, std::vector<::CsProtocol::Data>& data) + { + std::vector<::CsProtocol::Data>::const_iterator it; + for (it = data.begin(); it != data.end(); it++) + { + std::map::const_iterator mapIt; + for (mapIt = it->properties.begin(); mapIt != it->properties.end(); mapIt++) + { + switch (mapIt->second.type) + { + case CsProtocol::ValueKind::ValueInt64: + object["data"][mapIt->first] = mapIt->second.longValue; + break; + case CsProtocol::ValueKind::ValueUInt64: + object["data"][mapIt->first] = mapIt->second.longValue; + break; + case CsProtocol::ValueKind::ValueInt32: + object["data"][mapIt->first] = static_cast(mapIt->second.longValue); + break; + case CsProtocol::ValueKind::ValueUInt32: + object["data"][mapIt->first] = static_cast(mapIt->second.longValue); + break; + case CsProtocol::ValueKind::ValueBool: + { + UINT8 temp = static_cast(mapIt->second.longValue); + object["data"][mapIt->first] = temp; + break; + } + case CsProtocol::ValueKind::ValueDateTime: + { + object["data"][mapIt->first] = mapIt->second.longValue; + break; + } + case CsProtocol::ValueKind::ValueArrayInt64: + object["data"][mapIt->first] = mapIt->second.longArray; + break; + case CsProtocol::ValueKind::ValueArrayUInt64: + object["data"][mapIt->first] = mapIt->second.longArray; + break; + case CsProtocol::ValueKind::ValueArrayInt32: + object["data"][mapIt->first] = mapIt->second.longArray; + break; + case CsProtocol::ValueKind::ValueArrayUInt32: + object["data"][mapIt->first] = mapIt->second.longArray; + break; + case CsProtocol::ValueKind::ValueArrayBool: + case CsProtocol::ValueKind::ValueArrayDateTime: + break; + case CsProtocol::ValueKind::ValueDouble: + { + object["data"][mapIt->first] = mapIt->second.doubleValue; + break; + } + case CsProtocol::ValueKind::ValueArrayDouble: + { + object["data"][mapIt->first] = mapIt->second.doubleArray; + break; + } + case CsProtocol::ValueKind::ValueString: + { + object["data"][mapIt->first] = mapIt->second.stringValue; + break; + } + case CsProtocol::ValueKind::ValueArrayString: + { + object["data"][mapIt->first] = mapIt->second.stringArray; + break; + } + case CsProtocol::ValueKind::ValueGuid: + { + + if (mapIt->second.guidValue.size() > 0) + { + /*GUID temp = GUID_t::convertUintVectorToGUID(mapIt->second.guidValue[0]); + myJson["data"][mapIt->first] = temp;*/ + } + break; + } + } + } + } + } + + std::string JsonFormatter::getJsonFormattedEvent(IncomingEventContextPtr const& event) + { + json ans = json::object(); + ::CsProtocol::Record* source = event->source; + ans["ver"] = source->ver; + ans["name"] = source->name; + if (source->time) ans["time"] = source->time; + std::string iKey("P-ARIA-"); + iKey.append(event->record.tenantToken); + ans["iKey"] = iKey; + if (!source->cV.empty()) + ans[CorrelationVector::PropertyName] = source->cV; + if (source->data[0].properties.find(COMMONFIELDS_EVENT_PRIVTAGS) != source->data[0].properties.end()) { + ans["ext"]["metadata"]["privTags"] = source->data[0].properties[COMMONFIELDS_EVENT_PRIVTAGS].longValue; + source->data[0].properties.erase(COMMONFIELDS_EVENT_PRIVTAGS); + } + addExtApp(ans, source->extApp); + addExtNet(ans, source->extNet); + + std::string userLocalId = source->extUser[0].localId; + if (!userLocalId.empty()) + { + std::string userId("e:"); + userId.append(userLocalId); + ans["ext"]["user"]["localId"] = userId; + } + std::string userLanguage = source->extUser[0].locale; + if (!userLanguage.empty()) + { + ans["ext"]["os"]["locale"] = userLanguage; + } + + source->data[0].properties.erase(COMMONFIELDS_USER_MSAID); + source->data[0].properties.erase(COMMONFIELDS_DEVICE_ID); + source->data[0].properties.erase(COMMONFIELDS_OS_NAME); + source->data[0].properties.erase(COMMONFIELDS_OS_VERSION); + source->data[0].properties.erase(COMMONFIELDS_OS_BUILD); + source->data[0].properties.erase(COMMONFIELDS_EVENT_TIME); + source->data[0].properties.erase(COMMONFIELDS_USER_ANID); + source->data[0].properties.erase(COMMONFIELDS_APP_VERSION); + source->data[0].properties.erase(COMMONFIELDS_EVENT_NAME); + source->data[0].properties.erase(COMMONFIELDS_EVENT_INITID); + source->data[0].properties.erase(COMMONFIELDS_EVENT_PRIVTAGS); + source->data[0].properties.erase(COMMONFIELDS_METADATA_VIEWINGPRODUCERID); + source->data[0].properties.erase(COMMONFIELDS_METADATA_VIEWINGCATEGORY); + source->data[0].properties.erase(COMMONFIELDS_METADATA_VIEWINGPAYLOADDECODERPATH); + source->data[0].properties.erase(COMMONFIELDS_METADATA_VIEWINGPAYLOADENCODEDFIELDNAME); + source->data[0].properties.erase(COMMONFIELDS_METADATA_VIEWINGEXTRA1); + source->data[0].properties.erase(COMMONFIELDS_METADATA_VIEWINGEXTRA2); + source->data[0].properties.erase(COMMONFIELDS_METADATA_VIEWINGEXTRA3); + + addData(ans, source->ext); + addData(ans, source->data); + addData(ans, source->baseData); + return ans.dump(4); + } + +} ARIASDK_NS_END \ No newline at end of file diff --git a/lib/system/JsonFormatter.hpp b/lib/system/JsonFormatter.hpp new file mode 100644 index 000000000..4cea33337 --- /dev/null +++ b/lib/system/JsonFormatter.hpp @@ -0,0 +1,26 @@ +#include "Version.hpp" +#include "Contexts.hpp" +#include "CommonFields.h" +#include +#include + +namespace ARIASDK_NS_BEGIN +{ + const char* const ARIA_EXT_TEXT = "ext"; + const char* const ARIA_DATA_TEXT = "data"; + const char* const ARIA_EXT_EXTAPP_TEXT = "extApp"; + const char* const ARIA_EXT_EXTOS_TEXT = "os"; + const char* const ARIA_EXT_EXTNET_TEXT = "extNet"; + const char* const ARIA_EXT_EXTMETADATA_TEXT = "metadata"; + + class MATSDK_LIBABI JsonFormatter + { + public: + JsonFormatter(); + + ~JsonFormatter(); + + std::string getJsonFormattedEvent(IncomingEventContextPtr const& event); + }; + +} ARIASDK_NS_END \ No newline at end of file From 00c442f199ff44451703bb5cedb6576e55cf61a0 Mon Sep 17 00:00:00 2001 From: Matt Koscumb Date: Tue, 18 Jun 2019 10:07:20 -0700 Subject: [PATCH 03/15] if _WIN32 or _WIN64 are defined as empty-string (they are), the expression expands to ' || ' which is invalid. Wrapping these macros in defined checks. --- lib/include/public/ctmacros.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/include/public/ctmacros.hpp b/lib/include/public/ctmacros.hpp index 3886c3594..70ca99067 100644 --- a/lib/include/public/ctmacros.hpp +++ b/lib/include/public/ctmacros.hpp @@ -59,8 +59,8 @@ // Macro for mutex issues debugging. Supports both std::mutex and std::recursive_mutex #define LOCKGUARD(macro_mutex) LOG_DEBUG("LOCKGUARD lockin at %s:%d", __FILE__, __LINE__); std::lock_guard TOKENPASTE2(__guard_, __LINE__) (macro_mutex); LOG_DEBUG("LOCKGUARD locked at %s:%d", __FILE__, __LINE__); -#if _WIN32 || _WIN64 -#if _WIN64 +#if defined(_WIN32) || defined(_WIN64) +#ifdef _WIN64 #define ARCH_64BIT #else #define ARCH_32BIT From 3663d2c2484393a0e730766612437f0d82846ac4 Mon Sep 17 00:00:00 2001 From: Matt Koscumb Date: Tue, 18 Jun 2019 10:09:00 -0700 Subject: [PATCH 04/15] if __x86_64__ or __ppc64__ are defined as empty-string, this expression expands to ' || ' which is invalid. Wrapping these macros in defined checks. --- lib/include/public/ctmacros.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/include/public/ctmacros.hpp b/lib/include/public/ctmacros.hpp index 70ca99067..7b335d6d2 100644 --- a/lib/include/public/ctmacros.hpp +++ b/lib/include/public/ctmacros.hpp @@ -68,7 +68,7 @@ #endif #if __GNUC__ -#if __x86_64__ || __ppc64__ +#if defined(__x86_64__) || defined(__ppc64__) #define ARCH_64BIT #else #define ARCH_32BIT From 857aa797d647c2867e307f16bd68246efc66e414 Mon Sep 17 00:00:00 2001 From: Matt Koscumb Date: Tue, 18 Jun 2019 10:24:13 -0700 Subject: [PATCH 05/15] The code shouldn't know how to set LONG_IS_INT64_T in principle - that should be set by the build logic - but I'm not solving that here. For now just allow it to be defined elsewhere without Macro redefintion errors. --- lib/include/public/EventProperty.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/include/public/EventProperty.hpp b/lib/include/public/EventProperty.hpp index 5e13c39ef..546040ac2 100644 --- a/lib/include/public/EventProperty.hpp +++ b/lib/include/public/EventProperty.hpp @@ -21,8 +21,10 @@ #include #else #include +#ifndef LONG_IS_INT64_T #define LONG_IS_INT64_T #endif +#endif namespace ARIASDK_NS_BEGIN { From f13c79fad482a802711fbc4a6b0bcf59962a4004 Mon Sep 17 00:00:00 2001 From: Matt Koscumb Date: Tue, 18 Jun 2019 10:26:59 -0700 Subject: [PATCH 06/15] Remove the #ifdef ANDROID blocks in LogManagerProvider.hpp, as even on android they're not used. There's a better design for this. --- lib/include/public/LogManagerProvider.hpp | 37 ----------------------- 1 file changed, 37 deletions(-) diff --git a/lib/include/public/LogManagerProvider.hpp b/lib/include/public/LogManagerProvider.hpp index 62949076e..38bb0e494 100644 --- a/lib/include/public/LogManagerProvider.hpp +++ b/lib/include/public/LogManagerProvider.hpp @@ -40,11 +40,6 @@ namespace ARIASDK_NS_BEGIN ILogConfiguration& cfg, status_t& status, IHttpClient* httpClient, -#ifdef ANDROID - JNIEnv *env, - jclass contextClass, - jobject contextObject, -#endif uint64_t targetVersion = MAT::Version) { cfg["name"] = id; @@ -76,11 +71,6 @@ namespace ARIASDK_NS_BEGIN char const* id, bool wantController, status_t& status, -#ifdef ANDROID - JNIEnv *env, - jclass contextClass, - jobject contextObject, -#endif uint64_t targetVersion = MAT::Version) { UNREFERENCED_PARAMETER(targetVersion); @@ -89,12 +79,6 @@ namespace ARIASDK_NS_BEGIN return Get( id, status -#ifdef ANDROID - , - env, - contextClass, - contextObject -#endif ); }; #endif @@ -107,11 +91,6 @@ namespace ARIASDK_NS_BEGIN ///   static ILogManager* MATSDK_SPEC CreateLogManager(char const* id, status_t& status, -#ifdef ANDROID - JNIEnv *env, - jclass contextClass, - jobject contextObject, -#endif uint64_t targetVersion = MAT::Version) { UNREFERENCED_PARAMETER(targetVersion); @@ -119,12 +98,6 @@ namespace ARIASDK_NS_BEGIN return Get( id, status -#ifdef ANDROID - , - env, - contextClass, - contextObject -#endif ); } @@ -174,21 +147,11 @@ namespace ARIASDK_NS_BEGIN ILogConfiguration & cfg, status_t &status, IHttpClient* httpClient -#ifdef ANDROID - , JNIEnv * env - , jclass contextClass - , jobject contextObject -#endif ); static ILogManager* MATSDK_SPEC Get( const char * id, status_t& status -#ifdef ANDROID - JNIEnv *env, - jclass contextClass, - jobject contextObject, -#endif ); }; From 05d1b75cfb1dc926b367c4aabac471eaf26f4e61 Mon Sep 17 00:00:00 2001 From: Matt Koscumb Date: Wed, 19 Jun 2019 11:11:20 -0700 Subject: [PATCH 07/15] Get rid of some legacy #ifdef ANDROID blocks. --- lib/api/LogManagerFactory.hpp | 15 --------------- lib/api/LogManagerProvider.cpp | 10 ---------- 2 files changed, 25 deletions(-) diff --git a/lib/api/LogManagerFactory.hpp b/lib/api/LogManagerFactory.hpp index 73f9a0004..39f22ab75 100644 --- a/lib/api/LogManagerFactory.hpp +++ b/lib/api/LogManagerFactory.hpp @@ -98,11 +98,6 @@ namespace ARIASDK_NS_BEGIN { ILogConfiguration& logConfiguration, status_t& status, IHttpClient* httpClient -#ifdef ANDROID - , JNIEnv * env - , jclass contextClass - , jobject contextObject -#endif ) { auto result = instance().lease(logConfiguration, httpClient); @@ -115,11 +110,6 @@ namespace ARIASDK_NS_BEGIN { static ILogManager * Get( ILogConfiguration& logConfiguration, status_t& status -#ifdef ANDROID - , JNIEnv * env - , jclass contextClass - , jobject contextObject -#endif ) { return Get(logConfiguration, status, nullptr); @@ -128,11 +118,6 @@ namespace ARIASDK_NS_BEGIN { static ILogManager* Get( const char * module, status_t& status -#ifdef ANDROID - JNIEnv *env, - jclass contextClass, - jobject contextObject, -#endif ) { ILogConfiguration config = diff --git a/lib/api/LogManagerProvider.cpp b/lib/api/LogManagerProvider.cpp index 7116af81d..8d81242ff 100644 --- a/lib/api/LogManagerProvider.cpp +++ b/lib/api/LogManagerProvider.cpp @@ -8,11 +8,6 @@ namespace ARIASDK_NS_BEGIN { ILogConfiguration & config, status_t &status, IHttpClient* httpClient -#ifdef ANDROID - , JNIEnv * env - , jclass contextClass - , jobject contextObject -#endif ) { return LogManagerFactory::Get(config, status, httpClient); @@ -22,11 +17,6 @@ namespace ARIASDK_NS_BEGIN { ILogManager* LogManagerProvider::Get( const char * moduleName, status_t& status -#ifdef ANDROID - JNIEnv *env, - jclass contextClass, - jobject contextObject, -#endif ) { return LogManagerFactory::Get(moduleName, status); From 31e42d3a02bcd506df1b5c2eb46abb996de31017 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Wed, 19 Jun 2019 21:34:04 +0000 Subject: [PATCH 08/15] Merged PR 1086962: Samples and build scripts clean-up - Add sample app for compact SDK flavor (sample for MS Edge installer scenario) - Allow to build SDK without sudo / root - Remove unnecessary temporary auto-generated files - Move UTC sample to new location (in a private GitHub submodule) --- Solutions/MSTelemetrySDK.sln | 45 + build-gtest.sh | 3 +- build.sh | 12 +- examples/cpp/SampleCpp/out/Makefile | 238 --- .../cpp/SampleCpp/out/cmake_install.cmake | 44 - examples/cpp/SampleCppMini/CMakeLists.txt | 49 + .../cpp/SampleCppMini/SampleCppMini.vcxproj | 1571 +++++++++++++++++ .../SampleCppMini.vcxproj.filters | 33 + examples/cpp/SampleCppMini/build.sh | 7 + examples/cpp/SampleCppMini/demo.c | 66 + examples/cpp/SampleCppMini/deploy-dll.cmd | 3 + examples/cpp/SampleCppMini/main.cpp | 111 ++ examples/cpp/SampleCppMini/run-tests.sh | 48 + lib/include/public/Version.hpp | 6 +- lib/modules/.gitignore | 330 ++++ lib/modules/{README => README.md} | 0 .../examples/cpp/SampleCppUTC/.gitignore | 5 + .../cpp/SampleCppUTC/DebugCallback.cpp | 150 ++ .../cpp/SampleCppUTC/DebugCallback.hpp | 24 + .../cpp/SampleCppUTC/SampleCppUTC.vcxproj | 1138 ++++++++++++ .../SampleCppUTC/SampleCppUTC.vcxproj.filters | 27 + .../examples/cpp/SampleCppUTC/deploy-dll.cmd | 14 + .../examples/cpp/SampleCppUTC/main.cpp | 106 ++ 23 files changed, 3741 insertions(+), 289 deletions(-) delete mode 100644 examples/cpp/SampleCpp/out/Makefile delete mode 100644 examples/cpp/SampleCpp/out/cmake_install.cmake create mode 100644 examples/cpp/SampleCppMini/CMakeLists.txt create mode 100644 examples/cpp/SampleCppMini/SampleCppMini.vcxproj create mode 100644 examples/cpp/SampleCppMini/SampleCppMini.vcxproj.filters create mode 100644 examples/cpp/SampleCppMini/build.sh create mode 100644 examples/cpp/SampleCppMini/demo.c create mode 100644 examples/cpp/SampleCppMini/deploy-dll.cmd create mode 100644 examples/cpp/SampleCppMini/main.cpp create mode 100644 examples/cpp/SampleCppMini/run-tests.sh create mode 100644 lib/modules/.gitignore rename lib/modules/{README => README.md} (100%) create mode 100644 lib/modules/examples/cpp/SampleCppUTC/.gitignore create mode 100644 lib/modules/examples/cpp/SampleCppUTC/DebugCallback.cpp create mode 100644 lib/modules/examples/cpp/SampleCppUTC/DebugCallback.hpp create mode 100644 lib/modules/examples/cpp/SampleCppUTC/SampleCppUTC.vcxproj create mode 100644 lib/modules/examples/cpp/SampleCppUTC/SampleCppUTC.vcxproj.filters create mode 100644 lib/modules/examples/cpp/SampleCppUTC/deploy-dll.cmd create mode 100644 lib/modules/examples/cpp/SampleCppUTC/main.cpp diff --git a/Solutions/MSTelemetrySDK.sln b/Solutions/MSTelemetrySDK.sln index c1bdb4d21..180f00e40 100644 --- a/Solutions/MSTelemetrySDK.sln +++ b/Solutions/MSTelemetrySDK.sln @@ -119,6 +119,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "decoder", "..\lib\decoder\d EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleCppLogManagers", "..\examples\cpp\SampleCppLogManagers\SampleCppLogManagers.vcxproj", "{77053F92-F003-4D1C-A489-1DEB7CFEA4EC}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleCppMini", "..\examples\cpp\SampleCppMini\SampleCppMini.vcxproj", "{86AC752C-5687-4377-841E-943D9BEEF361}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution ..\lib\pal\universal\universal.vcxitems*{10e9165b-49d1-4d1c-8248-334b9905b9cc}*SharedItemsImports = 9 @@ -1095,6 +1097,48 @@ Global {77053F92-F003-4D1C-A489-1DEB7CFEA4EC}.Release|Win32.Build.0 = Release|Win32 {77053F92-F003-4D1C-A489-1DEB7CFEA4EC}.Release|x64.ActiveCfg = Release|x64 {77053F92-F003-4D1C-A489-1DEB7CFEA4EC}.Release|x64.Build.0 = Release|x64 + {86AC752C-5687-4377-841E-943D9BEEF361}.Debug.static|ARM.ActiveCfg = Debug.static|Win32 + {86AC752C-5687-4377-841E-943D9BEEF361}.Debug.static|ARM64.ActiveCfg = Debug.static|ARM64 + {86AC752C-5687-4377-841E-943D9BEEF361}.Debug.static|ARM64.Build.0 = Debug.static|ARM64 + {86AC752C-5687-4377-841E-943D9BEEF361}.Debug.static|Win32.ActiveCfg = Debug.static|Win32 + {86AC752C-5687-4377-841E-943D9BEEF361}.Debug.static|Win32.Build.0 = Debug.static|Win32 + {86AC752C-5687-4377-841E-943D9BEEF361}.Debug.static|x64.ActiveCfg = Debug.static|x64 + {86AC752C-5687-4377-841E-943D9BEEF361}.Debug.static|x64.Build.0 = Debug.static|x64 + {86AC752C-5687-4377-841E-943D9BEEF361}.Debug.vs2015.MT-sqlite|ARM.ActiveCfg = Debug.vs2015.MT-sqlite|Win32 + {86AC752C-5687-4377-841E-943D9BEEF361}.Debug.vs2015.MT-sqlite|ARM64.ActiveCfg = Debug.vs2015.MT-sqlite|ARM64 + {86AC752C-5687-4377-841E-943D9BEEF361}.Debug.vs2015.MT-sqlite|ARM64.Build.0 = Debug.vs2015.MT-sqlite|ARM64 + {86AC752C-5687-4377-841E-943D9BEEF361}.Debug.vs2015.MT-sqlite|Win32.ActiveCfg = Debug.vs2015.MT-sqlite|Win32 + {86AC752C-5687-4377-841E-943D9BEEF361}.Debug.vs2015.MT-sqlite|Win32.Build.0 = Debug.vs2015.MT-sqlite|Win32 + {86AC752C-5687-4377-841E-943D9BEEF361}.Debug.vs2015.MT-sqlite|x64.ActiveCfg = Debug.vs2015.MT-sqlite|x64 + {86AC752C-5687-4377-841E-943D9BEEF361}.Debug.vs2015.MT-sqlite|x64.Build.0 = Debug.vs2015.MT-sqlite|x64 + {86AC752C-5687-4377-841E-943D9BEEF361}.Debug|ARM.ActiveCfg = Debug|Win32 + {86AC752C-5687-4377-841E-943D9BEEF361}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {86AC752C-5687-4377-841E-943D9BEEF361}.Debug|ARM64.Build.0 = Debug|ARM64 + {86AC752C-5687-4377-841E-943D9BEEF361}.Debug|Win32.ActiveCfg = Debug|Win32 + {86AC752C-5687-4377-841E-943D9BEEF361}.Debug|Win32.Build.0 = Debug|Win32 + {86AC752C-5687-4377-841E-943D9BEEF361}.Debug|x64.ActiveCfg = Debug|x64 + {86AC752C-5687-4377-841E-943D9BEEF361}.Debug|x64.Build.0 = Debug|x64 + {86AC752C-5687-4377-841E-943D9BEEF361}.Release.static|ARM.ActiveCfg = Release.static|Win32 + {86AC752C-5687-4377-841E-943D9BEEF361}.Release.static|ARM64.ActiveCfg = Release.static|ARM64 + {86AC752C-5687-4377-841E-943D9BEEF361}.Release.static|ARM64.Build.0 = Release.static|ARM64 + {86AC752C-5687-4377-841E-943D9BEEF361}.Release.static|Win32.ActiveCfg = Release.static|Win32 + {86AC752C-5687-4377-841E-943D9BEEF361}.Release.static|Win32.Build.0 = Release.static|Win32 + {86AC752C-5687-4377-841E-943D9BEEF361}.Release.static|x64.ActiveCfg = Release.static|x64 + {86AC752C-5687-4377-841E-943D9BEEF361}.Release.static|x64.Build.0 = Release.static|x64 + {86AC752C-5687-4377-841E-943D9BEEF361}.Release.vs2015.MT-sqlite|ARM.ActiveCfg = Release.vs2015.MT-sqlite|Win32 + {86AC752C-5687-4377-841E-943D9BEEF361}.Release.vs2015.MT-sqlite|ARM64.ActiveCfg = Release.vs2015.MT-sqlite|ARM64 + {86AC752C-5687-4377-841E-943D9BEEF361}.Release.vs2015.MT-sqlite|ARM64.Build.0 = Release.vs2015.MT-sqlite|ARM64 + {86AC752C-5687-4377-841E-943D9BEEF361}.Release.vs2015.MT-sqlite|Win32.ActiveCfg = Release.vs2015.MT-sqlite|Win32 + {86AC752C-5687-4377-841E-943D9BEEF361}.Release.vs2015.MT-sqlite|Win32.Build.0 = Release.vs2015.MT-sqlite|Win32 + {86AC752C-5687-4377-841E-943D9BEEF361}.Release.vs2015.MT-sqlite|x64.ActiveCfg = Release.vs2015.MT-sqlite|x64 + {86AC752C-5687-4377-841E-943D9BEEF361}.Release.vs2015.MT-sqlite|x64.Build.0 = Release.vs2015.MT-sqlite|x64 + {86AC752C-5687-4377-841E-943D9BEEF361}.Release|ARM.ActiveCfg = Release|Win32 + {86AC752C-5687-4377-841E-943D9BEEF361}.Release|ARM64.ActiveCfg = Release|ARM64 + {86AC752C-5687-4377-841E-943D9BEEF361}.Release|ARM64.Build.0 = Release|ARM64 + {86AC752C-5687-4377-841E-943D9BEEF361}.Release|Win32.ActiveCfg = Release|Win32 + {86AC752C-5687-4377-841E-943D9BEEF361}.Release|Win32.Build.0 = Release|Win32 + {86AC752C-5687-4377-841E-943D9BEEF361}.Release|x64.ActiveCfg = Release|x64 + {86AC752C-5687-4377-841E-943D9BEEF361}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1121,6 +1165,7 @@ Global {65AFA0E2-F9A2-4309-87E7-E419D59583C1} = {11A3C4B2-1800-4A80-9771-E92E98B9485B} {F797B22C-A1C4-4136-9DCC-0682A183A4DA} = {11A3C4B2-1800-4A80-9771-E92E98B9485B} {77053F92-F003-4D1C-A489-1DEB7CFEA4EC} = {D31B3404-AE47-4D0A-9A59-C321164F945C} + {86AC752C-5687-4377-841E-943D9BEEF361} = {D31B3404-AE47-4D0A-9A59-C321164F945C} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {7EE8585B-C10F-4DAC-BDAF-3726EDF8FCD7} diff --git a/build-gtest.sh b/build-gtest.sh index f5aa23d22..3d4aee5f0 100755 --- a/build-gtest.sh +++ b/build-gtest.sh @@ -1,8 +1,9 @@ #!/usr/bin/env bash -cd "$(dirname "$0")" +cd `dirname $0` cd googletest set -evx env | sort +rm -rf build mkdir -p build || true cd build cmake -Dgtest_build_samples=ON \ diff --git a/build.sh b/build.sh index 6f2f89138..26451a398 100755 --- a/build.sh +++ b/build.sh @@ -6,6 +6,8 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" echo "Current directory: $DIR" cd $DIR +export NOROOT=$NOROOT + if [ "$1" == "clean" ]; then rm -f CMakeCache.txt *.cmake rm -rf out @@ -13,13 +15,17 @@ if [ "$1" == "clean" ]; then # make clean fi +if [ "$1" == "noroot" ] || [ "$2" == "noroot" ]; then +export NOROOT=true +fi + # Install build tools and recent sqlite3 FILE=.buildtools OS_NAME=`uname -a` if [ ! -f $FILE ]; then case "$OS_NAME" in *Darwin*) tools/setup-buildtools-mac.sh ;; - *Linux*) sudo tools/setup-buildtools.sh ;; + *Linux*) [[ -z "$NOROOT" ]] && sudo tools/setup-buildtools.sh || echo "No root: skipping build tools installation." ;; *) echo "WARNING: unsupported OS $OS_NAME , skipping build tools installation.." esac # Assume that the build tools have been successfully installed @@ -83,12 +89,12 @@ make package # Debian / Ubuntu / Raspbian if [ -f /usr/bin/dpkg ]; then # Install new package -sudo dpkg -i *.deb +[[ -z "$NOROOT" ]] && sudo dpkg -i *.deb || echo "No root: skipping package deployment." fi # RedHat / CentOS if [ -f /usr/bin/rpmbuild ]; then -sudo rpm -i --force -v *.rpm +[[ -z "$NOROOT" ]] && sudo rpm -i --force -v *.rpm || echo "No root: skipping package deployment." fi # Install SDK headers and lib to /usr/local diff --git a/examples/cpp/SampleCpp/out/Makefile b/examples/cpp/SampleCpp/out/Makefile deleted file mode 100644 index ab7a1dcc4..000000000 --- a/examples/cpp/SampleCpp/out/Makefile +++ /dev/null @@ -1,238 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.12 - -# Default target executed when no arguments are given to make. -default_target: all - -.PHONY : default_target - -# Allow only one "make -f Makefile2" at a time, but pass parallelism. -.NOTPARALLEL: - - -#============================================================================= -# Special targets provided by cmake. - -# Disable implicit rules so canonical targets will work. -.SUFFIXES: - - -# Remove some rules from gmake that .SUFFIXES does not remove. -SUFFIXES = - -.SUFFIXES: .hpux_make_needs_suffix_list - - -# Suppress display of executed commands. -$(VERBOSE).SILENT: - - -# A target that is always out of date. -cmake_force: - -.PHONY : cmake_force - -#============================================================================= -# Set environment variables for the build. - -# The shell in which to execute make rules. -SHELL = /bin/sh - -# The CMake executable. -CMAKE_COMMAND = /usr/local/Cellar/cmake/3.12.4/bin/cmake - -# The command to remove a file. -RM = /usr/local/Cellar/cmake/3.12.4/bin/cmake -E remove -f - -# Escaping for special characters. -EQUALS = = - -# The top-level source directory on which CMake was run. -CMAKE_SOURCE_DIR = /build/Aria.SDK.Cpp/examples/Cpp/SampleCpp - -# The top-level build directory on which CMake was run. -CMAKE_BINARY_DIR = /build/Aria.SDK.Cpp/examples/Cpp/SampleCpp/out - -#============================================================================= -# Targets provided globally by CMake. - -# Special rule for the target rebuild_cache -rebuild_cache: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." - /usr/local/Cellar/cmake/3.12.4/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) -.PHONY : rebuild_cache - -# Special rule for the target rebuild_cache -rebuild_cache/fast: rebuild_cache - -.PHONY : rebuild_cache/fast - -# Special rule for the target edit_cache -edit_cache: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..." - /usr/local/Cellar/cmake/3.12.4/bin/ccmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) -.PHONY : edit_cache - -# Special rule for the target edit_cache -edit_cache/fast: edit_cache - -.PHONY : edit_cache/fast - -# The main all target -all: cmake_check_build_system - $(CMAKE_COMMAND) -E cmake_progress_start /build/Aria.SDK.Cpp/examples/Cpp/SampleCpp/out/CMakeFiles /build/Aria.SDK.Cpp/examples/Cpp/SampleCpp/out/CMakeFiles/progress.marks - $(MAKE) -f CMakeFiles/Makefile2 all - $(CMAKE_COMMAND) -E cmake_progress_start /build/Aria.SDK.Cpp/examples/Cpp/SampleCpp/out/CMakeFiles 0 -.PHONY : all - -# The main clean target -clean: - $(MAKE) -f CMakeFiles/Makefile2 clean -.PHONY : clean - -# The main clean target -clean/fast: clean - -.PHONY : clean/fast - -# Prepare targets for installation. -preinstall: all - $(MAKE) -f CMakeFiles/Makefile2 preinstall -.PHONY : preinstall - -# Prepare targets for installation. -preinstall/fast: - $(MAKE) -f CMakeFiles/Makefile2 preinstall -.PHONY : preinstall/fast - -# clear depends -depend: - $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 -.PHONY : depend - -#============================================================================= -# Target rules for targets named SampleCpp - -# Build rule for target. -SampleCpp: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 SampleCpp -.PHONY : SampleCpp - -# fast build rule for target. -SampleCpp/fast: - $(MAKE) -f CMakeFiles/SampleCpp.dir/build.make CMakeFiles/SampleCpp.dir/build -.PHONY : SampleCpp/fast - -DebugCallback.o: DebugCallback.cpp.o - -.PHONY : DebugCallback.o - -# target to build an object file -DebugCallback.cpp.o: - $(MAKE) -f CMakeFiles/SampleCpp.dir/build.make CMakeFiles/SampleCpp.dir/DebugCallback.cpp.o -.PHONY : DebugCallback.cpp.o - -DebugCallback.i: DebugCallback.cpp.i - -.PHONY : DebugCallback.i - -# target to preprocess a source file -DebugCallback.cpp.i: - $(MAKE) -f CMakeFiles/SampleCpp.dir/build.make CMakeFiles/SampleCpp.dir/DebugCallback.cpp.i -.PHONY : DebugCallback.cpp.i - -DebugCallback.s: DebugCallback.cpp.s - -.PHONY : DebugCallback.s - -# target to generate assembly for a file -DebugCallback.cpp.s: - $(MAKE) -f CMakeFiles/SampleCpp.dir/build.make CMakeFiles/SampleCpp.dir/DebugCallback.cpp.s -.PHONY : DebugCallback.cpp.s - -demo.o: demo.c.o - -.PHONY : demo.o - -# target to build an object file -demo.c.o: - $(MAKE) -f CMakeFiles/SampleCpp.dir/build.make CMakeFiles/SampleCpp.dir/demo.c.o -.PHONY : demo.c.o - -demo.i: demo.c.i - -.PHONY : demo.i - -# target to preprocess a source file -demo.c.i: - $(MAKE) -f CMakeFiles/SampleCpp.dir/build.make CMakeFiles/SampleCpp.dir/demo.c.i -.PHONY : demo.c.i - -demo.s: demo.c.s - -.PHONY : demo.s - -# target to generate assembly for a file -demo.c.s: - $(MAKE) -f CMakeFiles/SampleCpp.dir/build.make CMakeFiles/SampleCpp.dir/demo.c.s -.PHONY : demo.c.s - -main.o: main.cpp.o - -.PHONY : main.o - -# target to build an object file -main.cpp.o: - $(MAKE) -f CMakeFiles/SampleCpp.dir/build.make CMakeFiles/SampleCpp.dir/main.cpp.o -.PHONY : main.cpp.o - -main.i: main.cpp.i - -.PHONY : main.i - -# target to preprocess a source file -main.cpp.i: - $(MAKE) -f CMakeFiles/SampleCpp.dir/build.make CMakeFiles/SampleCpp.dir/main.cpp.i -.PHONY : main.cpp.i - -main.s: main.cpp.s - -.PHONY : main.s - -# target to generate assembly for a file -main.cpp.s: - $(MAKE) -f CMakeFiles/SampleCpp.dir/build.make CMakeFiles/SampleCpp.dir/main.cpp.s -.PHONY : main.cpp.s - -# Help Target -help: - @echo "The following are some of the valid targets for this Makefile:" - @echo "... all (the default if no target is provided)" - @echo "... clean" - @echo "... depend" - @echo "... rebuild_cache" - @echo "... edit_cache" - @echo "... SampleCpp" - @echo "... DebugCallback.o" - @echo "... DebugCallback.i" - @echo "... DebugCallback.s" - @echo "... demo.o" - @echo "... demo.i" - @echo "... demo.s" - @echo "... main.o" - @echo "... main.i" - @echo "... main.s" -.PHONY : help - - - -#============================================================================= -# Special targets to cleanup operation of make. - -# Special rule to run CMake to check the build system integrity. -# No rule that depends on this can have commands that come from listfiles -# because they might be regenerated. -cmake_check_build_system: - $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 -.PHONY : cmake_check_build_system - diff --git a/examples/cpp/SampleCpp/out/cmake_install.cmake b/examples/cpp/SampleCpp/out/cmake_install.cmake deleted file mode 100644 index 3f6da0c3f..000000000 --- a/examples/cpp/SampleCpp/out/cmake_install.cmake +++ /dev/null @@ -1,44 +0,0 @@ -# Install script for directory: /build/Aria.SDK.Cpp/examples/Cpp/SampleCpp - -# Set the install prefix -if(NOT DEFINED CMAKE_INSTALL_PREFIX) - set(CMAKE_INSTALL_PREFIX "/usr/local") -endif() -string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") - -# Set the install configuration name. -if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) - if(BUILD_TYPE) - string(REGEX REPLACE "^[^A-Za-z0-9_]+" "" - CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") - else() - set(CMAKE_INSTALL_CONFIG_NAME "") - endif() - message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") -endif() - -# Set the component getting installed. -if(NOT CMAKE_INSTALL_COMPONENT) - if(COMPONENT) - message(STATUS "Install component: \"${COMPONENT}\"") - set(CMAKE_INSTALL_COMPONENT "${COMPONENT}") - else() - set(CMAKE_INSTALL_COMPONENT) - endif() -endif() - -# Is this installation the result of a crosscompile? -if(NOT DEFINED CMAKE_CROSSCOMPILING) - set(CMAKE_CROSSCOMPILING "FALSE") -endif() - -if(CMAKE_INSTALL_COMPONENT) - set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt") -else() - set(CMAKE_INSTALL_MANIFEST "install_manifest.txt") -endif() - -string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT - "${CMAKE_INSTALL_MANIFEST_FILES}") -file(WRITE "/build/Aria.SDK.Cpp/examples/Cpp/SampleCpp/out/${CMAKE_INSTALL_MANIFEST}" - "${CMAKE_INSTALL_MANIFEST_CONTENT}") diff --git a/examples/cpp/SampleCppMini/CMakeLists.txt b/examples/cpp/SampleCppMini/CMakeLists.txt new file mode 100644 index 000000000..5839e709f --- /dev/null +++ b/examples/cpp/SampleCppMini/CMakeLists.txt @@ -0,0 +1,49 @@ +cmake_minimum_required(VERSION 3.1.0) +project(SampleCppMini) + +# Uncomment for building i386 binary on x86_64 system +#set(CMAKE_SYSTEM_PROCESSOR i386) + +# For ARM / Raspberry Pi 3 cross-compile +# set(MAT_SDK_LIB /usr/local/lib/armv7l-linux-gnu) + +# Point example to SDK dirs for x86_64 Desktop +if(EXISTS "/usr/local/lib/libmat.a") +# Use local libmat.a +set(MAT_SDK_LIB /usr/local/lib/) +else() +# Use architecture-specific libmat.a +set(MAT_SDK_LIB /usr/local/lib/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu) +endif() + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -ggdb -gdwarf-2 -std=c11") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -ggdb -gdwarf-2 -std=c++11") + +find_package (Threads) + +set(MAT_SDK_INCLUDE /usr/local/include/aria) + +# Aria SDK to include dirs +include_directories( . ${MAT_SDK_INCLUDE} ) + +# Link main.cpp to executable +add_executable(SampleCppMini main.cpp DebugCallback.cpp demo.c) +source_group(" " REGULAR_EXPRESSION "") + +# Prefer linking to more recent local sqlite3 +if(EXISTS "/usr/local/lib/libsqlite3.a") +set (SQLITE3_LIB "/usr/local/lib/libsqlite3.a") +else() +set (SQLITE3_LIB "sqlite3") +endif() + +set (PLATFORM_LIBS "") +# Add flags for obtaining system UUID via IOKit +if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") +set (PLATFORM_LIBS "-framework CoreFoundation -framework IOKit") +endif() + +#tcmalloc turned off by default +#target_link_libraries(SampleCppMini ${MAT_SDK_LIB}/libmat.a curl z ${CMAKE_THREAD_LIBS_INIT} ${SQLITE3_LIB} dl tcmalloc) + +target_link_libraries(SampleCppMini ${MAT_SDK_LIB}/libmat.a curl z ${CMAKE_THREAD_LIBS_INIT} ${SQLITE3_LIB} ${PLATFORM_LIBS} dl) diff --git a/examples/cpp/SampleCppMini/SampleCppMini.vcxproj b/examples/cpp/SampleCppMini/SampleCppMini.vcxproj new file mode 100644 index 000000000..97bd892ad --- /dev/null +++ b/examples/cpp/SampleCppMini/SampleCppMini.vcxproj @@ -0,0 +1,1571 @@ + + + + + Debug.static + ARM64 + + + Debug.static + Win32 + + + Debug.static + x64 + + + Debug.vs2015.MT-sqlite + ARM64 + + + Debug.vs2015.MT-sqlite + Win32 + + + Debug.vs2015.MT-sqlite + x64 + + + Debug + ARM64 + + + Debug + Win32 + + + Release.static + ARM64 + + + Release.static + Win32 + + + Release.static + x64 + + + Release.vs2015.MT-sqlite + ARM64 + + + Release.vs2015.MT-sqlite + Win32 + + + Release.vs2015.MT-sqlite + x64 + + + Release + ARM64 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {86AC752C-5687-4377-841E-943D9BEEF361} + Win32Proj + SampleCppMini + 10.0.17763.0 + true + + + + Application + true + v141 + Unicode + Static + + + Application + true + v141 + Unicode + Static + + + Application + true + v141 + Unicode + Static + + + Application + false + v141 + true + Unicode + Static + + + Application + false + v141 + true + Unicode + Static + + + Application + false + v141 + true + Unicode + Static + + + Application + true + v141 + Unicode + Static + + + Application + true + v141 + Unicode + Static + + + Application + true + v141 + Unicode + Static + + + Application + true + v141 + Unicode + Static + + + Application + true + v141 + Unicode + Static + + + Application + true + v141 + Unicode + Static + + + Application + false + v141 + true + Unicode + Static + + + Application + false + v141 + true + Unicode + Static + + + Application + false + v141 + true + Unicode + Static + + + Application + false + v141 + true + Unicode + Static + + + Application + false + v141 + true + Unicode + Static + + + Application + false + v141 + true + Unicode + Static + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + + + true + false + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + true + false + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + true + false + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + true + false + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + true + false + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + true + false + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + + + true + false + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + true + false + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + true + false + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + + + true + false + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + true + false + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + true + false + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + true + false + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + true + false + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + true + false + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + + + true + false + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + true + false + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + true + false + + + + NotUsing + Level3 + MinSpace + false + false + true + HAVE_MAT_SHORT_NS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + + Guard + Default + true + false + false + false + false + false + false + Disabled + Size + true + Fast + false + + + + Console + true + true + true + false + true + true + Default + false + /merge:.rdata=.text + false + API-MS-WIN-CORE-WINRT-STRING-L1-1-0;API-MS-WIN-CORE-WINRT-L1-1-0 + + + $(ProjectDir)\deploy-dll.cmd $(PlatformTarget) $(Configuration) $(OutDir) + Copy DLL to target dir + + + + + + + type nul >> main.cpp + + + + + NotUsing + Level3 + MinSpace + false + false + true + HAVE_MAT_SHORT_NS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + + + Guard + Default + true + false + false + false + false + false + false + Disabled + Size + true + Fast + false + + + + Console + true + true + true + false + true + true + Default + false + /merge:.rdata=.text + false + API-MS-WIN-CORE-WINRT-STRING-L1-1-0;API-MS-WIN-CORE-WINRT-L1-1-0 + + + $(ProjectDir)\deploy-dll.cmd $(PlatformTarget) $(Configuration) $(OutDir) + + + Copy DLL to target dir + + + + + + + type nul >> main.cpp + + + + + + + + + NotUsing + Level3 + MinSpace + false + false + true + HAVE_MAT_SHORT_NS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + + + Guard + Default + true + Cdecl + false + false + false + false + false + false + Disabled + Size + true + Fast + false + + + + Console + true + true + true + wininet.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + false + true + true + Default + false + /merge:.rdata=.text + false + API-MS-WIN-CORE-WINRT-STRING-L1-1-0;API-MS-WIN-CORE-WINRT-L1-1-0 + + + $(ProjectDir)\deploy-dll.cmd $(PlatformTarget) $(Configuration) $(OutDir) + + + Copy DLL to target dir + + + + + + + type nul >> main.cpp + + + + + + + + + NotUsing + Level3 + MinSpace + false + false + true + HAVE_MAT_SHORT_NS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + + + Guard + Default + true + MultiThreaded + false + false + false + false + false + false + Disabled + Size + true + Fast + false + + false + + + Console + true + true + true + libcmt.lib;libvcruntime.lib;libucrt.lib;Version.lib;wininet.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + true + false + true + Default + false + /merge:.rdata=.text + false + false + API-MS-WIN-CORE-WINRT-STRING-L1-1-0;API-MS-WIN-CORE-WINRT-L1-1-0 + + + $(ProjectDir)\deploy-dll.cmd $(PlatformTarget) $(Configuration) $(OutDir) + + + Copy DLL to target dir + + + + + + + type nul >> main.cpp + + + + + + + + + NotUsing + Level3 + MinSpace + false + false + true + HAVE_MAT_SHORT_NS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + + + Guard + Default + true + Cdecl + false + false + false + false + false + false + Disabled + Size + true + Fast + false + + + + Console + true + true + true + wininet.lib;kernel32.lib;user32.lib;%(AdditionalDependencies) + false + true + true + Default + false + /merge:.rdata=.text + false + API-MS-WIN-CORE-WINRT-STRING-L1-1-0;API-MS-WIN-CORE-WINRT-L1-1-0 + + + $(ProjectDir)\deploy-dll.cmd $(PlatformTarget) $(Configuration) $(OutDir) + + + Copy DLL to target dir + + + + + + + type nul >> main.cpp + + + + + + + + + NotUsing + Level3 + MinSpace + false + false + true + HAVE_MAT_SHORT_NS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + + + Guard + Default + true + MultiThreaded + false + false + false + false + false + false + Disabled + Size + true + Fast + false + + false + + + Console + true + true + true + libcmt.lib;libvcruntime.lib;libucrt.lib;Version.lib;wininet.lib;kernel32.lib;user32.lib;%(AdditionalDependencies) + true + false + true + Default + false + /merge:.rdata=.text + false + false + API-MS-WIN-CORE-WINRT-STRING-L1-1-0;API-MS-WIN-CORE-WINRT-L1-1-0 + + + $(ProjectDir)\deploy-dll.cmd $(PlatformTarget) $(Configuration) $(OutDir) + + + Copy DLL to target dir + + + + + + + type nul >> main.cpp + + + + + + + + + NotUsing + Level3 + MinSpace + true + HAVE_MAT_SHORT_NS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + + Guard + ProgramDatabase + true + true + false + false + false + false + true + Default + false + false + false + Disabled + Size + false + Fast + false + + + + Console + true + false + true + true + true + true + Default + false + /merge:.rdata=.text + false + API-MS-WIN-CORE-WINRT-STRING-L1-1-0;API-MS-WIN-CORE-WINRT-L1-1-0 + + + $(ProjectDir)\deploy-dll.cmd $(PlatformTarget) $(Configuration) $(OutDir) + + + Copy DLL to target dir + + + + + + + type nul >> main.cpp + + + + + + + + + NotUsing + Level3 + MinSpace + true + HAVE_MAT_SHORT_NS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + + + Guard + ProgramDatabase + true + true + false + false + false + false + true + Default + false + false + false + Disabled + Size + false + Fast + false + + + + Console + true + wininet.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + false + true + true + true + true + Default + false + /merge:.rdata=.text + false + API-MS-WIN-CORE-WINRT-STRING-L1-1-0;API-MS-WIN-CORE-WINRT-L1-1-0 + + + $(ProjectDir)\deploy-dll.cmd $(PlatformTarget) $(Configuration) $(OutDir) + + + Copy DLL to target dir + + + + + + + type nul >> main.cpp + + + + + + + + + NotUsing + Level3 + MinSpace + true + HAVE_MAT_SHORT_NS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + + + Guard + ProgramDatabase + true + true + false + MultiThreadedDebug + false + false + false + true + Default + false + false + false + Disabled + Size + false + Fast + false + + + + Console + true + libucrtd.lib;Version.lib;wininet.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + false + true + true + true + true + Default + false + /merge:.rdata=.text + false + API-MS-WIN-CORE-WINRT-STRING-L1-1-0;API-MS-WIN-CORE-WINRT-L1-1-0 + + + $(ProjectDir)\deploy-dll.cmd $(PlatformTarget) $(Configuration) $(OutDir) + + + Copy DLL to target dir + + + + + + + type nul >> main.cpp + + + + + + + + + NotUsing + Level3 + MinSpace + true + HAVE_MAT_SHORT_NS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + + Guard + ProgramDatabase + true + false + false + false + true + Default + false + false + false + false + Disabled + Size + true + false + Fast + false + + + + Console + true + false + true + true + true + true + Default + false + /merge:.rdata=.text + false + API-MS-WIN-CORE-WINRT-STRING-L1-1-0;API-MS-WIN-CORE-WINRT-L1-1-0 + + + $(ProjectDir)\deploy-dll.cmd $(PlatformTarget) $(Configuration) $(OutDir) + + + Copy DLL to target dir + + + + + + + type nul >> main.cpp + + + + + + + + + NotUsing + Level3 + MinSpace + true + HAVE_MAT_SHORT_NS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + + + Guard + ProgramDatabase + true + false + false + false + true + Default + false + false + false + false + Disabled + Size + true + false + Fast + false + + + + Console + true + false + true + true + true + true + Default + false + /merge:.rdata=.text + false + API-MS-WIN-CORE-WINRT-STRING-L1-1-0;API-MS-WIN-CORE-WINRT-L1-1-0 + + + $(ProjectDir)\deploy-dll.cmd $(PlatformTarget) $(Configuration) $(OutDir) + + + Copy DLL to target dir + + + + + + + type nul >> main.cpp + + + + + + + + + NotUsing + Level3 + MinSpace + true + HAVE_MAT_SHORT_NS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + + + Guard + ProgramDatabase + true + Cdecl + false + false + false + true + Default + false + false + false + false + Disabled + Size + true + false + Fast + false + + + + Console + true + wininet.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + false + true + true + true + true + Default + false + /merge:.rdata=.text + false + API-MS-WIN-CORE-WINRT-STRING-L1-1-0;API-MS-WIN-CORE-WINRT-L1-1-0 + + + $(ProjectDir)\deploy-dll.cmd $(PlatformTarget) $(Configuration) $(OutDir) + + + Copy DLL to target dir + + + + + + + type nul >> main.cpp + + + + + + + + + NotUsing + Level3 + MinSpace + true + HAVE_MAT_SHORT_NS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + + + Guard + ProgramDatabase + true + MultiThreadedDebug + false + false + false + true + Default + false + false + false + false + Disabled + Size + true + false + Fast + false + + + + Console + true + libucrtd.lib;Version.lib;wininet.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + false + true + true + true + true + Default + false + /merge:.rdata=.text + false + API-MS-WIN-CORE-WINRT-STRING-L1-1-0;API-MS-WIN-CORE-WINRT-L1-1-0 + + + $(ProjectDir)\deploy-dll.cmd $(PlatformTarget) $(Configuration) $(OutDir) + + + Copy DLL to target dir + + + + + + + type nul >> main.cpp + + + + + + + + + NotUsing + Level3 + MinSpace + true + HAVE_MAT_SHORT_NS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + + + Guard + ProgramDatabase + true + false + false + false + true + Default + false + false + false + false + Disabled + Size + true + false + Fast + false + + + + Console + true + wininet.lib;kernel32.lib;user32.lib;%(AdditionalDependencies) + false + true + true + true + true + Default + false + /merge:.rdata=.text + false + API-MS-WIN-CORE-WINRT-STRING-L1-1-0;API-MS-WIN-CORE-WINRT-L1-1-0 + + + $(ProjectDir)\deploy-dll.cmd $(PlatformTarget) $(Configuration) $(OutDir) + + + Copy DLL to target dir + + + + + + + type nul >> main.cpp + + + + + + + + + NotUsing + Level3 + MinSpace + true + HAVE_MAT_SHORT_NS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + + + Guard + ProgramDatabase + true + MultiThreadedDebug + false + false + false + true + Default + false + false + false + false + Disabled + Size + true + false + Fast + false + + + + Console + true + libucrtd.lib;Version.lib;wininet.lib;kernel32.lib;user32.lib;%(AdditionalDependencies) + false + true + true + true + true + Default + false + /merge:.rdata=.text + false + API-MS-WIN-CORE-WINRT-STRING-L1-1-0;API-MS-WIN-CORE-WINRT-L1-1-0 + + + $(ProjectDir)\deploy-dll.cmd $(PlatformTarget) $(Configuration) $(OutDir) + + + Copy DLL to target dir + + + + + + + type nul >> main.cpp + + + + + + + + + NotUsing + Level3 + MinSpace + false + false + true + HAVE_MAT_SHORT_NS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + + Guard + Default + false + false + false + false + false + false + Disabled + Size + true + true + Fast + false + + + + Console + true + true + true + false + true + true + Default + false + /merge:.rdata=.text + false + API-MS-WIN-CORE-WINRT-STRING-L1-1-0;API-MS-WIN-CORE-WINRT-L1-1-0 + + + $(ProjectDir)\deploy-dll.cmd $(PlatformTarget) $(Configuration) $(OutDir) + + + Copy DLL to target dir + + + + + + + type nul >> main.cpp + + + + + + + + + NotUsing + Level3 + MinSpace + false + false + true + HAVE_MAT_SHORT_NS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + + + Guard + Default + Cdecl + false + false + false + false + false + false + Disabled + Size + true + true + Fast + false + + + + Console + true + true + true + wininet.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + false + true + true + Default + false + /merge:.rdata=.text + false + API-MS-WIN-CORE-WINRT-STRING-L1-1-0;API-MS-WIN-CORE-WINRT-L1-1-0 + + + $(ProjectDir)\deploy-dll.cmd $(PlatformTarget) $(Configuration) $(OutDir) + + + Copy DLL to target dir + + + + + + + type nul >> main.cpp + + + + + + + + + NotUsing + Level3 + MinSpace + false + false + true + HAVE_MAT_SHORT_NS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + + + Guard + Default + Cdecl + MultiThreaded + false + false + false + false + false + false + Disabled + Size + true + true + Fast + false + + false + + + Console + true + true + true + libcmt.lib;libvcruntime.lib;libucrt.lib;Version.lib;wininet.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + true + false + true + Default + false + /merge:.rdata=.text + false + false + API-MS-WIN-CORE-WINRT-STRING-L1-1-0;API-MS-WIN-CORE-WINRT-L1-1-0 + + + $(ProjectDir)\deploy-dll.cmd $(PlatformTarget) $(Configuration) $(OutDir) + + + Copy DLL to target dir + + + + + + + type nul >> main.cpp + + + + + + + + + + + + + + + + + + + + + + {1dc6b38a-b390-34ce-907f-4958807a3d43} + + + + + + \ No newline at end of file diff --git a/examples/cpp/SampleCppMini/SampleCppMini.vcxproj.filters b/examples/cpp/SampleCppMini/SampleCppMini.vcxproj.filters new file mode 100644 index 000000000..ad3de7523 --- /dev/null +++ b/examples/cpp/SampleCppMini/SampleCppMini.vcxproj.filters @@ -0,0 +1,33 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + + + Source Files + + + Source Files + + + + + + \ No newline at end of file diff --git a/examples/cpp/SampleCppMini/build.sh b/examples/cpp/SampleCppMini/build.sh new file mode 100644 index 000000000..e960f224b --- /dev/null +++ b/examples/cpp/SampleCppMini/build.sh @@ -0,0 +1,7 @@ +#!/bin/sh +mkdir -p out +cd out +cmake .. +make +# Strip for release +# strip SampleCppMini diff --git a/examples/cpp/SampleCppMini/demo.c b/examples/cpp/SampleCppMini/demo.c new file mode 100644 index 000000000..bad120b19 --- /dev/null +++ b/examples/cpp/SampleCppMini/demo.c @@ -0,0 +1,66 @@ +#include "mat.h" + +#include +#include + +void test_c_api(const char * token) +{ + +#if 0 /* No JSON parser in smallest SKU */ + static const char* config_template = + "{" + "\"cacheFilePath\":\"MyOfflineStorage.db\"," // Custom storage path + "\"config\":{\"host\": \"*\"}," // Attach as guest to any host + "\"name\":\"C-API-Client-0\"," // Module ID + "\"version\":\"1.0.0\"," // Module semver + "\"primaryToken\":\"%s\"," // Primary Token + "\"maxTeardownUploadTimeInSec\":5," // Allow up to 5 seconds for upload + "\"hostMode\":false," // Explicitly declare yourself as guest + "\"minimumTraceLevel\":0," // Debug printout level + "\"sdkmode\":0" // SDK direct-upload mode + "}"; + static char config[1024] = { 0 }; + snprintf(config, sizeof(config), config_template, token); +#endif + + printf("Testing C API...\t"); + +#if 1 // Initialize using TOKEN + evt_handle_t handle = evt_open(token); +#else // Initialize using ILogConfiguration in JSON format + evt_handle_t handle = evt_open((const char *)config); +#endif + + // Ref. https://docs.microsoft.com/en-us/windows/privacy/basic-level-windows-diagnostic-events-and-fields for description of Common Schema fields + evt_prop event[] = TELEMETRY_EVENT + ( + // Common Data Extensions.Envelope - reserved keywords that C API should not use. + // Alternate solution is to declare a special macro for envelope 'root' namespace props, + // such as $STR, $INT, etc. + _STR("name", "Event.Name.Pure.C"), // Represents the uniquely qualified name for the event + _STR("ver", "3.0"), // Represents the major and minor version of the extension + _STR("time", "1979-08-12"), // Represents the event date time in Coordinated Universal Time(UTC) when the event was generated on the client.This should be in ISO 8601 format + _INT("popSample", 100), // Represents the effective sample rate for this event at the time it was generated by a client + // FIXME: [MG] - iKey should only be needed if logging to alternate token, otherwise we should use the primaryToken by default + _STR("iKey", token), // Represents an ID for applications or other logical groupings of events. + _INT("flags", 0xffffffff), // Represents a collection of bits that describe how the event should be processed ... + _STR("cV", "12345"), // Represents the Correlation Vector : A single field for tracking partial order of related telemetry events across component boundaries. + // Customer Data fields go as part of userdata + _STR("strKey", "value1"), + _INT("intKey", 12345), + PII_STR("piiKey", "secret", 1), // TODO: copy-paste-translate the Pii Kind enum from C++ to C + // Part "X" demo - populating CS extension props + // Common Data Extensions.App + PII_STR("ext.app.userId", "jackfrost@microsoft.com", 1), + _STR("ext.app.ver", "1.0.0") + ); + + evt_log(handle, event); + evt_flush(handle); + // FIXME: [MG] - default settings are optimized for 'fast shutdown' and not giving enough time for SDK to upload the event logged. + // However, if you restart this sample - events from a previous run get uploaded. Modify the + evt_upload(handle); + evt_close(handle); + + printf("[ DONE ]\n"); +} diff --git a/examples/cpp/SampleCppMini/deploy-dll.cmd b/examples/cpp/SampleCppMini/deploy-dll.cmd new file mode 100644 index 000000000..bd98ed454 --- /dev/null +++ b/examples/cpp/SampleCppMini/deploy-dll.cmd @@ -0,0 +1,3 @@ +copy %3\..\win32-mini-dll\*.dll %3 +copy %3\..\win32-mini-dll\*.pdb %3 +exit /b 0 diff --git a/examples/cpp/SampleCppMini/main.cpp b/examples/cpp/SampleCppMini/main.cpp new file mode 100644 index 000000000..ed9ceed8c --- /dev/null +++ b/examples/cpp/SampleCppMini/main.cpp @@ -0,0 +1,111 @@ +#define _CRT_SECURE_NO_WARNINGS + +#define API_KEY "99999999999999999999999999999999-99999999-9999-9999-9999-999999999999-9999" + +#include +#include + +#include "LogManager.hpp" + +using namespace MAT; + +#ifdef _WIN32 +#pragma comment(lib, "Ole32.Lib") /* needed for CoCreateGuid */ +#pragma comment(lib, "Advapi32.Lib") /* needed for RegGetValueA */ +#endif + +LOGMANAGER_INSTANCE + +extern "C" void test_c_api(const char *token); + +void test_cpp_api(const char * token, int ticketType, const char *ticket) +{ + printf("Testing C++ API...\t"); + + // LogManager configuration + auto& config = LogManager::GetLogConfiguration(); + // config[CFG_INT_SDK_MODE] = SdkModeTypes::SdkModeTypes_UTCCommonSchema; + + // LogManager initialization + ILogger *logger = LogManager::Initialize(token); + + if (ticket != nullptr) + { + const char *ticketNames[7] = + { + "TicketType_MSA_Device", + "TicketType_MSA_User", + "TicketType_XAuth_Device", + "TicketType_XAuth_User", + "TicketType_AAD", + "TicketType_AAD_User", + "TicketType_AAD_JWT", + }; + printf("\nSet ticket %s=%s\n", ticketNames[ticketType], ticket); + auto tc = LogManager::GetAuthTokensController(); + tc->SetStrictMode(true); + tc->SetTicketToken((TicketType)ticketType, ticket); + } + + // Log simple event without any properties + logger->LogEvent("MyApp.simple_event"); + + ISemanticContext *global_ctx = LogManager::GetSemanticContext(); + auto local_ctx = logger->GetSemanticContext(); + logger->SetContext("Local.Context.Variable", "value"); + + // Log detailed event with various properties + EventProperties detailed_event("MyApp.detailed_event", + { + // Log compiler version + { "_MSC_VER", _MSC_VER }, + // Pii-typed fields + { "piiKind.None", EventProperty("field_value", PiiKind_None) }, + { "piiKind.DistinguishedName", EventProperty("/CN=Jack Frost,OU=PIE,DC=REDMOND,DC=COM", PiiKind_DistinguishedName) }, + { "piiKind.GenericData", EventProperty("generic_data", PiiKind_GenericData) }, + { "piiKind.IPv4Address", EventProperty("127.0.0.1", PiiKind_IPv4Address) }, + { "piiKind.IPv6Address", EventProperty("2001:0db8:85a3:0000:0000:8a2e:0370:7334", PiiKind_IPv6Address) }, + { "piiKind.MailSubject", EventProperty("RE: test", PiiKind_MailSubject) }, + { "piiKind.PhoneNumber", EventProperty("+1-425-829-5875", PiiKind_PhoneNumber) }, + { "piiKind.QueryString", EventProperty("a=1&b=2&c=3", PiiKind_QueryString) }, + { "piiKind.SipAddress", EventProperty("sip:info@microsoft.com", PiiKind_SipAddress) }, + { "piiKind.SmtpAddress", EventProperty("Jack Frost ", PiiKind_SmtpAddress) }, + { "piiKind.Identity", EventProperty("Jack Frost", PiiKind_Identity) }, + { "piiKind.Uri", EventProperty("http://www.microsoft.com", PiiKind_Uri) }, + { "piiKind.Fqdn", EventProperty("www.microsoft.com", PiiKind_Fqdn) }, + // Various typed key-values + { "strKey1", "hello1" }, + { "strKey2", "hello2" }, + { "int64Key", 1L }, + { "dblKey", 3.14 }, + { "boolKey", false }, + { "guidKey0", GUID_t("00000000-0000-0000-0000-000000000000") }, + { "guidKey1", GUID_t("00010203-0405-0607-0809-0A0B0C0D0E0F") }, + { "guidKey2", GUID_t("00010203-0405-0607-0809-0A0B0C0D0E0F") }, + { "timeKey1", time_ticks_t((uint64_t)0) }, // time in .NET ticks + }); + logger->LogEvent(detailed_event); + + // Shutdown + LogManager::FlushAndTeardown(); + + printf("[ DONE ]\n"); +} + +int main(int argc, const char *argv[]) +{ + printf("Microsoft Event Analytics 1DS pipe test tool \n"); + printf("=============================================\n"); + + const char *token = (argc > 1) ? argv[1] : API_KEY; + int type = (argc > 2) ? atoi(argv[2]) : TicketType::TicketType_MSA_Device; + const char *ticket = (argc > 3) ? argv[3] : nullptr; + + // Send event using C API + test_c_api(token); + + // Send event using C++ API + test_cpp_api(token, type, ticket); + + return 0; +} diff --git a/examples/cpp/SampleCppMini/run-tests.sh b/examples/cpp/SampleCppMini/run-tests.sh new file mode 100644 index 000000000..602efd2fc --- /dev/null +++ b/examples/cpp/SampleCppMini/run-tests.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +## +## Clean-up previous results +## +#sudo rm /tmp/aria*.log +#sudo rm offline* +#sudo rm -f heap* + +BIN=./out/SampleCppMini + +case $1 in + +"") + echo "Running basic test..." + $BIN + ;; + +1) + echo "Running heap check..." + export PPROF_PATH=/usr/local/bin + export HEAPCHECK=normal + $BIN + ;; + +2) + echo "Running gdb..." + gdb -ex=r --args $BIN + ;; + +3) + echo "Running valgrind..." + valgrind -v $BIN + ;; + +4) + echo "Running valgrind leak check..." + valgrind -v --track-origins=yes --leak-check=full $BIN + ;; + +5) + echo "Running cgroups 300MB memory test..." + cgcreate -g memory:/300MB + echo $(( 300 * 1024 * 1024 )) > /sys/fs/cgroup/memory/300MB/memory.limit_in_bytes + cgexec -g memory:/300MB $BIN + ;; + +esac diff --git a/lib/include/public/Version.hpp b/lib/include/public/Version.hpp index 4000c23e9..f5c239448 100644 --- a/lib/include/public/Version.hpp +++ b/lib/include/public/Version.hpp @@ -3,8 +3,8 @@ #define MAT_VERSION_HPP // WARNING: DO NOT MODIFY THIS FILE! // This file has been automatically generated, manual changes will be lost. -#define BUILD_VERSION_STR "3.2.143.1" -#define BUILD_VERSION 3,2,143,1 +#define BUILD_VERSION_STR "3.2.170.1" +#define BUILD_VERSION 3,2,170,1 #ifndef RESOURCE_COMPILER_INVOKED #include @@ -30,7 +30,7 @@ namespace ARIASDK_NS_BEGIN { uint64_t const Version = ((uint64_t)3 << 48) | ((uint64_t)2 << 32) | - ((uint64_t)143 << 16) | + ((uint64_t)170 << 16) | ((uint64_t)1); } ARIASDK_NS_END diff --git a/lib/modules/.gitignore b/lib/modules/.gitignore new file mode 100644 index 000000000..3e759b75b --- /dev/null +++ b/lib/modules/.gitignore @@ -0,0 +1,330 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ diff --git a/lib/modules/README b/lib/modules/README.md similarity index 100% rename from lib/modules/README rename to lib/modules/README.md diff --git a/lib/modules/examples/cpp/SampleCppUTC/.gitignore b/lib/modules/examples/cpp/SampleCppUTC/.gitignore new file mode 100644 index 000000000..99e2e36ac --- /dev/null +++ b/lib/modules/examples/cpp/SampleCppUTC/.gitignore @@ -0,0 +1,5 @@ +include +lib +offlinestorage*.* +Release +x64 diff --git a/lib/modules/examples/cpp/SampleCppUTC/DebugCallback.cpp b/lib/modules/examples/cpp/SampleCppUTC/DebugCallback.cpp new file mode 100644 index 000000000..2321333d5 --- /dev/null +++ b/lib/modules/examples/cpp/SampleCppUTC/DebugCallback.cpp @@ -0,0 +1,150 @@ +#include "DebugCallback.hpp" + +unsigned latency[MAX_LATENCY_SAMPLES] = { 0 }; + +std::atomic eps(0); +std::atomic numLogged0(0); +std::atomic numLogged(0); +std::atomic numSent(0); +std::atomic numDropped(0); +std::atomic numReject(0); +std::atomic numCached(0); +std::atomic logLatMin(100); +std::atomic logLatMax(0); +unsigned long testStartMs; + +/// +/// The network cost names +/// +const char* networkCostNames[] = { + "Unknown", + "Unmetered", + "Metered", + "Roaming", +}; + +/// +/// Resets this instance. +/// +void MyDebugEventListener::reset() +{ + testStartMs = (unsigned long) (std::chrono::system_clock::now().time_since_epoch() / std::chrono::milliseconds(1)); + eps = 0; + numLogged0 = 0; + numLogged = 0; + numSent = 0; + numDropped = 0; + numReject = 0; + numCached = 0; + logLatMin = 100; + logLatMax = 0; +} + +/// +/// The DebugEventListener constructor. +/// +/// +void MyDebugEventListener::OnDebugEvent(DebugEvent &evt) +{ + // lock for the duration of the print, so that we don't mess up the prints + std::lock_guard lock(dbg_callback_mtx); + unsigned long ms; + + switch (evt.type) { + case EVT_LOG_EVENT: + // Track LogEvent latency here + if (evt.param1 < logLatMin) + logLatMin = evt.param1; + if (evt.param1 > logLatMax) + logLatMax = evt.param1; + case EVT_LOG_LIFECYCLE: + case EVT_LOG_FAILURE: + case EVT_LOG_PAGEVIEW: + case EVT_LOG_PAGEACTION: + case EVT_LOG_SAMPLEMETR: + case EVT_LOG_AGGRMETR: + case EVT_LOG_TRACE: + case EVT_LOG_USERSTATE: + case EVT_LOG_SESSION: + // printf("OnEventLogged: seq=%llu, ts=%llu, type=0x%08x, p1=%u, p2=%u\n", evt.seq, evt.ts, evt.type, evt.param1, evt.param2); + numLogged++; + ms = (unsigned long) (std::chrono::system_clock::now().time_since_epoch() / std::chrono::milliseconds(1)); + { + eps = (1000 * numLogged) / (ms - testStartMs); + if ((numLogged % 500) == 0) + { + printf("EPS=%zu\n", eps.load() ); + } + } + break; + case EVT_REJECTED: + numReject++; + if ((numReject % 10) == 0) + printf("R10\n"); + // printf("OnEventRejected: seq=%llu, ts=%llu, type=0x%08x, p1=%zu, p2=%zu\n", evt.seq, evt.ts, evt.type, evt.param1, evt.param2); + break; + case EVT_ADDED: + printf("+"); + // printf("OnEventAdded: seq=%llu, ts=%llu, type=0x%08x, p1=%zu, p2=%zu\n", evt.seq, evt.ts, evt.type, evt.param1, evt.param2); + break; + case EVT_CACHED: + numCached += evt.param1; + printf("OnEventCached: seq=%llu, ts=%llu, type=0x%08x, p1=%zu, p2=%zu\n", evt.seq, evt.ts, evt.type, evt.param1, evt.param2); + break; + case EVT_DROPPED: + numDropped += evt.param1; + if ((numDropped % 10) == 0) + printf("D10\n"); + // printf("OnEventDropped: seq=%llu, ts=%llu, type=0x%08x, p1=%zu, p2=%zu\n", evt.seq, evt.ts, evt.type, evt.param1, evt.param2); + break; + case EVT_SENT: + numSent += evt.param1; + printf("OnEventsSent: seq=%llu, ts=%llu, type=0x%08x, p1=%zu, p2=%zu\n", evt.seq, evt.ts, evt.type, evt.param1, evt.param2); + break; + case EVT_STORAGE_FULL: + printf("OnStorageFull: seq=%llu, ts=%llu, type=0x%08x, p1=%zu, p2=%zu\n", evt.seq, evt.ts, evt.type, evt.param1, evt.param2); + if (evt.param1 >= 75) { + // UploadNow must NEVER EVER be called from SDK callback thread, so either use this structure below + // or notify the main app that it has to do the profile timers housekeeping / force the upload... + std::thread([]() { LogManager::UploadNow(); }).detach(); + } + break; + + case EVT_CONN_FAILURE: + case EVT_HTTP_FAILURE: + case EVT_COMPRESS_FAILED: + case EVT_UNKNOWN_HOST: + case EVT_SEND_FAILED: + printf("OnEventsSendFailed: seq=%llu, ts=%llu, type=0x%08x, p1=%zu, p2=%zu\n", evt.seq, evt.ts, evt.type, evt.param1, evt.param2); + break; + case EVT_HTTP_ERROR: + printf("OnHttpError: seq=%llu, ts=%llu, type=0x%08x, p1=%zu, p2=%zu, data=%p, size=%zu\n", + evt.seq, evt.ts, evt.type, evt.param1, evt.param2, evt.data, evt.size); + break; + case EVT_HTTP_OK: + printf("OnHttpOK: seq=%llu, ts=%llu, type=0x%08x, p1=%zu, p2=%zu, data=%p, size=%zu\n", + evt.seq, evt.ts, evt.type, evt.param1, evt.param2, evt.data, evt.size); + break; + case EVT_SEND_RETRY: + printf("OnSendRetry: seq=%llu, ts=%llu, type=0x%08x, p1=%zu, p2=%zu, data=%p, size=%zu\n", + evt.seq, evt.ts, evt.type, evt.param1, evt.param2, evt.data, evt.size); + break; + case EVT_SEND_RETRY_DROPPED: + printf("OnSendRetryDropped: seq=%llu, ts=%llu, type=0x%08x, p1=%zu, p2=%zu, data=%p, size=%zu\n", + evt.seq, evt.ts, evt.type, evt.param1, evt.param2, evt.data, evt.size); + break; + case EVT_NET_CHANGED: + printf("OnNetChanged: seq=%llu, ts=%llu, type=0x%08x, p1=%zu, p2=%zu [%s]\n", + evt.seq, evt.ts, evt.type, evt.param1, evt.param2, networkCostNames[evt.param1]); + if (evt.param2) + { + printf("Malwarebytes Antiexploit has been detected! Network cost is unknown.\n"); + } + break; + case EVT_UNKNOWN: + default: + printf("OnEventUnknown: seq=%llu, ts=%llu, type=0x%08x, p1=%zu, p2=%zu\n", evt.seq, evt.ts, evt.type, evt.param1, evt.param2); + break; + }; + +}; diff --git a/lib/modules/examples/cpp/SampleCppUTC/DebugCallback.hpp b/lib/modules/examples/cpp/SampleCppUTC/DebugCallback.hpp new file mode 100644 index 000000000..d6469a66b --- /dev/null +++ b/lib/modules/examples/cpp/SampleCppUTC/DebugCallback.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include "LogManager.hpp" + +#include +#include +#include +#include + +using namespace MAT; + +static const constexpr size_t MAX_LATENCY_SAMPLES = 10; + +class MyDebugEventListener : public DebugEventListener { + std::mutex dbg_callback_mtx; + +public: + MyDebugEventListener() : DebugEventListener() + { + reset(); + } + virtual void OnDebugEvent(DebugEvent &evt); + virtual void reset(); +}; diff --git a/lib/modules/examples/cpp/SampleCppUTC/SampleCppUTC.vcxproj b/lib/modules/examples/cpp/SampleCppUTC/SampleCppUTC.vcxproj new file mode 100644 index 000000000..7c28eae4d --- /dev/null +++ b/lib/modules/examples/cpp/SampleCppUTC/SampleCppUTC.vcxproj @@ -0,0 +1,1138 @@ + + + + + Debug.static + ARM64 + + + Debug.static + Win32 + + + Debug.static + x64 + + + Debug.vs2015.MT-sqlite + ARM64 + + + Debug.vs2015.MT-sqlite + Win32 + + + Debug.vs2015.MT-sqlite + x64 + + + Debug + ARM64 + + + Debug + Win32 + + + Release.static + ARM64 + + + Release.static + Win32 + + + Release.static + x64 + + + Release.vs2015.MT-sqlite + ARM64 + + + Release.vs2015.MT-sqlite + Win32 + + + Release.vs2015.MT-sqlite + x64 + + + Release + ARM64 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {C947B185-2B00-4073-A19D-483ED5C7EDC2} + SampleCppUTC + 10.0.17763.0 + + + + Application + true + v141 + Unicode + + + Application + true + v141 + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + false + v141 + true + Unicode + + + Application + false + v141 + true + Unicode + + + Application + true + v141 + Unicode + + + Application + true + v141 + Unicode + + + Application + true + v141 + Unicode + + + Application + true + v141 + Unicode + + + Application + true + v141 + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + false + v141 + true + Unicode + + + Application + false + v141 + true + Unicode + + + Application + false + v141 + true + Unicode + + + Application + false + v141 + true + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + + + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + + + true + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + + + + + true + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + + + true + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + + + true + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + + + + + true + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + + + true + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + + + true + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + + + true + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + + + true + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + + + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + + + false + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public + + + + + + NotUsing + Level3 + Disabled + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + Guard + EnableFastChecks + false + $(SolutionDir)\..\examples\HelloAria + + + Console + true + true + true + + + + + + + + + + + + + + + $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) + + + Deploy DLLs + + + + + NotUsing + Level3 + Disabled + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Guard + EnableFastChecks + false + $(SolutionDir)\..\examples\HelloAria + + + Console + true + true + true + + + + + + + + + + + + + + + $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) + + + Deploy DLLs + + + + + NotUsing + Level3 + Disabled + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Guard + EnableFastChecks + false + StdCall + $(SolutionDir)\..\examples\HelloAria + + + Console + true + true + true + wininet.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) + + + Deploy DLLs + + + + + NotUsing + Level3 + Disabled + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Guard + EnableFastChecks + false + MultiThreaded + $(SolutionDir)\..\examples\HelloAria + + + Console + true + true + true + + + + + + + + + + + + + + + $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) + + + Deploy DLLs + + + + + NotUsing + Level3 + Disabled + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Guard + EnableFastChecks + false + StdCall + $(SolutionDir)\..\examples\HelloAria + + + Console + true + true + true + wininet.lib;kernel32.lib;user32.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) + + + Deploy DLLs + + + + + NotUsing + Level3 + Disabled + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Guard + EnableFastChecks + false + MultiThreaded + $(SolutionDir)\..\examples\HelloAria + + + Console + true + true + true + + + + + + + + + + + + + + + $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) + + + Deploy DLLs + + + + + NotUsing + Level3 + Disabled + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + Guard + ProgramDatabase + true + false + false + $(SolutionDir)\..\examples\HelloAria + + + Console + true + + + + + + + + + + + + + + + $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) + + + Deploy DLLs + + + + + NotUsing + Level3 + Disabled + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Guard + ProgramDatabase + true + false + false + $(SolutionDir)\..\examples\HelloAria + + + Console + true + wininet.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) + + + Deploy DLLs + + + + + NotUsing + Level3 + Disabled + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Guard + ProgramDatabase + true + false + false + MultiThreadedDebug + $(SolutionDir)\..\examples\HelloAria + + + Console + true + + + + + + + + + + + + + + + $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) + + + Deploy DLLs + + + + + NotUsing + Level3 + Disabled + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + Guard + ProgramDatabase + false + $(SolutionDir)\..\examples\HelloAria + + + Console + true + + + + + + + + + + + + + + + $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) + + + Deploy DLLs + + + + + NotUsing + Level3 + Disabled + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Guard + ProgramDatabase + false + $(SolutionDir)\..\examples\HelloAria + + + Console + true + + + + + + + + + + + + + + + $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) + + + Deploy DLLs + + + + + NotUsing + Level3 + Disabled + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Guard + ProgramDatabase + false + StdCall + $(SolutionDir)\..\examples\HelloAria + + + Console + true + wininet.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) + + + Deploy DLLs + + + + + NotUsing + Level3 + Disabled + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Guard + ProgramDatabase + false + MultiThreadedDebug + $(SolutionDir)\..\examples\HelloAria + + + Console + true + + + + + + + + + + + + + + + $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) + + + Deploy DLLs + + + + + NotUsing + Level3 + Disabled + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Guard + ProgramDatabase + false + $(SolutionDir)\..\examples\HelloAria + + + Console + true + wininet.lib;kernel32.lib;user32.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) + + + Deploy DLLs + + + + + NotUsing + Level3 + Disabled + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Guard + ProgramDatabase + false + MultiThreadedDebug + $(SolutionDir)\..\examples\HelloAria + + + Console + true + + + + + + + + + + + + + + + $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) + + + Deploy DLLs + + + + + NotUsing + Level3 + Disabled + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + Guard + EnableFastChecks + $(SolutionDir)\..\examples\HelloAria + + + Console + true + true + true + + + + + + + + + + + + + + + $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) + + + Deploy DLLs + + + + + NotUsing + Level3 + Disabled + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Guard + EnableFastChecks + StdCall + $(SolutionDir)\..\examples\HelloAria + + + Console + true + true + true + wininet.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) + + + Deploy DLLs + + + + + NotUsing + Level3 + Disabled + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Guard + EnableFastChecks + StdCall + MultiThreaded + $(SolutionDir)\..\examples\HelloAria + + + Console + true + true + true + + + + + + + + + + + + + + + $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) + + + Deploy DLLs + + + + + + + + + + + {1DC6B38A-B390-34CE-907F-4958807A3D42} + + + {2ebc7b3c-2af1-442c-9285-cab39bbb8c00} + + + {8fd826f8-3739-44e6-8cc8-997122e53b8d} + + + + + {216a8e97-21f7-4bef-9e52-7f772c177c32} + + + + + + \ No newline at end of file diff --git a/lib/modules/examples/cpp/SampleCppUTC/SampleCppUTC.vcxproj.filters b/lib/modules/examples/cpp/SampleCppUTC/SampleCppUTC.vcxproj.filters new file mode 100644 index 000000000..c682fbb4a --- /dev/null +++ b/lib/modules/examples/cpp/SampleCppUTC/SampleCppUTC.vcxproj.filters @@ -0,0 +1,27 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + + + Header Files + + + \ No newline at end of file diff --git a/lib/modules/examples/cpp/SampleCppUTC/deploy-dll.cmd b/lib/modules/examples/cpp/SampleCppUTC/deploy-dll.cmd new file mode 100644 index 000000000..449186d64 --- /dev/null +++ b/lib/modules/examples/cpp/SampleCppUTC/deploy-dll.cmd @@ -0,0 +1,14 @@ +@echo off +set PROJECT_DIR=%~dp0 + +@mkdir %PROJECT_DIR%\include +copy %PROJECT_DIR%..\..\..\lib\include\public\*.* %PROJECT_DIR%\include + +@mkdir %PROJECT_DIR%\lib\%1\%2 +copy %PROJECT_DIR%..\..\..\Solutions\out\%1\%2\win32-dll\*.lib %PROJECT_DIR%\lib\%1\%2 + +@mkdir %PROJECT_DIR%\%1\%2 +copy %PROJECT_DIR%..\..\ +copy %PROJECT_DIR%..\..\..\Solutions\out\%1\%2\win32-dll\*.* %PROJECT_DIR%\lib\%1\%2 +copy %PROJECT_DIR%..\..\..\Solutions\out\%1\%2\win32-dll\*.* %3 +exit /b 0 diff --git a/lib/modules/examples/cpp/SampleCppUTC/main.cpp b/lib/modules/examples/cpp/SampleCppUTC/main.cpp new file mode 100644 index 000000000..1aa224900 --- /dev/null +++ b/lib/modules/examples/cpp/SampleCppUTC/main.cpp @@ -0,0 +1,106 @@ +#define _CRT_SECURE_NO_WARNINGS +#pragma warning(suppress:4447) // 'main' signature found without threading mode. Consider using 'int main(Platform::Array^ args)'. + +#include "LogManager.hpp" + +#ifdef _WIN32 + #include +#endif + +#include "CommonFields.h" + +LOGMANAGER_INSTANCE + +using namespace MAT; + +#define TENANT_TOKEN "99999999999999999999999999999999-99999999-9999-9999-9999-999999999999-9999" + +void forwardEventToUTC() +{ + printf("LogManager init\n"); + ILogger *logger = LogManager::Initialize(TENANT_TOKEN); + + printf("Updating LogManager context \n"); + ISemanticContext* semanticContext = LogManager::GetSemanticContext(); + semanticContext->SetAppId("MyAppName"); // caller must obtain this from app manifest, e.g. .plist on Mac OS X + semanticContext->SetAppVersion("1.0.1"); // caller must obtain this from app manifest, e.g. .plist on Mac OS X + semanticContext->SetAppLanguage("en-US"); // caller must obtain this from app manifest, e.g. .plist on Mac OS X + semanticContext->SetUserLanguage("en-US"); // caller must obtain the user language from preferences + +#ifndef _WIN32 + // Platforms other than Windows currently do not have automatic network detection implemented, + // so the caller must populate these fields using semantic context API + semanticContext->SetNetworkCost(MAT::NetworkCost::NetworkCost_Unmetered); + semanticContext->SetNetworkType(MAT::NetworkType::NetworkType_Wired); +#endif + + // Ingest 5 sample events. + for(size_t i = 1; i <= 5; i++) + { + EventLatency latency = EventLatency_Normal; + std::string eventName("Microsoft.Applications.Telemetry.ControlOptIn.sample_event"); + eventName += std::to_string((unsigned)i); + + EventProperties event(eventName); + + std::string evtType = "My.Record.BaseType"; // default v1 legacy behaviour: custom.my_record_basetype + event.SetType(evtType); + event.SetLatency(latency); + + // To make event observable in DDV (Diagnostic Data Viewer) + event.SetProperty(COMMONFIELDS_METADATA_VIEWINGPRODUCERID, "MyAppName"); + event.SetProperty(COMMONFIELDS_METADATA_VIEWINGCATEGORY, "Category1|Category2"); + + // Any extra DDV related information + event.SetProperty(COMMONFIELDS_METADATA_VIEWINGPAYLOADDECODERPATH,"EnterPathOrRegistryKey"); + event.SetProperty(COMMONFIELDS_METADATA_VIEWINGPAYLOADENCODEDFIELDNAME,"EnterEncodedFieldName"); + event.SetProperty(COMMONFIELDS_METADATA_VIEWINGEXTRA1, "ExtraDataField1"); + event.SetProperty(COMMONFIELDS_METADATA_VIEWINGEXTRA2, "ExtraDataField2"); + event.SetProperty(COMMONFIELDS_METADATA_VIEWINGEXTRA3, "ExtraDataField3"); + + logger->LogEvent(event); + } + + printf("LogManager::FlushAndTeardown\n"); + LogManager::FlushAndTeardown(); +} + +void setupConfigs() +{ + auto& config = LogManager::GetLogConfiguration(); + + // Specify Provider-Group for event + // NB: Defaults to ARIA + // config[CFG_STR_UTC][CFG_STR_PROVIDER_GROUP_ID] = "5ECB0BAC-B930-47F5-A8A4-E8253529EDB7"; + + // Set Telemetry System to UTC. + config[CFG_INT_SDK_MODE] = SdkModeTypes::SdkModeTypes_UTCCommonSchema; + + // Other Configs. + config[CFG_INT_TRACE_LEVEL_MASK] = 0; // 0xFFFFFFFF ^ 128; + config[CFG_INT_TRACE_LEVEL_MIN] = ACTTraceLevel_Warn; // ACTTraceLevel_Info; // ACTTraceLevel_Debug; + config[CFG_INT_MAX_TEARDOWN_TIME] = 10; + config[CFG_INT_RAM_QUEUE_SIZE] = 32 * 1024 * 1024; // 32 MB heap limit for sqlite3 + config[CFG_INT_CACHE_FILE_SIZE] = 16 * 1024 * 1024; // 16 MB storage file limit + +#ifdef __APPLE__ + config[CFG_STR_CACHE_FILE_PATH] = "/tmp/offlinestorage.db"; +#else + config[CFG_STR_CACHE_FILE_PATH] = "offlinestorage.db"; +#endif +#ifdef USE_INVALID_URL /* Stress-test for the case when collector is unreachable */ + config[CFG_STR_COLLECTOR_URL] = "https://127.0.0.1/invalid/url"; +#endif +} + +int main() +{ + printf("ControlOptIn Aria 1DS Sample App\n\n"); + + printf("Setting up configuration...\n"); + setupConfigs(); + + forwardEventToUTC(); + + return 0; +} From 38a35e50d2dcbb7edf14201a178ad05b58796b5f Mon Sep 17 00:00:00 2001 From: Matt Koscumb Date: Thu, 20 Jun 2019 13:48:12 -0700 Subject: [PATCH 09/15] AriaDecoderV3 should have a HAVE_MAT_JSONHPP guard. --- lib/decoder/AriaDecoderV3.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/decoder/AriaDecoderV3.cpp b/lib/decoder/AriaDecoderV3.cpp index 3bc8cc331..707bd5590 100644 --- a/lib/decoder/AriaDecoderV3.cpp +++ b/lib/decoder/AriaDecoderV3.cpp @@ -25,15 +25,15 @@ #define TEST_LOG_ERROR(arg0, ...) fprintf(stderr, arg0 "\n", ##__VA_ARGS__) #endif +#ifdef HAVE_MAT_JSONHPP #include "json.hpp" - using nlohmann::json; + using namespace CsProtocol; namespace clienttelemetry { namespace data { namespace v3 { - void to_json(json& j, const Record& r); std::vector decodeRequest(const std::vector& request) @@ -312,6 +312,7 @@ namespace clienttelemetry { } } } +#endif // HAVE_MAT_JSONHPP #if 0 /* These routines should exist in scope of FuncTests and UnitTests project provided by SDK utils */ @@ -533,10 +534,12 @@ void AriaDecoderV3::InflateVector(std::vector &in, std::vector inflateEnd(&zs); } -using namespace clienttelemetry::data::v3; - void AriaDecoderV3::decode(std::vector &in, std::vector &out, bool compressed) { +#ifdef HAVE_MAT_JSONHPP + + using namespace clienttelemetry::data::v3; + if (compressed) { InflateVector(in, out); @@ -551,4 +554,13 @@ void AriaDecoderV3::decode(std::vector &in, std::vector &out, std::string s = j.dump(2); out.clear(); std::copy(s.begin(), s.end(), std::back_inserter(out)); + +#else + + (void) (in); + (void) (out); + (void) (compressed); + assert(false /* json.hpp support is not enabled! */); + +#endif // HAVE_MAT_JSONHPP } From 54d83bfcbfa9123d30fa9400436b3112897bf0c7 Mon Sep 17 00:00:00 2001 From: Matt Koscumb Date: Thu, 20 Jun 2019 13:52:28 -0700 Subject: [PATCH 10/15] Fix whitespace inconsistencies. --- lib/decoder/AriaDecoderV3.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/decoder/AriaDecoderV3.cpp b/lib/decoder/AriaDecoderV3.cpp index 707bd5590..d5257c552 100644 --- a/lib/decoder/AriaDecoderV3.cpp +++ b/lib/decoder/AriaDecoderV3.cpp @@ -28,7 +28,6 @@ #ifdef HAVE_MAT_JSONHPP #include "json.hpp" using nlohmann::json; - using namespace CsProtocol; namespace clienttelemetry { @@ -557,10 +556,10 @@ void AriaDecoderV3::decode(std::vector &in, std::vector &out, #else - (void) (in); - (void) (out); - (void) (compressed); - assert(false /* json.hpp support is not enabled! */); + (void) (in); + (void) (out); + (void) (compressed); + assert(false /* json.hpp support is not enabled! */); #endif // HAVE_MAT_JSONHPP } From f1446e8b2e3848cd0d1233d84e35dbd41635cf49 Mon Sep 17 00:00:00 2001 From: Miguel Casillas Date: Thu, 20 Jun 2019 21:07:22 +0000 Subject: [PATCH 11/15] Merged PR 1088590: Removed AllowLargeEvents from API surface Delete AllowLargeEvents from Logger API surface Expose bool flags on LogConfiguration - CFG_BOOL_UTC_ENABLED -> UTC mode is enabled on SDK - CFG_BOOL_UTC_ACTIVE -> SDK is running on UTC mode - CFG_BOOL_UTC_LARGE_PAYLOADS -> UTC allows large payloads on windows version Related work items: #1782870 --- lib/api/LogManagerImpl.cpp | 6 ++++++ lib/api/Logger.cpp | 12 +----------- lib/api/Logger.hpp | 3 --- lib/config/RuntimeConfig_Default.hpp | 9 ++++++++- lib/include/public/ILogConfiguration.hpp | 15 +++++++++++++++ lib/include/public/ILogger.hpp | 7 ------- lib/include/public/NullObjects.hpp | 2 -- lib/modules/utc/UtcTelemetrySystem.cpp | 23 +++++++++-------------- lib/system/Contexts.hpp | 4 +--- 9 files changed, 40 insertions(+), 41 deletions(-) diff --git a/lib/api/LogManagerImpl.cpp b/lib/api/LogManagerImpl.cpp index 981fabd33..40853cdf5 100644 --- a/lib/api/LogManagerImpl.cpp +++ b/lib/api/LogManagerImpl.cpp @@ -146,12 +146,18 @@ namespace ARIASDK_NS_BEGIN m_context.SetCommonField(SESSION_ID_LEGACY, PAL::generateUuidString()); #ifdef HAVE_MAT_UTC + // UTC is not active + configuration[CFG_STR_UTC][CFG_BOOL_UTC_ACTIVE] = false; + // UTC functionality is only available on Windows 10 RS2+ bool isWindowsUtcClientRegistrationEnable = PAL::IsUtcRegistrationEnabledinWindows(); + configuration[CFG_STR_UTC][CFG_BOOL_UTC_ENABLED] = isWindowsUtcClientRegistrationEnable; int32_t sdkMode = configuration[CFG_INT_SDK_MODE]; if ((sdkMode > SdkModeTypes::SdkModeTypes_CS) && isWindowsUtcClientRegistrationEnable) { + // UTC is active + configuration[CFG_STR_UTC][CFG_BOOL_UTC_ACTIVE] = true; LOG_TRACE("Initializing UTC physical layer..."); m_system.reset(new UtcTelemetrySystem(*this, *m_config)); if (!deferSystemStart) diff --git a/lib/api/Logger.cpp b/lib/api/Logger.cpp index 12bf84797..a15d1cc8c 100644 --- a/lib/api/Logger.cpp +++ b/lib/api/Logger.cpp @@ -40,8 +40,7 @@ namespace ARIASDK_NS_BEGIN m_semanticApiDecorators(logManager), m_sessionStartTime(0), - m_allowDotsInType(false), - m_sendLargeEvents(false) + m_allowDotsInType(false) { std::string tenantId = tenantTokenToId(m_tenantToken); LOG_TRACE("%p: New instance (tenantId=%s)", this, tenantId.c_str()); @@ -419,10 +418,6 @@ namespace ARIASDK_NS_BEGIN IncomingEventContext event(PAL::generateUuidString(), m_tenantToken, latency, persistence, &record); event.policyBitFlags = policyBitFlags; - // TODO: [MC] - maybe UTC_MODE validation is necessary - if (m_sendLargeEvents) - event.isLargeEvent = true; - m_logManager.sendEvent(&event); } @@ -660,9 +655,4 @@ namespace ARIASDK_NS_BEGIN m_level = level; } - void Logger::AllowLargeEvents(bool flag) - { - m_sendLargeEvents = flag; - } - } ARIASDK_NS_END \ No newline at end of file diff --git a/lib/api/Logger.hpp b/lib/api/Logger.hpp index 9f8a6873b..e209decf4 100644 --- a/lib/api/Logger.hpp +++ b/lib/api/Logger.hpp @@ -79,8 +79,6 @@ namespace ARIASDK_NS_BEGIN { virtual void SetLevel(uint8_t level) override; - virtual void AllowLargeEvents(bool flag) override; - virtual ISemanticContext* GetSemanticContext() const override; virtual void SetParentContext(ISemanticContext* context) override; @@ -202,7 +200,6 @@ namespace ARIASDK_NS_BEGIN { SemanticApiDecorators m_semanticApiDecorators; bool m_allowDotsInType; - bool m_sendLargeEvents; }; } ARIASDK_NS_END diff --git a/lib/config/RuntimeConfig_Default.hpp b/lib/config/RuntimeConfig_Default.hpp index 949e2f73b..2f287a7be 100644 --- a/lib/config/RuntimeConfig_Default.hpp +++ b/lib/config/RuntimeConfig_Default.hpp @@ -33,7 +33,14 @@ namespace ARIASDK_NS_BEGIN { }, {"utc", { - { "providerGroupId", "780dddc8-18a1-5781-895a-a690464fa89c" } + { "providerGroupId", "780dddc8-18a1-5781-895a-a690464fa89c" }, +#ifdef HAVE_MAT_UTC + {CFG_BOOL_UTC_ENABLED, true}, + {CFG_BOOL_UTC_ACTIVE, false}, + {CFG_BOOL_UTC_LARGE_PAYLOADS, false} +#else + {CFG_BOOL_UTC_ENABLED, false} +#endif } }, { "http", diff --git a/lib/include/public/ILogConfiguration.hpp b/lib/include/public/ILogConfiguration.hpp index 3dd9074ff..c9494c322 100644 --- a/lib/include/public/ILogConfiguration.hpp +++ b/lib/include/public/ILogConfiguration.hpp @@ -89,6 +89,21 @@ namespace ARIASDK_NS_BEGIN /// static constexpr const char* const CFG_BOOL_ENABLE_WAL_JOURNAL = "enableWALJournal"; + /// + /// Parameter that allows to check if the SDK is running on UTC mode + /// + static constexpr const char* const CFG_BOOL_UTC_ENABLED = "UTC_enabled"; + + /// + /// Parameter that allows to check if the SDK is running on UTC mode + /// + static constexpr const char* const CFG_BOOL_UTC_ACTIVE = "UTC_active"; + + /// + /// Parameter that allows to check if the Windows 10 version SDK is using supports large payloads on UTC + /// + static constexpr const char* const CFG_BOOL_UTC_LARGE_PAYLOADS = "UTC_largePayloadsEnabled"; + /// /// The event collection URI. /// diff --git a/lib/include/public/ILogger.hpp b/lib/include/public/ILogger.hpp index 3f2a8e468..d604d6a8d 100644 --- a/lib/include/public/ILogger.hpp +++ b/lib/include/public/ILogger.hpp @@ -585,13 +585,6 @@ namespace ARIASDK_NS_BEGIN /// /// Diagnostic level. virtual void SetLevel(uint8_t level) = 0; - - /// - /// Set the boolean flag for allowing events with payload - /// larger than 64K to be sent to UTC - /// - /// Diagnostic level. - virtual void AllowLargeEvents(bool flag) = 0; }; diff --git a/lib/include/public/NullObjects.hpp b/lib/include/public/NullObjects.hpp index d0defd9d3..b7da41e8e 100644 --- a/lib/include/public/NullObjects.hpp +++ b/lib/include/public/NullObjects.hpp @@ -107,8 +107,6 @@ namespace ARIASDK_NS_BEGIN virtual void SetLevel(uint8_t level) override {}; - virtual void AllowLargeEvents(bool flag) override {}; - }; class NullLogManager : public ILogManager diff --git a/lib/modules/utc/UtcTelemetrySystem.cpp b/lib/modules/utc/UtcTelemetrySystem.cpp index dab721e48..8ac2701a0 100644 --- a/lib/modules/utc/UtcTelemetrySystem.cpp +++ b/lib/modules/utc/UtcTelemetrySystem.cpp @@ -509,18 +509,13 @@ namespace ARIASDK_NS_BEGIN EVENT_DATA_DESCRIPTOR pDataDescriptors[3]; EventDataDescCreate(&pDataDescriptors[2], byteDataVector.data(), static_cast(byteDataVector.size())); + // Event size detection is needed + int64_t eventByteSize = byteDataVector.size() + byteVector.size() + + providerdata.providerMetaVector.size(); + int64_t eventKBSize = (eventByteSize + 1024 - 1) / 1024; + bool isLargeEvent = eventKBSize >= LargeEventSizeKB; - // if the event does not come from a logger that sends large events - // auto size detection is needed - if (!eventCtx->isLargeEvent) - { - int64_t eventByteSize = byteDataVector.size() + byteVector.size() - + providerdata.providerMetaVector.size(); - int64_t eventKBSize = (eventByteSize + 1024 - 1) / 1024; - eventCtx->isLargeEvent = eventKBSize >= LargeEventSizeKB; - } - - if (!eventCtx->isLargeEvent) + if (!isLargeEvent) { HRESULT writeResponse = tld::WriteEvent( providerdata.providerHandle, @@ -532,13 +527,13 @@ namespace ARIASDK_NS_BEGIN if (writeResponse == 0) return 0; else if (writeResponse == HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW)) - eventCtx->isLargeEvent = true; + isLargeEvent = true; else return -1; } - // if event comes from a tagged logger, or size is larger than LargeEventSizeKB + // if event size is larger than LargeEventSizeKB // or was sent to ETW and the response was STATUS_INTEGER_OVERFLOW - if(eventCtx->isLargeEvent) + if(isLargeEvent) { // Use RPC path for 64KB+ events if (0 != RPCWriteEvent( diff --git a/lib/system/Contexts.hpp b/lib/system/Contexts.hpp index 6ca2bd893..f31d78fc1 100644 --- a/lib/system/Contexts.hpp +++ b/lib/system/Contexts.hpp @@ -20,13 +20,11 @@ namespace ARIASDK_NS_BEGIN { ::CsProtocol::Record* source; StorageRecord record; std::uint64_t policyBitFlags; - bool isLargeEvent; public: IncomingEventContext() : policyBitFlags(0), - source(nullptr), - isLargeEvent(false) + source(nullptr) { } From 1eaf0cb53ac93ab0022ea9f91bd54dbc5add69e7 Mon Sep 17 00:00:00 2001 From: "David Brown (XBOX)" Date: Mon, 24 Jun 2019 21:02:49 +0000 Subject: [PATCH 12/15] Merged PR 1090219: Add a config-versionPrefix.h Adds a minimal config header to support flexible configuration during build via CONFIG_CUSTOM_H and make logic instead of header defines. --- Solutions/Clienttelemetry/Clienttelemetry.vcxitems | 1 + Solutions/Clienttelemetry/Clienttelemetry.vcxitems.filters | 3 +++ lib/include/mat/config-versionPrefix.h | 1 + 3 files changed, 5 insertions(+) create mode 100644 lib/include/mat/config-versionPrefix.h diff --git a/Solutions/Clienttelemetry/Clienttelemetry.vcxitems b/Solutions/Clienttelemetry/Clienttelemetry.vcxitems index e2eb677a8..4856d84dd 100644 --- a/Solutions/Clienttelemetry/Clienttelemetry.vcxitems +++ b/Solutions/Clienttelemetry/Clienttelemetry.vcxitems @@ -101,6 +101,7 @@ + diff --git a/Solutions/Clienttelemetry/Clienttelemetry.vcxitems.filters b/Solutions/Clienttelemetry/Clienttelemetry.vcxitems.filters index 10cd091c6..3c566c6f8 100644 --- a/Solutions/Clienttelemetry/Clienttelemetry.vcxitems.filters +++ b/Solutions/Clienttelemetry/Clienttelemetry.vcxitems.filters @@ -497,6 +497,9 @@ include\mat + + include\mat + pal diff --git a/lib/include/mat/config-versionPrefix.h b/lib/include/mat/config-versionPrefix.h new file mode 100644 index 000000000..066f227df --- /dev/null +++ b/lib/include/mat/config-versionPrefix.h @@ -0,0 +1 @@ +#define EVTSDK_VERSION_PREFIX "EVT" \ No newline at end of file From eb8f39bef53a98523c019af5d1ffd5d1baa1aebb Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Mon, 24 Jun 2019 14:49:59 -0700 Subject: [PATCH 13/15] Housekeeping (no code change): move UTC example to private git submodule location --- Solutions/MSTelemetrySDK.sln | 90 +- examples/cpp/SampleCppUTC/.gitignore | 5 - examples/cpp/SampleCppUTC/DebugCallback.cpp | 150 --- examples/cpp/SampleCppUTC/DebugCallback.hpp | 24 - .../cpp/SampleCppUTC/SampleCppUTC.vcxproj | 1138 ----------------- .../SampleCppUTC/SampleCppUTC.vcxproj.filters | 27 - examples/cpp/SampleCppUTC/deploy-dll.cmd | 14 - examples/cpp/SampleCppUTC/main.cpp | 118 -- .../examples/cpp/SampleCppUTC/README.md | 1 + .../cpp/SampleCppUTC/SampleCppUTC.vcxproj | 8 +- .../examples/cpp/SampleCppUTC/deploy-dll.cmd | 11 +- .../examples/cpp/SampleCppUTC/main.cpp | 12 + 12 files changed, 68 insertions(+), 1530 deletions(-) delete mode 100644 examples/cpp/SampleCppUTC/.gitignore delete mode 100644 examples/cpp/SampleCppUTC/DebugCallback.cpp delete mode 100644 examples/cpp/SampleCppUTC/DebugCallback.hpp delete mode 100644 examples/cpp/SampleCppUTC/SampleCppUTC.vcxproj delete mode 100644 examples/cpp/SampleCppUTC/SampleCppUTC.vcxproj.filters delete mode 100644 examples/cpp/SampleCppUTC/deploy-dll.cmd delete mode 100644 examples/cpp/SampleCppUTC/main.cpp create mode 100644 lib/modules/examples/cpp/SampleCppUTC/README.md diff --git a/Solutions/MSTelemetrySDK.sln b/Solutions/MSTelemetrySDK.sln index 180f00e40..81236500d 100644 --- a/Solutions/MSTelemetrySDK.sln +++ b/Solutions/MSTelemetrySDK.sln @@ -107,8 +107,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleC", "..\examples\c\Sa EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleCpp", "..\examples\cpp\SampleCpp\SampleCpp.vcxproj", "{86AC752C-5687-4377-841E-943D9BEEF360}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleCppUTC", "..\examples\cpp\SampleCppUTC\SampleCppUTC.vcxproj", "{C947B185-2B00-4073-A19D-483ED5C7EDC2}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleCppUWP", "..\examples\cpp\SampleCppUWP\SampleCppUWP.vcxproj", "{39DBD601-4D79-49F9-AD18-065404DBA273}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleCsNet40", "..\examples\cs\SampleCsNet40\SampleCsNet40.csproj", "{65AFA0E2-F9A2-4309-87E7-E419D59583C1}" @@ -121,6 +119,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleCppLogManagers", "..\ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleCppMini", "..\examples\cpp\SampleCppMini\SampleCppMini.vcxproj", "{86AC752C-5687-4377-841E-943D9BEEF361}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleCppUTC", "..\lib\modules\examples\cpp\SampleCppUTC\SampleCppUTC.vcxproj", "{C947B185-2B00-4073-A19D-483ED5C7EDC2}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution ..\lib\pal\universal\universal.vcxitems*{10e9165b-49d1-4d1c-8248-334b9905b9cc}*SharedItemsImports = 9 @@ -826,48 +826,6 @@ Global {86AC752C-5687-4377-841E-943D9BEEF360}.Release|Win32.Build.0 = Release|Win32 {86AC752C-5687-4377-841E-943D9BEEF360}.Release|x64.ActiveCfg = Release|x64 {86AC752C-5687-4377-841E-943D9BEEF360}.Release|x64.Build.0 = Release|x64 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.static|ARM.ActiveCfg = Debug.static|Win32 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.static|ARM64.ActiveCfg = Debug.static|ARM64 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.static|ARM64.Build.0 = Debug.static|ARM64 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.static|Win32.ActiveCfg = Debug.static|Win32 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.static|Win32.Build.0 = Debug.static|Win32 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.static|x64.ActiveCfg = Debug.static|x64 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.static|x64.Build.0 = Debug.static|x64 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.vs2015.MT-sqlite|ARM.ActiveCfg = Debug.vs2015.MT-sqlite|Win32 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.vs2015.MT-sqlite|ARM64.ActiveCfg = Debug.vs2015.MT-sqlite|ARM64 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.vs2015.MT-sqlite|ARM64.Build.0 = Debug.vs2015.MT-sqlite|ARM64 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.vs2015.MT-sqlite|Win32.ActiveCfg = Debug.vs2015.MT-sqlite|Win32 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.vs2015.MT-sqlite|Win32.Build.0 = Debug.vs2015.MT-sqlite|Win32 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.vs2015.MT-sqlite|x64.ActiveCfg = Debug.vs2015.MT-sqlite|x64 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.vs2015.MT-sqlite|x64.Build.0 = Debug.vs2015.MT-sqlite|x64 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug|ARM.ActiveCfg = Debug|Win32 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug|ARM64.Build.0 = Debug|ARM64 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug|Win32.ActiveCfg = Debug|Win32 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug|Win32.Build.0 = Debug|Win32 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug|x64.ActiveCfg = Debug|x64 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug|x64.Build.0 = Debug|x64 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.static|ARM.ActiveCfg = Release.static|Win32 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.static|ARM64.ActiveCfg = Release.static|ARM64 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.static|ARM64.Build.0 = Release.static|ARM64 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.static|Win32.ActiveCfg = Release.static|Win32 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.static|Win32.Build.0 = Release.static|Win32 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.static|x64.ActiveCfg = Release.static|x64 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.static|x64.Build.0 = Release.static|x64 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.vs2015.MT-sqlite|ARM.ActiveCfg = Release.vs2015.MT-sqlite|Win32 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.vs2015.MT-sqlite|ARM64.ActiveCfg = Release.vs2015.MT-sqlite|ARM64 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.vs2015.MT-sqlite|ARM64.Build.0 = Release.vs2015.MT-sqlite|ARM64 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.vs2015.MT-sqlite|Win32.ActiveCfg = Release.vs2015.MT-sqlite|Win32 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.vs2015.MT-sqlite|Win32.Build.0 = Release.vs2015.MT-sqlite|Win32 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.vs2015.MT-sqlite|x64.ActiveCfg = Release.vs2015.MT-sqlite|x64 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.vs2015.MT-sqlite|x64.Build.0 = Release.vs2015.MT-sqlite|x64 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release|ARM.ActiveCfg = Release|Win32 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release|ARM64.ActiveCfg = Release|ARM64 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release|ARM64.Build.0 = Release|ARM64 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release|Win32.ActiveCfg = Release|Win32 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release|Win32.Build.0 = Release|Win32 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release|x64.ActiveCfg = Release|x64 - {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release|x64.Build.0 = Release|x64 {39DBD601-4D79-49F9-AD18-065404DBA273}.Debug.static|ARM.ActiveCfg = Debug|ARM {39DBD601-4D79-49F9-AD18-065404DBA273}.Debug.static|ARM.Build.0 = Debug|ARM {39DBD601-4D79-49F9-AD18-065404DBA273}.Debug.static|ARM.Deploy.0 = Debug|ARM @@ -1139,6 +1097,48 @@ Global {86AC752C-5687-4377-841E-943D9BEEF361}.Release|Win32.Build.0 = Release|Win32 {86AC752C-5687-4377-841E-943D9BEEF361}.Release|x64.ActiveCfg = Release|x64 {86AC752C-5687-4377-841E-943D9BEEF361}.Release|x64.Build.0 = Release|x64 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.static|ARM.ActiveCfg = Debug.static|Win32 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.static|ARM64.ActiveCfg = Debug.static|ARM64 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.static|ARM64.Build.0 = Debug.static|ARM64 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.static|Win32.ActiveCfg = Debug.static|Win32 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.static|Win32.Build.0 = Debug.static|Win32 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.static|x64.ActiveCfg = Debug.static|x64 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.static|x64.Build.0 = Debug.static|x64 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.vs2015.MT-sqlite|ARM.ActiveCfg = Debug.vs2015.MT-sqlite|Win32 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.vs2015.MT-sqlite|ARM64.ActiveCfg = Debug.vs2015.MT-sqlite|ARM64 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.vs2015.MT-sqlite|ARM64.Build.0 = Debug.vs2015.MT-sqlite|ARM64 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.vs2015.MT-sqlite|Win32.ActiveCfg = Debug.vs2015.MT-sqlite|Win32 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.vs2015.MT-sqlite|Win32.Build.0 = Debug.vs2015.MT-sqlite|Win32 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.vs2015.MT-sqlite|x64.ActiveCfg = Debug.vs2015.MT-sqlite|x64 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug.vs2015.MT-sqlite|x64.Build.0 = Debug.vs2015.MT-sqlite|x64 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug|ARM.ActiveCfg = Debug|Win32 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug|ARM64.Build.0 = Debug|ARM64 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug|Win32.ActiveCfg = Debug|Win32 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug|Win32.Build.0 = Debug|Win32 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug|x64.ActiveCfg = Debug|x64 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Debug|x64.Build.0 = Debug|x64 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.static|ARM.ActiveCfg = Release.static|Win32 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.static|ARM64.ActiveCfg = Release.static|ARM64 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.static|ARM64.Build.0 = Release.static|ARM64 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.static|Win32.ActiveCfg = Release.static|Win32 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.static|Win32.Build.0 = Release.static|Win32 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.static|x64.ActiveCfg = Release.static|x64 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.static|x64.Build.0 = Release.static|x64 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.vs2015.MT-sqlite|ARM.ActiveCfg = Release.vs2015.MT-sqlite|Win32 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.vs2015.MT-sqlite|ARM64.ActiveCfg = Release.vs2015.MT-sqlite|ARM64 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.vs2015.MT-sqlite|ARM64.Build.0 = Release.vs2015.MT-sqlite|ARM64 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.vs2015.MT-sqlite|Win32.ActiveCfg = Release.vs2015.MT-sqlite|Win32 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.vs2015.MT-sqlite|Win32.Build.0 = Release.vs2015.MT-sqlite|Win32 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.vs2015.MT-sqlite|x64.ActiveCfg = Release.vs2015.MT-sqlite|x64 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release.vs2015.MT-sqlite|x64.Build.0 = Release.vs2015.MT-sqlite|x64 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release|ARM.ActiveCfg = Release|Win32 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release|ARM64.ActiveCfg = Release|ARM64 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release|ARM64.Build.0 = Release|ARM64 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release|Win32.ActiveCfg = Release|Win32 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release|Win32.Build.0 = Release|Win32 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release|x64.ActiveCfg = Release|x64 + {C947B185-2B00-4073-A19D-483ED5C7EDC2}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1160,12 +1160,12 @@ Global {A4B32472-A8F1-4F52-A20D-2CDFEC2BFD95} = {250EFB82-2F0E-4781-94BB-8313201ABDF0} {277AEB2C-E995-4A40-B63A-B16B8A3A4550} = {A4B32472-A8F1-4F52-A20D-2CDFEC2BFD95} {86AC752C-5687-4377-841E-943D9BEEF360} = {D31B3404-AE47-4D0A-9A59-C321164F945C} - {C947B185-2B00-4073-A19D-483ED5C7EDC2} = {D31B3404-AE47-4D0A-9A59-C321164F945C} {39DBD601-4D79-49F9-AD18-065404DBA273} = {D31B3404-AE47-4D0A-9A59-C321164F945C} {65AFA0E2-F9A2-4309-87E7-E419D59583C1} = {11A3C4B2-1800-4A80-9771-E92E98B9485B} {F797B22C-A1C4-4136-9DCC-0682A183A4DA} = {11A3C4B2-1800-4A80-9771-E92E98B9485B} {77053F92-F003-4D1C-A489-1DEB7CFEA4EC} = {D31B3404-AE47-4D0A-9A59-C321164F945C} {86AC752C-5687-4377-841E-943D9BEEF361} = {D31B3404-AE47-4D0A-9A59-C321164F945C} + {C947B185-2B00-4073-A19D-483ED5C7EDC2} = {D31B3404-AE47-4D0A-9A59-C321164F945C} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {7EE8585B-C10F-4DAC-BDAF-3726EDF8FCD7} diff --git a/examples/cpp/SampleCppUTC/.gitignore b/examples/cpp/SampleCppUTC/.gitignore deleted file mode 100644 index 99e2e36ac..000000000 --- a/examples/cpp/SampleCppUTC/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -include -lib -offlinestorage*.* -Release -x64 diff --git a/examples/cpp/SampleCppUTC/DebugCallback.cpp b/examples/cpp/SampleCppUTC/DebugCallback.cpp deleted file mode 100644 index 2321333d5..000000000 --- a/examples/cpp/SampleCppUTC/DebugCallback.cpp +++ /dev/null @@ -1,150 +0,0 @@ -#include "DebugCallback.hpp" - -unsigned latency[MAX_LATENCY_SAMPLES] = { 0 }; - -std::atomic eps(0); -std::atomic numLogged0(0); -std::atomic numLogged(0); -std::atomic numSent(0); -std::atomic numDropped(0); -std::atomic numReject(0); -std::atomic numCached(0); -std::atomic logLatMin(100); -std::atomic logLatMax(0); -unsigned long testStartMs; - -/// -/// The network cost names -/// -const char* networkCostNames[] = { - "Unknown", - "Unmetered", - "Metered", - "Roaming", -}; - -/// -/// Resets this instance. -/// -void MyDebugEventListener::reset() -{ - testStartMs = (unsigned long) (std::chrono::system_clock::now().time_since_epoch() / std::chrono::milliseconds(1)); - eps = 0; - numLogged0 = 0; - numLogged = 0; - numSent = 0; - numDropped = 0; - numReject = 0; - numCached = 0; - logLatMin = 100; - logLatMax = 0; -} - -/// -/// The DebugEventListener constructor. -/// -/// -void MyDebugEventListener::OnDebugEvent(DebugEvent &evt) -{ - // lock for the duration of the print, so that we don't mess up the prints - std::lock_guard lock(dbg_callback_mtx); - unsigned long ms; - - switch (evt.type) { - case EVT_LOG_EVENT: - // Track LogEvent latency here - if (evt.param1 < logLatMin) - logLatMin = evt.param1; - if (evt.param1 > logLatMax) - logLatMax = evt.param1; - case EVT_LOG_LIFECYCLE: - case EVT_LOG_FAILURE: - case EVT_LOG_PAGEVIEW: - case EVT_LOG_PAGEACTION: - case EVT_LOG_SAMPLEMETR: - case EVT_LOG_AGGRMETR: - case EVT_LOG_TRACE: - case EVT_LOG_USERSTATE: - case EVT_LOG_SESSION: - // printf("OnEventLogged: seq=%llu, ts=%llu, type=0x%08x, p1=%u, p2=%u\n", evt.seq, evt.ts, evt.type, evt.param1, evt.param2); - numLogged++; - ms = (unsigned long) (std::chrono::system_clock::now().time_since_epoch() / std::chrono::milliseconds(1)); - { - eps = (1000 * numLogged) / (ms - testStartMs); - if ((numLogged % 500) == 0) - { - printf("EPS=%zu\n", eps.load() ); - } - } - break; - case EVT_REJECTED: - numReject++; - if ((numReject % 10) == 0) - printf("R10\n"); - // printf("OnEventRejected: seq=%llu, ts=%llu, type=0x%08x, p1=%zu, p2=%zu\n", evt.seq, evt.ts, evt.type, evt.param1, evt.param2); - break; - case EVT_ADDED: - printf("+"); - // printf("OnEventAdded: seq=%llu, ts=%llu, type=0x%08x, p1=%zu, p2=%zu\n", evt.seq, evt.ts, evt.type, evt.param1, evt.param2); - break; - case EVT_CACHED: - numCached += evt.param1; - printf("OnEventCached: seq=%llu, ts=%llu, type=0x%08x, p1=%zu, p2=%zu\n", evt.seq, evt.ts, evt.type, evt.param1, evt.param2); - break; - case EVT_DROPPED: - numDropped += evt.param1; - if ((numDropped % 10) == 0) - printf("D10\n"); - // printf("OnEventDropped: seq=%llu, ts=%llu, type=0x%08x, p1=%zu, p2=%zu\n", evt.seq, evt.ts, evt.type, evt.param1, evt.param2); - break; - case EVT_SENT: - numSent += evt.param1; - printf("OnEventsSent: seq=%llu, ts=%llu, type=0x%08x, p1=%zu, p2=%zu\n", evt.seq, evt.ts, evt.type, evt.param1, evt.param2); - break; - case EVT_STORAGE_FULL: - printf("OnStorageFull: seq=%llu, ts=%llu, type=0x%08x, p1=%zu, p2=%zu\n", evt.seq, evt.ts, evt.type, evt.param1, evt.param2); - if (evt.param1 >= 75) { - // UploadNow must NEVER EVER be called from SDK callback thread, so either use this structure below - // or notify the main app that it has to do the profile timers housekeeping / force the upload... - std::thread([]() { LogManager::UploadNow(); }).detach(); - } - break; - - case EVT_CONN_FAILURE: - case EVT_HTTP_FAILURE: - case EVT_COMPRESS_FAILED: - case EVT_UNKNOWN_HOST: - case EVT_SEND_FAILED: - printf("OnEventsSendFailed: seq=%llu, ts=%llu, type=0x%08x, p1=%zu, p2=%zu\n", evt.seq, evt.ts, evt.type, evt.param1, evt.param2); - break; - case EVT_HTTP_ERROR: - printf("OnHttpError: seq=%llu, ts=%llu, type=0x%08x, p1=%zu, p2=%zu, data=%p, size=%zu\n", - evt.seq, evt.ts, evt.type, evt.param1, evt.param2, evt.data, evt.size); - break; - case EVT_HTTP_OK: - printf("OnHttpOK: seq=%llu, ts=%llu, type=0x%08x, p1=%zu, p2=%zu, data=%p, size=%zu\n", - evt.seq, evt.ts, evt.type, evt.param1, evt.param2, evt.data, evt.size); - break; - case EVT_SEND_RETRY: - printf("OnSendRetry: seq=%llu, ts=%llu, type=0x%08x, p1=%zu, p2=%zu, data=%p, size=%zu\n", - evt.seq, evt.ts, evt.type, evt.param1, evt.param2, evt.data, evt.size); - break; - case EVT_SEND_RETRY_DROPPED: - printf("OnSendRetryDropped: seq=%llu, ts=%llu, type=0x%08x, p1=%zu, p2=%zu, data=%p, size=%zu\n", - evt.seq, evt.ts, evt.type, evt.param1, evt.param2, evt.data, evt.size); - break; - case EVT_NET_CHANGED: - printf("OnNetChanged: seq=%llu, ts=%llu, type=0x%08x, p1=%zu, p2=%zu [%s]\n", - evt.seq, evt.ts, evt.type, evt.param1, evt.param2, networkCostNames[evt.param1]); - if (evt.param2) - { - printf("Malwarebytes Antiexploit has been detected! Network cost is unknown.\n"); - } - break; - case EVT_UNKNOWN: - default: - printf("OnEventUnknown: seq=%llu, ts=%llu, type=0x%08x, p1=%zu, p2=%zu\n", evt.seq, evt.ts, evt.type, evt.param1, evt.param2); - break; - }; - -}; diff --git a/examples/cpp/SampleCppUTC/DebugCallback.hpp b/examples/cpp/SampleCppUTC/DebugCallback.hpp deleted file mode 100644 index d6469a66b..000000000 --- a/examples/cpp/SampleCppUTC/DebugCallback.hpp +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include "LogManager.hpp" - -#include -#include -#include -#include - -using namespace MAT; - -static const constexpr size_t MAX_LATENCY_SAMPLES = 10; - -class MyDebugEventListener : public DebugEventListener { - std::mutex dbg_callback_mtx; - -public: - MyDebugEventListener() : DebugEventListener() - { - reset(); - } - virtual void OnDebugEvent(DebugEvent &evt); - virtual void reset(); -}; diff --git a/examples/cpp/SampleCppUTC/SampleCppUTC.vcxproj b/examples/cpp/SampleCppUTC/SampleCppUTC.vcxproj deleted file mode 100644 index 7c28eae4d..000000000 --- a/examples/cpp/SampleCppUTC/SampleCppUTC.vcxproj +++ /dev/null @@ -1,1138 +0,0 @@ - - - - - Debug.static - ARM64 - - - Debug.static - Win32 - - - Debug.static - x64 - - - Debug.vs2015.MT-sqlite - ARM64 - - - Debug.vs2015.MT-sqlite - Win32 - - - Debug.vs2015.MT-sqlite - x64 - - - Debug - ARM64 - - - Debug - Win32 - - - Release.static - ARM64 - - - Release.static - Win32 - - - Release.static - x64 - - - Release.vs2015.MT-sqlite - ARM64 - - - Release.vs2015.MT-sqlite - Win32 - - - Release.vs2015.MT-sqlite - x64 - - - Release - ARM64 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {C947B185-2B00-4073-A19D-483ED5C7EDC2} - SampleCppUTC - 10.0.17763.0 - - - - Application - true - v141 - Unicode - - - Application - true - v141 - Unicode - - - Application - true - v141 - Unicode - - - Application - false - v141 - true - Unicode - - - Application - false - v141 - true - Unicode - - - Application - false - v141 - true - Unicode - - - Application - true - v141 - Unicode - - - Application - true - v141 - Unicode - - - Application - true - v141 - Unicode - - - Application - true - v141 - Unicode - - - Application - true - v141 - Unicode - - - Application - true - v141 - Unicode - - - Application - false - v141 - true - Unicode - - - Application - false - v141 - true - Unicode - - - Application - false - v141 - true - Unicode - - - Application - false - v141 - true - Unicode - - - Application - false - v141 - true - Unicode - - - Application - false - v141 - true - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - false - $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public - - - - - - - false - $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public - - - - - false - $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public - - - - - false - $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public - - - - - false - $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public - - - - - false - $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public - - - - - true - $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public - - - - - - - true - $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public - - - - - true - $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public - - - - - true - $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public - - - - - - - true - $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public - - - - - true - $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public - - - - - true - $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public - - - - - true - $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public - - - - - true - $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public - - - - - false - $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public - - - - - - - false - $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public - - - - - false - $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\..\lib\include\public - - - - - - NotUsing - Level3 - Disabled - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - Guard - EnableFastChecks - false - $(SolutionDir)\..\examples\HelloAria - - - Console - true - true - true - - - - - - - - - - - - - - - $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) - - - Deploy DLLs - - - - - NotUsing - Level3 - Disabled - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Guard - EnableFastChecks - false - $(SolutionDir)\..\examples\HelloAria - - - Console - true - true - true - - - - - - - - - - - - - - - $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) - - - Deploy DLLs - - - - - NotUsing - Level3 - Disabled - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Guard - EnableFastChecks - false - StdCall - $(SolutionDir)\..\examples\HelloAria - - - Console - true - true - true - wininet.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - - - - - - - - - $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) - - - Deploy DLLs - - - - - NotUsing - Level3 - Disabled - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Guard - EnableFastChecks - false - MultiThreaded - $(SolutionDir)\..\examples\HelloAria - - - Console - true - true - true - - - - - - - - - - - - - - - $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) - - - Deploy DLLs - - - - - NotUsing - Level3 - Disabled - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Guard - EnableFastChecks - false - StdCall - $(SolutionDir)\..\examples\HelloAria - - - Console - true - true - true - wininet.lib;kernel32.lib;user32.lib;%(AdditionalDependencies) - - - - - - - - - - - - - - - $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) - - - Deploy DLLs - - - - - NotUsing - Level3 - Disabled - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Guard - EnableFastChecks - false - MultiThreaded - $(SolutionDir)\..\examples\HelloAria - - - Console - true - true - true - - - - - - - - - - - - - - - $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) - - - Deploy DLLs - - - - - NotUsing - Level3 - Disabled - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - Guard - ProgramDatabase - true - false - false - $(SolutionDir)\..\examples\HelloAria - - - Console - true - - - - - - - - - - - - - - - $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) - - - Deploy DLLs - - - - - NotUsing - Level3 - Disabled - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Guard - ProgramDatabase - true - false - false - $(SolutionDir)\..\examples\HelloAria - - - Console - true - wininet.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - - - - - - - - - $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) - - - Deploy DLLs - - - - - NotUsing - Level3 - Disabled - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Guard - ProgramDatabase - true - false - false - MultiThreadedDebug - $(SolutionDir)\..\examples\HelloAria - - - Console - true - - - - - - - - - - - - - - - $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) - - - Deploy DLLs - - - - - NotUsing - Level3 - Disabled - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - Guard - ProgramDatabase - false - $(SolutionDir)\..\examples\HelloAria - - - Console - true - - - - - - - - - - - - - - - $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) - - - Deploy DLLs - - - - - NotUsing - Level3 - Disabled - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Guard - ProgramDatabase - false - $(SolutionDir)\..\examples\HelloAria - - - Console - true - - - - - - - - - - - - - - - $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) - - - Deploy DLLs - - - - - NotUsing - Level3 - Disabled - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Guard - ProgramDatabase - false - StdCall - $(SolutionDir)\..\examples\HelloAria - - - Console - true - wininet.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - - - - - - - - - $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) - - - Deploy DLLs - - - - - NotUsing - Level3 - Disabled - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Guard - ProgramDatabase - false - MultiThreadedDebug - $(SolutionDir)\..\examples\HelloAria - - - Console - true - - - - - - - - - - - - - - - $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) - - - Deploy DLLs - - - - - NotUsing - Level3 - Disabled - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Guard - ProgramDatabase - false - $(SolutionDir)\..\examples\HelloAria - - - Console - true - wininet.lib;kernel32.lib;user32.lib;%(AdditionalDependencies) - - - - - - - - - - - - - - - $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) - - - Deploy DLLs - - - - - NotUsing - Level3 - Disabled - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Guard - ProgramDatabase - false - MultiThreadedDebug - $(SolutionDir)\..\examples\HelloAria - - - Console - true - - - - - - - - - - - - - - - $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) - - - Deploy DLLs - - - - - NotUsing - Level3 - Disabled - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - Guard - EnableFastChecks - $(SolutionDir)\..\examples\HelloAria - - - Console - true - true - true - - - - - - - - - - - - - - - $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) - - - Deploy DLLs - - - - - NotUsing - Level3 - Disabled - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Guard - EnableFastChecks - StdCall - $(SolutionDir)\..\examples\HelloAria - - - Console - true - true - true - wininet.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - - - - - - - - - $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) - - - Deploy DLLs - - - - - NotUsing - Level3 - Disabled - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Guard - EnableFastChecks - StdCall - MultiThreaded - $(SolutionDir)\..\examples\HelloAria - - - Console - true - true - true - - - - - - - - - - - - - - - $(MSBuildProjectDirectory)\deploy-dll.cmd $(Configuration) $(Platform) $(OutDir) - - - Deploy DLLs - - - - - - - - - - - {1DC6B38A-B390-34CE-907F-4958807A3D42} - - - {2ebc7b3c-2af1-442c-9285-cab39bbb8c00} - - - {8fd826f8-3739-44e6-8cc8-997122e53b8d} - - - - - {216a8e97-21f7-4bef-9e52-7f772c177c32} - - - - - - \ No newline at end of file diff --git a/examples/cpp/SampleCppUTC/SampleCppUTC.vcxproj.filters b/examples/cpp/SampleCppUTC/SampleCppUTC.vcxproj.filters deleted file mode 100644 index c682fbb4a..000000000 --- a/examples/cpp/SampleCppUTC/SampleCppUTC.vcxproj.filters +++ /dev/null @@ -1,27 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - - - Header Files - - - \ No newline at end of file diff --git a/examples/cpp/SampleCppUTC/deploy-dll.cmd b/examples/cpp/SampleCppUTC/deploy-dll.cmd deleted file mode 100644 index 449186d64..000000000 --- a/examples/cpp/SampleCppUTC/deploy-dll.cmd +++ /dev/null @@ -1,14 +0,0 @@ -@echo off -set PROJECT_DIR=%~dp0 - -@mkdir %PROJECT_DIR%\include -copy %PROJECT_DIR%..\..\..\lib\include\public\*.* %PROJECT_DIR%\include - -@mkdir %PROJECT_DIR%\lib\%1\%2 -copy %PROJECT_DIR%..\..\..\Solutions\out\%1\%2\win32-dll\*.lib %PROJECT_DIR%\lib\%1\%2 - -@mkdir %PROJECT_DIR%\%1\%2 -copy %PROJECT_DIR%..\..\ -copy %PROJECT_DIR%..\..\..\Solutions\out\%1\%2\win32-dll\*.* %PROJECT_DIR%\lib\%1\%2 -copy %PROJECT_DIR%..\..\..\Solutions\out\%1\%2\win32-dll\*.* %3 -exit /b 0 diff --git a/examples/cpp/SampleCppUTC/main.cpp b/examples/cpp/SampleCppUTC/main.cpp deleted file mode 100644 index 5647108e6..000000000 --- a/examples/cpp/SampleCppUTC/main.cpp +++ /dev/null @@ -1,118 +0,0 @@ -#define _CRT_SECURE_NO_WARNINGS -#pragma warning(suppress:4447) // 'main' signature found without threading mode. Consider using 'int main(Platform::Array^ args)'. - -#include "LogManager.hpp" - -#ifdef _WIN32 - #include -#endif - -#include "CommonFields.h" - -LOGMANAGER_INSTANCE - -using namespace MAT; - -#define TENANT_TOKEN "99999999999999999999999999999999-99999999-9999-9999-9999-999999999999-9999" - -std::string getRandomStringWithSize(int size) -{ - std::string alpha = "abcdefghijklmnopqrstuvwxyz"; - std::string ans; - for (size_t i = 0; i < size; i++) - { - ans += alpha[rand() % 26]; - } - return ans; -} - -void forwardEventToUTC() -{ - printf("LogManager init\n"); - ILogger *logger = LogManager::Initialize(TENANT_TOKEN); - - printf("Updating LogManager context \n"); - ISemanticContext* semanticContext = LogManager::GetSemanticContext(); - semanticContext->SetAppId("MyAppName"); // caller must obtain this from app manifest, e.g. .plist on Mac OS X - semanticContext->SetAppVersion("1.0.1"); // caller must obtain this from app manifest, e.g. .plist on Mac OS X - semanticContext->SetAppLanguage("en-US"); // caller must obtain this from app manifest, e.g. .plist on Mac OS X - semanticContext->SetUserLanguage("en-US"); // caller must obtain the user language from preferences - -#ifndef _WIN32 - // Platforms other than Windows currently do not have automatic network detection implemented, - // so the caller must populate these fields using semantic context API - semanticContext->SetNetworkCost(MAT::NetworkCost::NetworkCost_Unmetered); - semanticContext->SetNetworkType(MAT::NetworkType::NetworkType_Wired); -#endif - - // Ingest 5 sample events. - for(size_t i = 1; i <= 5; i++) - { - EventLatency latency = EventLatency_Normal; - std::string eventName("Microsoft.Applications.Telemetry.ControlOptIn.sample_event"); - eventName += std::to_string((unsigned)i); - - EventProperties event(eventName); - - std::string evtType = "My.Record.BaseType"; // default v1 legacy behaviour: custom.my_record_basetype - event.SetType(evtType); - event.SetLatency(latency); - - // To make event observable in DDV (Diagnostic Data Viewer) - event.SetProperty(COMMONFIELDS_METADATA_VIEWINGPRODUCERID, "MyAppName"); - event.SetProperty(COMMONFIELDS_METADATA_VIEWINGCATEGORY, "Category1|Category2"); - - // Any extra DDV related information - event.SetProperty(COMMONFIELDS_METADATA_VIEWINGPAYLOADDECODERPATH,"EnterPathOrRegistryKey"); - event.SetProperty(COMMONFIELDS_METADATA_VIEWINGPAYLOADENCODEDFIELDNAME,"EnterEncodedFieldName"); - event.SetProperty(COMMONFIELDS_METADATA_VIEWINGEXTRA1, "ExtraDataField1"); - event.SetProperty(COMMONFIELDS_METADATA_VIEWINGEXTRA2, "ExtraDataField2"); - event.SetProperty(COMMONFIELDS_METADATA_VIEWINGEXTRA3, "ExtraDataField3"); - event.SetProperty(COMMONFIELDS_EVENT_PRIVTAGS, PDT_ProductAndServicePerformance); - - logger->LogEvent(event); - } - - printf("LogManager::FlushAndTeardown\n"); - LogManager::FlushAndTeardown(); -} - -void setupConfigs() -{ - auto& config = LogManager::GetLogConfiguration(); - - // Specify Provider-Group for event - // NB: Defaults to ARIA - // config[CFG_STR_UTC][CFG_STR_PROVIDER_GROUP_ID] = "5ECB0BAC-B930-47F5-A8A4-E8253529EDB7"; - - // Set Telemetry System to UTC. - config[CFG_INT_SDK_MODE] = SdkModeTypes::SdkModeTypes_UTCCommonSchema; - - // Other Configs. - config[CFG_INT_TRACE_LEVEL_MASK] = 0; // 0xFFFFFFFF ^ 128; - config[CFG_INT_TRACE_LEVEL_MIN] = ACTTraceLevel_Warn; // ACTTraceLevel_Info; // ACTTraceLevel_Debug; - config[CFG_INT_MAX_TEARDOWN_TIME] = 10; - config[CFG_INT_RAM_QUEUE_SIZE] = 32 * 1024 * 1024; // 32 MB heap limit for sqlite3 - config[CFG_INT_CACHE_FILE_SIZE] = 16 * 1024 * 1024; // 16 MB storage file limit - -#ifdef __APPLE__ - config[CFG_STR_CACHE_FILE_PATH] = "/tmp/offlinestorage.db"; -#else - config[CFG_STR_CACHE_FILE_PATH] = "offlinestorage.db"; -#endif -#ifdef USE_INVALID_URL /* Stress-test for the case when collector is unreachable */ - config[CFG_STR_COLLECTOR_URL] = "https://127.0.0.1/invalid/url"; -#endif -} - -int main() -{ - printf("ControlOptIn Aria 1DS Sample App\n\n"); - - printf("Setting up configuration...\n"); - setupConfigs(); - - forwardEventToUTC(); - - return 0; -} diff --git a/lib/modules/examples/cpp/SampleCppUTC/README.md b/lib/modules/examples/cpp/SampleCppUTC/README.md new file mode 100644 index 000000000..5d054c7ab --- /dev/null +++ b/lib/modules/examples/cpp/SampleCppUTC/README.md @@ -0,0 +1 @@ +This directory contains optional proprietary modules that must be contained in a private git submodule. diff --git a/lib/modules/examples/cpp/SampleCppUTC/SampleCppUTC.vcxproj b/lib/modules/examples/cpp/SampleCppUTC/SampleCppUTC.vcxproj index 7c28eae4d..9bcf427bd 100644 --- a/lib/modules/examples/cpp/SampleCppUTC/SampleCppUTC.vcxproj +++ b/lib/modules/examples/cpp/SampleCppUTC/SampleCppUTC.vcxproj @@ -1117,18 +1117,18 @@ - + {1DC6B38A-B390-34CE-907F-4958807A3D42} - + {2ebc7b3c-2af1-442c-9285-cab39bbb8c00} - + {8fd826f8-3739-44e6-8cc8-997122e53b8d} - + {216a8e97-21f7-4bef-9e52-7f772c177c32} diff --git a/lib/modules/examples/cpp/SampleCppUTC/deploy-dll.cmd b/lib/modules/examples/cpp/SampleCppUTC/deploy-dll.cmd index 449186d64..238e5510c 100644 --- a/lib/modules/examples/cpp/SampleCppUTC/deploy-dll.cmd +++ b/lib/modules/examples/cpp/SampleCppUTC/deploy-dll.cmd @@ -1,14 +1,15 @@ @echo off set PROJECT_DIR=%~dp0 +del %3\*.exe + @mkdir %PROJECT_DIR%\include -copy %PROJECT_DIR%..\..\..\lib\include\public\*.* %PROJECT_DIR%\include +copy /y %PROJECT_DIR%..\..\..\..\include\public\*.* %PROJECT_DIR%\include @mkdir %PROJECT_DIR%\lib\%1\%2 -copy %PROJECT_DIR%..\..\..\Solutions\out\%1\%2\win32-dll\*.lib %PROJECT_DIR%\lib\%1\%2 +copy /y %PROJECT_DIR%..\..\..\..\..\Solutions\out\%1\%2\win32-dll\*.lib %PROJECT_DIR%\lib\%1\%2 @mkdir %PROJECT_DIR%\%1\%2 -copy %PROJECT_DIR%..\..\ -copy %PROJECT_DIR%..\..\..\Solutions\out\%1\%2\win32-dll\*.* %PROJECT_DIR%\lib\%1\%2 -copy %PROJECT_DIR%..\..\..\Solutions\out\%1\%2\win32-dll\*.* %3 +copy /y %PROJECT_DIR%..\..\..\..\..\Solutions\out\%1\%2\win32-dll\*.* %PROJECT_DIR%\lib\%1\%2 +copy /y %PROJECT_DIR%..\..\..\..\..\Solutions\out\%1\%2\win32-dll\*.* %3 exit /b 0 diff --git a/lib/modules/examples/cpp/SampleCppUTC/main.cpp b/lib/modules/examples/cpp/SampleCppUTC/main.cpp index 1aa224900..5417f029f 100644 --- a/lib/modules/examples/cpp/SampleCppUTC/main.cpp +++ b/lib/modules/examples/cpp/SampleCppUTC/main.cpp @@ -15,6 +15,17 @@ using namespace MAT; #define TENANT_TOKEN "99999999999999999999999999999999-99999999-9999-9999-9999-999999999999-9999" +std::string getRandomStringWithSize(size_t size) +{ + std::string alpha = "abcdefghijklmnopqrstuvwxyz"; + std::string ans; + for (size_t i = 0; i < size; i++) + { + ans += alpha[rand() % 26]; + } + return ans; +} + void forwardEventToUTC() { printf("LogManager init\n"); @@ -57,6 +68,7 @@ void forwardEventToUTC() event.SetProperty(COMMONFIELDS_METADATA_VIEWINGEXTRA1, "ExtraDataField1"); event.SetProperty(COMMONFIELDS_METADATA_VIEWINGEXTRA2, "ExtraDataField2"); event.SetProperty(COMMONFIELDS_METADATA_VIEWINGEXTRA3, "ExtraDataField3"); + event.SetProperty(COMMONFIELDS_EVENT_PRIVTAGS, PDT_ProductAndServicePerformance); logger->LogEvent(event); } From 6a8f98e252fcd4a0f44c18cd8614293faa3fbd15 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Tue, 25 Jun 2019 11:45:35 -0700 Subject: [PATCH 14/15] Specify the proper iKey for stats event --- lib/include/mat/config-ikeys.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/include/mat/config-ikeys.h b/lib/include/mat/config-ikeys.h index 9c6ad9de3..b19023b46 100644 --- a/lib/include/mat/config-ikeys.h +++ b/lib/include/mat/config-ikeys.h @@ -6,9 +6,9 @@ #ifndef CONFIG_IKEYS_H #define CONFIG_IKEYS_H #if defined(__linux__) || defined(__gnu_linux__) -#define STATS_TOKEN_PROD "99999999999999999999999999999999-99999999-9999-9999-9999-999999999999-9999" +#define STATS_TOKEN_PROD "4bb4d6f7cafc4e9292f972dca2dcde42-bd019ee8-e59c-4b0f-a02c-84e72157a3ef-7485" #else -#define STATS_TOKEN_PROD "99999999999999999999999999999999-99999999-9999-9999-9999-999999999999-9999" +#define STATS_TOKEN_PROD "4bb4d6f7cafc4e9292f972dca2dcde42-bd019ee8-e59c-4b0f-a02c-84e72157a3ef-7485" #endif -#define STATS_TOKEN_INT "99999999999999999999999999999999-99999999-9999-9999-9999-999999999999-9999" +#define STATS_TOKEN_INT "8130ef8ff472405d89d6f420038927ea-0c0d561e-cca5-4c81-90ed-0aa9ad786a03-7166" #endif From 1e5ebc81f754c777d72721d389897e539758641e Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Tue, 25 Jun 2019 11:55:29 -0700 Subject: [PATCH 15/15] Track submodule lib/modules from master --- .gitmodules | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitmodules b/.gitmodules index 137214b95..1dc490722 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,5 @@ [submodule "lib/modules"] path = lib/modules url = https://github.com/Microsoft/cpp_client_telemetry_modules + branch = master +