Open 3D Engine AzCore API Reference 23.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 Types inherited from AZ::Metrics::IEventLogger
using ErrorString = AZStd::fixed_string< 256 >
 Outcome which is populated with an error message should the event recording fail.
 
using ResultOutcome = AZ::Outcome< void, ErrorString >
 

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.
 
- Public Member Functions inherited from AZ::Metrics::IEventLogger
 AZ_RTTI (IEventLogger, "{D39D09FA-DEA0-4874-BC45-4B310C3DD52E}")
 
virtual void SetName (AZStd::string_view name)
 
virtual AZStd::string_view GetName () const
 
virtual void Flush ()=0
 
virtual ResultOutcome RecordDurationEventBegin (const DurationArgs &)=0
 
virtual ResultOutcome RecordDurationEventEnd (const DurationArgs &)=0
 
virtual ResultOutcome RecordCompleteEvent (const CompleteArgs &)=0
 
virtual ResultOutcome RecordInstantEvent (const InstantArgs &)=0
 
virtual ResultOutcome RecordCounterEvent (const CounterArgs &)=0
 
virtual ResultOutcome RecordAsyncEventStart (const AsyncArgs &)=0
 
virtual ResultOutcome RecordAsyncEventInstant (const AsyncArgs &)=0
 
virtual ResultOutcome RecordAsyncEventEnd (const AsyncArgs &)=0
 

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

◆ Flush()

void AZ::Metrics::JsonTraceEventLogger::Flush ( )
overridevirtual

Writes and json data to the stream.

Implements AZ::Metrics::IEventLogger.

◆ GetName()

AZStd::string_view AZ::Metrics::JsonTraceEventLogger::GetName ( ) const
overridevirtual

Returns the name associated with this event logger.

Reimplemented from AZ::Metrics::IEventLogger.

◆ RecordAsyncEventEnd()

ResultOutcome AZ::Metrics::JsonTraceEventLogger::RecordAsyncEventEnd ( const AsyncArgs )
overridevirtual

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

Implements AZ::Metrics::IEventLogger.

◆ RecordAsyncEventInstant()

ResultOutcome AZ::Metrics::JsonTraceEventLogger::RecordAsyncEventInstant ( const AsyncArgs )
overridevirtual

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

Implements AZ::Metrics::IEventLogger.

◆ RecordAsyncEventStart()

ResultOutcome AZ::Metrics::JsonTraceEventLogger::RecordAsyncEventStart ( const AsyncArgs )
overridevirtual

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

Implements AZ::Metrics::IEventLogger.

◆ RecordCompleteEvent()

ResultOutcome AZ::Metrics::JsonTraceEventLogger::RecordCompleteEvent ( const CompleteArgs )
overridevirtual

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

Implements AZ::Metrics::IEventLogger.

◆ RecordCounterEvent()

ResultOutcome AZ::Metrics::JsonTraceEventLogger::RecordCounterEvent ( const CounterArgs )
overridevirtual

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

Implements AZ::Metrics::IEventLogger.

◆ RecordDurationEventBegin()

ResultOutcome AZ::Metrics::JsonTraceEventLogger::RecordDurationEventBegin ( const DurationArgs )
overridevirtual

Records a begin duration event Uses the event header to populate the event fields

Implements AZ::Metrics::IEventLogger.

◆ RecordDurationEventEnd()

ResultOutcome AZ::Metrics::JsonTraceEventLogger::RecordDurationEventEnd ( const DurationArgs )
overridevirtual

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

Implements AZ::Metrics::IEventLogger.

◆ RecordInstantEvent()

ResultOutcome AZ::Metrics::JsonTraceEventLogger::RecordInstantEvent ( const InstantArgs )
overridevirtual

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

Implements AZ::Metrics::IEventLogger.

◆ 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

◆ SetName()

void AZ::Metrics::JsonTraceEventLogger::SetName ( AZStd::string_view  )
overridevirtual

Set the name associated of this event logger.

Reimplemented from AZ::Metrics::IEventLogger.

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: