Open 3D Engine AzCore API Reference 25.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::Metrics::JsonTraceEventLogger Class Reference

Inherits AZ::Metrics::IEventLogger.

Public Types

using JsonEventString = AZStd::fixed_string< MaxEventJsonStringSize >
 

Public Member Functions

 JsonTraceEventLogger (JsonTraceEventLoggerConfig)
 
 JsonTraceEventLogger (AZStd::unique_ptr< AZ::IO::GenericStream > stream)
 Generic stream which owned by the JsonEventLogger.
 
 JsonTraceEventLogger (AZStd::unique_ptr< AZ::IO::GenericStream > stream, JsonTraceEventLoggerConfig)
 
void SetName (AZStd::string_view) override
 Set the name associated of this event logger.
 
AZStd::string_view GetName () const override
 Returns the name associated with this event logger.
 
void Flush () override
 Writes and json data to the stream.
 
ResultOutcome RecordDurationEventBegin (const DurationArgs &) override
 
ResultOutcome RecordDurationEventEnd (const DurationArgs &) override
 
ResultOutcome RecordCompleteEvent (const CompleteArgs &) override
 
ResultOutcome RecordInstantEvent (const InstantArgs &) override
 
ResultOutcome RecordCounterEvent (const CounterArgs &) override
 
ResultOutcome RecordAsyncEventStart (const AsyncArgs &) override
 
ResultOutcome RecordAsyncEventInstant (const AsyncArgs &) override
 
ResultOutcome RecordAsyncEventEnd (const AsyncArgs &) override
 
void ResetStream (AZStd::unique_ptr< AZ::IO::GenericStream > stream)
 Closes the previous stream and associates a new stream.
 

Static Public Attributes

static constexpr size_t MaxEventJsonStringSize = 1024
 

Protected Member Functions

bool FlushRequest (const EventDesc &)
 Responsible for writing the recorded event data to JSON.
 
bool Start (AZ::IO::GenericStream &stream)
 Start the JSON document by adding the opening '[' bracket.
 
bool Complete (AZ::IO::GenericStream &stream)
 Complete the JSON document by adding the ending ']' bracket.
 
void ResetSettingsHandler ()
 

Protected Attributes

AZStd::mutex m_flushToStreamMutex
 
AZStd::unique_ptr< AZ::IO::GenericStreamm_stream
 
AZStd::string m_name
 Provides a user friendly name for the event logger.
 
bool m_active { GetDefaultActiveState() }
 
AZ::SettingsRegistryInterfacem_settingsRegistry {}
 
AZ::SettingsRegistryInterface::NotifyEventHandler m_settingsHandler
 
AZStd::atomic_bool m_prependComma { false }
 
size_t m_eventCount {}
 Tracks the number of events written so far.
 

Member Function Documentation

◆ RecordAsyncEventEnd()

ResultOutcome AZ::Metrics::JsonTraceEventLogger::RecordAsyncEventEnd ( const AsyncArgs &  )
override

Records an end async event Uses the event header to populate the event fields

◆ RecordAsyncEventInstant()

ResultOutcome AZ::Metrics::JsonTraceEventLogger::RecordAsyncEventInstant ( const AsyncArgs &  )
override

Records an instant async event Uses the event header to populate the event fields

◆ RecordAsyncEventStart()

ResultOutcome AZ::Metrics::JsonTraceEventLogger::RecordAsyncEventStart ( const AsyncArgs &  )
override

Records a start async event Uses the event header to populate the event fields

◆ RecordCompleteEvent()

ResultOutcome AZ::Metrics::JsonTraceEventLogger::RecordCompleteEvent ( const CompleteArgs &  )
override

Records a complete event(encapsulates a beging and end duration event) Uses the event header to populate the event fields

◆ RecordCounterEvent()

ResultOutcome AZ::Metrics::JsonTraceEventLogger::RecordCounterEvent ( const CounterArgs &  )
override

Records a Counter Uses the event header to populate the event fields

◆ RecordDurationEventEnd()

ResultOutcome AZ::Metrics::JsonTraceEventLogger::RecordDurationEventEnd ( const DurationArgs &  )
override

Records an end duration event Uses the event header to populate the event fields

◆ RecordInstantEvent()

ResultOutcome AZ::Metrics::JsonTraceEventLogger::RecordInstantEvent ( const InstantArgs &  )
override

Records an instant event Uses the event header to populate the event fields

◆ ResetSettingsHandler()

void AZ::Metrics::JsonTraceEventLogger::ResetSettingsHandler ( )
protected

Reads the event logger "/O3DE/Metrics/<Name>/Active" setting from the Settings Registry and resets a handler to listen for changes to any setting below "/O3DE/Metrics/<Name>" key

Member Data Documentation

◆ m_active

bool AZ::Metrics::JsonTraceEventLogger::m_active { GetDefaultActiveState() }
protected

Active flag to to allow the record functions to write event data to the stream member The default is true When the name of the event logger is set, the value is updated from the settings registry "/O3DE/Metrics/<Name>/Active" bool

◆ m_prependComma

AZStd::atomic_bool AZ::Metrics::JsonTraceEventLogger::m_prependComma { false }
protected

Keep track of whether this is the first event being logged This is used to prepend a leading comma before the event entry in the trace events array

◆ m_settingsRegistry

AZ::SettingsRegistryInterface* AZ::Metrics::JsonTraceEventLogger::m_settingsRegistry {}
protected

Stores a pointer to the SettingsRegistry used to query settings associated with this event logger instance If nullptr, the global SettingsRegistry is queried


The documentation for this class was generated from the following file: