Skip to content

Commit 765fd55

Browse files
committed
dedicated diagnostics demo and level improvements
1 parent 2f5d8e2 commit 765fd55

File tree

21 files changed

+170
-62
lines changed

21 files changed

+170
-62
lines changed

IntelPresentMon/AppCef/source/SchemeFileHandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ namespace p2c::client::cef
5858
return false;
5959
}
6060

61-
pmlog_info(std::format(L"Opening file: {}", file_path_.wstring()));
61+
pmlog_dbg(std::format(L"Opening file: {}", file_path_.wstring()));
6262
return true;
6363
}
6464

IntelPresentMon/AppCef/source/SchemeHandlerFactory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ namespace p2c::client::cef
7070
return nullptr;
7171
}
7272
else {
73-
pmlog_info(std::format(L"Processing request URL: {}", request->GetURL().ToWString()));
73+
pmlog_dbg(std::format(L"Processing request URL: {}", request->GetURL().ToWString()));
7474
}
7575
return new SchemeFileHandler(baseDir_);
7676
}

IntelPresentMon/CommonUtilities/Exception.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ namespace pmon::util
7878
std::rethrow_exception(pEx);
7979
}
8080
catch (const std::exception& e) {
81-
return std::format("[{}]\n{}", typeid(e).name(), e.what());
81+
return std::format("[{}] {}", typeid(e).name(), e.what());
8282
}
8383
catch (...) {
8484
return "Unrecognized exception";

IntelPresentMon/CommonUtilities/log/GlobalPolicy.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ namespace pmon::util::log
4141
{
4242
traceLevel_ = level;
4343
}
44+
void GlobalPolicy::SetTraceLevelDefault() noexcept
45+
{
46+
SetTraceLevel(Level::Error);
47+
}
4448
bool GlobalPolicy::GetResolveTraceInClientThread() const noexcept
4549
{
4650
return resolveTraceInClientThread_;

IntelPresentMon/CommonUtilities/log/GlobalPolicy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace pmon::util::log
1313
void SetLogLevelDefault() noexcept;
1414
Level GetTraceLevel() const noexcept;
1515
void SetTraceLevel(Level level) noexcept;
16+
void SetTraceLevelDefault() noexcept;
1617
bool GetResolveTraceInClientThread() const noexcept;
1718
void SetResolveTraceInClientThread(bool setting) noexcept;
1819
bool GetExceptionTrace() const noexcept;

IntelPresentMon/PresentMonAPI2/PresentMonAPI.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,12 @@ PRESENTMON_API2_EXPORT PM_STATUS pmRegisterDynamicQuery(PM_SESSION_HANDLE sessio
297297
PM_QUERY_ELEMENT* pElements, uint64_t numElements, double windowSizeMs, double metricOffsetMs)
298298
{
299299
try {
300-
if (!pElements || !numElements) {
301-
// TODO: error code for bad args
300+
if (!pElements) {
301+
pmlog_error(L"null pointer to query element array argument").diag();
302+
return PM_STATUS_FAILURE;
303+
}
304+
if (!numElements) {
305+
pmlog_error(L"zero length query element array").diag();
302306
return PM_STATUS_FAILURE;
303307
}
304308
const auto queryHandle = LookupMiddleware_(sessionHandle).RegisterDynamicQuery(

IntelPresentMon/PresentMonAPIWrapper/DiagnosticHandler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ namespace pmapi
5151
PM_DIAGNOSTIC_LEVEL filterLevel,
5252
int outputFlags,
5353
std::function<void(const PM_DIAGNOSTIC_MESSAGE&)> callback,
54+
int gracePeriodMs,
5455
std::span<PM_DIAGNOSTIC_SUBSYSTEM> allowList,
5556
bool enableTimestamp,
5657
bool enableTrace,
57-
bool enableLocation,
58-
int gracePeriodMs
58+
bool enableLocation
5959
) : gracePeriodMs_{ gracePeriodMs } {
6060
const PM_DIAGNOSTIC_CONFIGURATION config{
6161
.filterLevel = filterLevel,

IntelPresentMon/PresentMonAPIWrapper/DiagnosticHandler.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace pmapi
88
{
9-
// DiagnosticHandler is simplifies the process of setting up the debug diagnostic layer
9+
// DiagnosticHandler simplifies the process of setting up the debug diagnostic layer
1010
// when you supply a callback, this class will spawn a thread to process messages from
1111
// the diagnostic queue (sleeping while none are available)
1212
// make sure that any resources accessed by this callback are done so in a thread-safe manner
@@ -21,16 +21,16 @@ namespace pmapi
2121
int outputFlags = PM_DIAGNOSTIC_OUTPUT_FLAGS_DEBUGGER,
2222
// callback that will process messages received into the queue
2323
std::function<void(const PM_DIAGNOSTIC_MESSAGE&)> callback = {},
24+
// add a grace period to wait for final messages before destroying diagnostics (ms)
25+
int gracePeriodMs = 10,
2426
// span of subsystems to allow, ignore all not in this span (empty span to accept all)
2527
std::span<PM_DIAGNOSTIC_SUBSYSTEM> allowList = {},
2628
// capture timestamps as a string and add to all non-queue outputs
2729
bool enableTimestamp = true,
2830
// capture stack traces as a string when available (typically for error-level messages)
2931
bool enableTrace = false,
3032
// capture source file and line number as a string
31-
bool enableLocation = false,
32-
// add a grace period to wait for final messages before destroying diagnostics (ms)
33-
int gracePeriodMs = 50
33+
bool enableLocation = false
3434
);
3535
~DiagnosticHandler();
3636
private:

IntelPresentMon/PresentMonAPIWrapper/Session.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ namespace pmapi
5252
// begin tracking a process, necessary to consume frame data or query metrics involving that process
5353
ProcessTracker TrackProcess(uint32_t pid);
5454
// register (build/compile) a dynamic query used to poll metrics
55-
DynamicQuery RegisterDyanamicQuery(std::span<PM_QUERY_ELEMENT> elements, double winSizeMs, double metricOffsetMs);
55+
DynamicQuery RegisterDyanamicQuery(std::span<PM_QUERY_ELEMENT> elements, double winSizeMs = 1000, double metricOffsetMs = 1020);
5656
// register (build/compile) a frame query used to consume frame events
5757
FrameQuery RegisterFrameQuery(std::span<PM_QUERY_ELEMENT> elements);
5858
// set the rate at which the service polls device telemetry data

IntelPresentMon/PresentMonAPIWrapperCommon/Introspection.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <format>
33
#include <cassert>
44
#include "Exception.h"
5+
#include "../CommonUtilities/log/Log.h"
56

67

78
namespace pmapi::intro
@@ -523,6 +524,7 @@ namespace pmapi::intro
523524
MetricView Root::FindMetric(PM_METRIC metricId) const
524525
{
525526
if (auto i = metricMap.find(metricId); i == metricMap.end()) {
527+
pmlog_error(std::format(L"Cannot find metric id={} in introspection data", (int)metricId)).diag();
526528
throw LookupException{ std::format("unable to find metric ID={}", (int)metricId) };
527529
}
528530
else {

0 commit comments

Comments
 (0)