Bug 1884213 - Part 4: Convert Text and Tracing markers to use BaseMarkerType so they gain ETW support. r=mstange,profiler-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D203985
This commit is contained in:
Bas Schouten 2024-03-11 20:13:57 +00:00
Родитель b6330536be
Коммит 44cb6d2bea
3 изменённых файлов: 43 добавлений и 28 удалений

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

@ -138,45 +138,54 @@ inline ProfileBufferBlockIndex AddMarker(const ProfilerString8View& aName,
namespace mozilla::baseprofiler::markers {
// Most common marker type. Others are in BaseProfilerMarkerTypes.h.
struct TextMarker {
static constexpr Span<const char> MarkerTypeName() {
return MakeStringSpan("Text");
}
struct TextMarker : public BaseMarkerType<TextMarker> {
static constexpr const char* Name = "Text";
static constexpr const char* Description = "Generic text marker";
static constexpr bool StoreName = true;
using MS = MarkerSchema;
static constexpr MS::PayloadField PayloadFields[] =
// XXX - This is confusingly labeled 'name'. We probably want to fix that.
{{"name", MS::InputType::CString, "Details", MS::Format::String,
MS::PayloadFlags::Searchable}};
static constexpr MS::Location Locations[] = {MS::Location::MarkerChart,
MS::Location::MarkerTable};
static constexpr const char* ChartLabel = "{marker.data.name}";
static constexpr const char* TableLabel =
"{marker.name} - {marker.data.name}";
static void StreamJSONMarkerData(baseprofiler::SpliceableJSONWriter& aWriter,
const ProfilerString8View& aText) {
aWriter.StringProperty("name", aText);
}
static MarkerSchema MarkerTypeDisplay() {
using MS = MarkerSchema;
MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable};
schema.SetChartLabel("{marker.data.name}");
schema.SetTableLabel("{marker.name} - {marker.data.name}");
schema.AddKeyLabelFormatSearchable("name", "Details", MS::Format::String,
MS::Searchable::Searchable);
return schema;
}
};
// Keep this struct in sync with the `gecko_profiler::marker::Tracing` Rust
// counterpart.
struct Tracing {
static constexpr Span<const char> MarkerTypeName() {
return MakeStringSpan("tracing");
}
struct Tracing : public BaseMarkerType<Tracing> {
static constexpr const char* Name = "tracing";
static constexpr const char* Description = "Generic tracing marker";
static constexpr bool StoreName = true;
using MS = MarkerSchema;
static constexpr MS::PayloadField PayloadFields[] = {
{"category", MS::InputType::CString, "Type", MS::Format::String,
MS::PayloadFlags::Searchable}};
static constexpr MS::Location Locations[] = {MS::Location::MarkerChart,
MS::Location::MarkerTable,
MS::Location::TimelineOverview};
static void StreamJSONMarkerData(SpliceableJSONWriter& aWriter,
const ProfilerString8View& aCategory) {
if (aCategory.Length() != 0) {
aWriter.StringProperty("category", aCategory);
}
}
static MarkerSchema MarkerTypeDisplay() {
using MS = MarkerSchema;
MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable,
MS::Location::TimelineOverview};
schema.AddKeyLabelFormatSearchable("category", "Type", MS::Format::String,
MS::Searchable::Searchable);
return schema;
}
};
} // namespace mozilla::baseprofiler::markers

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

@ -784,7 +784,9 @@ class MarkerSchema {
Generic = 1,
UserMarkers = 1 << 1,
Memory = 1 << 2,
Scheduling = 1 << 3
Scheduling = 1 << 3,
Text = 1 << 4,
Tracing = 1 << 5
};
// Flags which describe additional information for a PayloadField.

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

@ -3228,12 +3228,14 @@ TEST(GeckoProfiler, Markers)
EXPECT_EQ(display[0u].asString(), "marker-chart");
EXPECT_EQ(display[1u].asString(), "marker-table");
ASSERT_EQ(data.size(), 1u);
ASSERT_EQ(data.size(), 2u);
ASSERT_TRUE(data[0u].isObject());
EXPECT_EQ_JSON(data[0u]["key"], String, "name");
EXPECT_EQ_JSON(data[0u]["label"], String, "Details");
EXPECT_EQ_JSON(data[0u]["format"], String, "string");
EXPECT_EQ_JSON(data[1u]["label"], String, "Description");
EXPECT_EQ_JSON(data[1u]["value"], String, "Generic text marker");
} else if (nameString == "NoPayloadUserData") {
// TODO: Remove this when bug 1646714 lands.
@ -3252,12 +3254,14 @@ TEST(GeckoProfiler, Markers)
EXPECT_EQ(display[1u].asString(), "marker-table");
EXPECT_EQ(display[2u].asString(), "timeline-overview");
ASSERT_EQ(data.size(), 1u);
ASSERT_EQ(data.size(), 2u);
ASSERT_TRUE(data[0u].isObject());
EXPECT_EQ_JSON(data[0u]["key"], String, "category");
EXPECT_EQ_JSON(data[0u]["label"], String, "Type");
EXPECT_EQ_JSON(data[0u]["format"], String, "string");
EXPECT_EQ_JSON(data[1u]["label"], String, "Description");
EXPECT_EQ_JSON(data[1u]["value"], String, "Generic tracing marker");
} else if (nameString == "BHR-detected hang") {
EXPECT_EQ(display.size(), 2u);