Open 3D Engine AWSMetrics Gem API Reference  24.09
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AWSMetrics::MetricsManager Class Reference

Metrics manager handles direct or batch sending metrics to backend. More...

#include <MetricsManager.h>

Public Member Functions

bool Init ()
 
void StartMetrics ()
 Start sending metircs to the backend or a local file.
 
void ShutdownMetrics ()
 Stop sending metircs to the backend or a local file.
 
bool SubmitMetrics (const AZStd::vector< MetricsAttribute > &metricsAttributes=AZStd::vector< MetricsAttribute >(), int eventPriority=0, const AZStd::string &eventSourceOverride="")
 
bool SendMetricsAsync (const AZStd::vector< MetricsAttribute > &metricsAttributes=AZStd::vector< MetricsAttribute >(), int eventPriority=0, const AZStd::string &eventSourceOverride="")
 
void OnResponseReceived (const MetricsQueue &metricsEventsInRequest, const ServiceAPI::PostMetricsEventsResponseEntries &responseEntries=ServiceAPI::PostMetricsEventsResponseEntries())
 
void FlushMetricsAsync ()
 Implementation for flush all metrics buffered in memory.
 
AZ::s64 GetNumBufferedMetrics ()
 
const GlobalStatisticsGetGlobalStatistics () const
 
void UpdateOfflineRecordingStatus (bool enable, bool submitLocalMetrics=false)
 
const char * GetMetricsFileDirectory () const
 
const char * GetMetricsFilePath () const
 
int GetNumTotalRequests () const
 

Static Public Attributes

static const unsigned int DesiredMaxWorkers = 2
 

Protected Member Functions

virtual AZ::Outcome< void, AZStd::string > SendMetricsToFile (AZStd::shared_ptr< MetricsQueue > metricsQueue)
 

Detailed Description

Metrics manager handles direct or batch sending metrics to backend.

Member Function Documentation

◆ GetGlobalStatistics()

const GlobalStatistics& AWSMetrics::MetricsManager::GetGlobalStatistics ( ) const

Retrieve the global statistics for sending metrics.

Returns
Global statistics for sending metrics

◆ GetMetricsFileDirectory()

const char* AWSMetrics::MetricsManager::GetMetricsFileDirectory ( ) const

Get the directory of the local metrics file.

Returns
Directory of the local metrics file.

◆ GetMetricsFilePath()

const char* AWSMetrics::MetricsManager::GetMetricsFilePath ( ) const

Get the path to the local metrics file.

Returns
Path to the local metrics file.

◆ GetNumBufferedMetrics()

AZ::s64 AWSMetrics::MetricsManager::GetNumBufferedMetrics ( )

Get the total number of metrics buffered in the metrics queue.

Returns
the number of buffered metrics

◆ GetNumTotalRequests()

int AWSMetrics::MetricsManager::GetNumTotalRequests ( ) const

Get the total number of requests for sending metrics events. This value could be different to the number of submitted metrics events since metrics events could be sent in batch.

Returns
Total number of requests for sending metrics events.

◆ Init()

bool AWSMetrics::MetricsManager::Init ( )

Initializing the metrics manager

Returns
Whether the operation is successful.

◆ OnResponseReceived()

void AWSMetrics::MetricsManager::OnResponseReceived ( const MetricsQueue metricsEventsInRequest,
const ServiceAPI::PostMetricsEventsResponseEntries &  responseEntries = ServiceAPI::PostMetricsEventsResponseEntries() 
)

Update the global stats and add qualified failed metrics events back to the buffer for retry.

Parameters
metricsEventsInRequestMetrics events in the original request.
responseEntriesResponse list for all the processed metrics events.

◆ SendMetricsAsync()

bool AWSMetrics::MetricsManager::SendMetricsAsync ( const AZStd::vector< MetricsAttribute > &  metricsAttributes = AZStd::vector< MetricsAttribute >(),
int  eventPriority = 0,
const AZStd::string &  eventSourceOverride = "" 
)

Implementation for sending metrics asynchronously.

Parameters
metricsAttributesAttributes of the metrics.
eventSourceOverrideEvent source used to override the default value.
eventPriorityPriority of the event. Default to 0 which is considered as the highest priority.
Returns
Whether the request is sent successfully.

◆ SendMetricsToFile()

virtual AZ::Outcome<void, AZStd::string> AWSMetrics::MetricsManager::SendMetricsToFile ( AZStd::shared_ptr< MetricsQueue metricsQueue)
protectedvirtual

Send metrics to a local file.

Parameters
metricsQueuemetricsQueue Metrics queue that stores the metrics.
Returns
Outcome of the operation.

◆ SubmitMetrics()

bool AWSMetrics::MetricsManager::SubmitMetrics ( const AZStd::vector< MetricsAttribute > &  metricsAttributes = AZStd::vector< MetricsAttribute >(),
int  eventPriority = 0,
const AZStd::string &  eventSourceOverride = "" 
)

Implementation for submitting metrics. Metrics will be buffered before sending in batch.

Parameters
metricsAttributesAttributes of the metrics.
eventPriorityPriority of the event. Default to 0 which is considered as the highest priority.
eventSourceOverrideEvent source used to override the default value.
Returns
Whether the submission is successful.

◆ UpdateOfflineRecordingStatus()

void AWSMetrics::MetricsManager::UpdateOfflineRecordingStatus ( bool  enable,
bool  submitLocalMetrics = false 
)

Enable/Disable the offline recording and resubmit metrics stored in the local metrics file if the client switches to the online mode.

Parameters
enableWhether to enable the offline recording.
submitLocalMetricsWhether to resubmit local metrics if exist.

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