Copy as Markdown
Other Tools
// -*- mode: C++ -*-
// AUTOGENERATED BY toolkit/components/gecko_trace/scripts/codegen.py DO NOT EDIT.
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
#ifndef GECKO_TRACE_EVENTS_H
#define GECKO_TRACE_EVENTS_H
#include "mozilla/Maybe.h"
#include "mozilla/gecko_trace/SpanEvent.h"
namespace mozilla::gecko_trace {
/**
* Namespace containing auto-generated event classes for GeckoTrace.
*
* Each event class corresponds to a trace event definition and provides
* a builder-pattern interface for setting attributes before emission.
*/
namespace events {
/**
* Trace event class for "test.simple" events.
*
* Simple test event with basic attributes
*
* Generated from: toolkit/components/gecko-trace/tests/gtest/gecko-trace.yaml:8:4
*
* Usage:
* SpanEvent::TestSimple()
* .WithTestString(test_string)
* .WithTestInteger(test_integer)
* .WithTestBoolean(test_boolean);
*
* Attributes:
* - test_string (string): Test string attribute
* - test_integer (integer): Test integer attribute
* - test_boolean (boolean): Test boolean attribute
*/
template <class T>
class TestSimpleEventBase : public virtual SpanEvent {
public:
/**
* Set the test_string attribute for this trace event.
*
* Test string attribute
*
* @param aTestString The test_string value
* (type: std::string_view)
* @return Reference to this event object for method chaining
*/
T& WithTestString(std::string_view aTestString) {
mTestString = mozilla::Some(aTestString);
return static_cast<T&>(*this);
}
/**
* Set the test_integer attribute for this trace event.
*
* Test integer attribute
*
* @param aTestInteger The test_integer value
* (type: int64_t)
* @return Reference to this event object for method chaining
*/
T& WithTestInteger(int64_t aTestInteger) {
mTestInteger = mozilla::Some(aTestInteger);
return static_cast<T&>(*this);
}
/**
* Set the test_boolean attribute for this trace event.
*
* Test boolean attribute
*
* @param aTestBoolean The test_boolean value
* (type: bool)
* @return Reference to this event object for method chaining
*/
T& WithTestBoolean(bool aTestBoolean) {
mTestBoolean = mozilla::Some(aTestBoolean);
return static_cast<T&>(*this);
}
bool ForEachKeyValue(
std::function<bool(std::string_view, AttributeValue)> aCallback)
const override {
// Process this event's attributes
if (mTestString.isSome() &&
!aCallback("test_string",
AttributeValue(mTestString.value()))) {
return false;
}
if (mTestInteger.isSome() &&
!aCallback("test_integer",
AttributeValue(mTestInteger.value()))) {
return false;
}
if (mTestBoolean.isSome() &&
!aCallback("test_boolean",
AttributeValue(mTestBoolean.value()))) {
return false;
}
return true;
}
std::string_view GetEventName() const override {
return "test.simple";
}
size_t Size() const override {
size_t size = 3;
return size;
}
private:
mozilla::Maybe<std::string_view> mTestString;
mozilla::Maybe<int64_t> mTestInteger;
mozilla::Maybe<bool> mTestBoolean;
};
class TestSimpleEvent : public TestSimpleEventBase<TestSimpleEvent> { };
/**
* Trace event class for "test.complex" events.
*
* Test event with multiple inheritance
*
* Generated from: toolkit/components/gecko-trace/tests/gtest/gecko-trace.yaml:21:4
*
* Usage:
* SpanEvent::TestComplex()
* .WithTestData(test_data)
* .WithRetryCount(retry.count);
*
* Inherits from:
* - TestSimpleEvent
*
* Attributes:
* - test_data (string): Additional test data
* - retry.count (integer): Number of retries attempted
*/
template <class T>
class TestComplexEventBase : public TestSimpleEventBase<T> {
public:
/**
* Set the test_data attribute for this trace event.
*
* Additional test data
*
* @param aTestData The test_data value
* (type: std::string_view)
* @return Reference to this event object for method chaining
*/
T& WithTestData(std::string_view aTestData) {
mTestData = mozilla::Some(aTestData);
return static_cast<T&>(*this);
}
/**
* Set the retry.count attribute for this trace event.
*
* Number of retries attempted
*
* @param aRetryCount The retry.count value
* (type: int64_t)
* @return Reference to this event object for method chaining
*/
T& WithRetryCount(int64_t aRetryCount) {
mRetryCount = mozilla::Some(aRetryCount);
return static_cast<T&>(*this);
}
bool ForEachKeyValue(
std::function<bool(std::string_view, AttributeValue)> aCallback)
const override {
// Process attributes from parent classes first
if (!TestSimpleEventBase<T>::ForEachKeyValue(aCallback)) {
return false;
}
// Process this event's attributes
if (mTestData.isSome() &&
!aCallback("test_data",
AttributeValue(mTestData.value()))) {
return false;
}
if (mRetryCount.isSome() &&
!aCallback("retry.count",
AttributeValue(mRetryCount.value()))) {
return false;
}
return true;
}
std::string_view GetEventName() const override {
return "test.complex";
}
size_t Size() const override {
size_t size = 2;
size += TestSimpleEventBase<T>::Size();
return size;
}
private:
mozilla::Maybe<std::string_view> mTestData;
mozilla::Maybe<int64_t> mRetryCount;
};
class TestComplexEvent : public TestComplexEventBase<TestComplexEvent> { };
/**
* Trace event class for "test.deep_inheritance" events.
*
* Test event with deep multi-level inheritance
*
* Generated from: toolkit/components/gecko-trace/tests/gtest/gecko-trace.yaml:32:4
*
* Usage:
* SpanEvent::TestDeepInheritance()
* .WithExtraInfo(extra.info);
*
* Inherits from:
* - TestComplexEvent
*
* Attributes:
* - extra.info (string): Additional information for deep inheritance test
*/
template <class T>
class TestDeepInheritanceEventBase : public TestComplexEventBase<T> {
public:
/**
* Set the extra.info attribute for this trace event.
*
* Additional information for deep inheritance test
*
* @param aExtraInfo The extra.info value
* (type: std::string_view)
* @return Reference to this event object for method chaining
*/
T& WithExtraInfo(std::string_view aExtraInfo) {
mExtraInfo = mozilla::Some(aExtraInfo);
return static_cast<T&>(*this);
}
bool ForEachKeyValue(
std::function<bool(std::string_view, AttributeValue)> aCallback)
const override {
// Process attributes from parent classes first
if (!TestComplexEventBase<T>::ForEachKeyValue(aCallback)) {
return false;
}
// Process this event's attributes
return !((mExtraInfo.isSome() &&
!aCallback("extra.info",
AttributeValue(mExtraInfo.value()))));
}
std::string_view GetEventName() const override {
return "test.deep_inheritance";
}
size_t Size() const override {
size_t size = 1;
size += TestComplexEventBase<T>::Size();
return size;
}
private:
mozilla::Maybe<std::string_view> mExtraInfo;
};
class TestDeepInheritanceEvent : public TestDeepInheritanceEventBase<TestDeepInheritanceEvent> { };
} // namespace events
/**
* Namespace containing factory functions for creating trace events.
*
* These functions provide a convenient way to create event objects using
* the builder pattern. Each function returns an event object that can be
* configured with attributes and then emitted.
*
* Example usage:
* SpanEvent::SomeEvent()
* .WithAttribute1(value1)
* .WithAttribute2(value2);
*/
namespace event {
/**
* Create a new test.simple trace event.
*
* Simple test event with basic attributes
*
* @return A new TestSimpleEvent instance ready for
* configuration
*/
inline events::TestSimpleEvent TestSimple() {
return events::TestSimpleEvent{};
}
/**
* Create a new test.complex trace event.
*
* Test event with multiple inheritance
*
* @return A new TestComplexEvent instance ready for
* configuration
*/
inline events::TestComplexEvent TestComplex() {
return events::TestComplexEvent{};
}
/**
* Create a new test.deep_inheritance trace event.
*
* Test event with deep multi-level inheritance
*
* @return A new TestDeepInheritanceEvent instance ready for
* configuration
*/
inline events::TestDeepInheritanceEvent TestDeepInheritance() {
return events::TestDeepInheritanceEvent{};
}
} // namespace event
} // namespace mozilla::gecko_trace
#endif // GECKO_TRACE_EVENTS_H