Integrating latest 47acbe8

This commit is contained in:
alexpete
2021-03-25 13:57:57 -07:00
parent 448c549698
commit 75dc720198
10312 changed files with 2711566 additions and 671451 deletions
@@ -0,0 +1,35 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#ifndef TELEMETRY_TELEMETRYBUS_H
#define TELEMETRY_TELEMETRYBUS_H
#include <AzCore/EBus/EBus.h>
#include "Source/Telemetry/TelemetryEvent.h"
namespace Telemetry
{
class TelemetryComponent;
class TelemetryEvents
: public AZ::EBusTraits
{
public:
virtual void Initialize(const char* applicationName, AZ::u32 processIntervalInSecs, bool doSDKInitShutdown) = 0;
virtual void LogEvent(const TelemetryEvent& event) = 0;
virtual void Shutdown() = 0;
};
typedef AZ::EBus<TelemetryEvents> TelemetryEventsBus;
}
#endif
@@ -0,0 +1,52 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "StandaloneTools_precompiled.h"
#include "TelemetryComponent.h"
namespace Telemetry
{
void TelemetryComponent::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context);
if (serialize)
{
serialize->Class<TelemetryComponent, AZ::Component>()
->Version(1)
;
}
}
void TelemetryComponent::Activate()
{
TelemetryEventsBus::Handler::BusConnect();
}
void TelemetryComponent::Deactivate()
{
Shutdown();
TelemetryEventsBus::Handler::BusDisconnect();
}
void TelemetryComponent::Initialize([[maybe_unused]] const char* applicationName, [[maybe_unused]] AZ::u32 processInterval, [[maybe_unused]] bool doAPIInitShutdown)
{
}
void TelemetryComponent::LogEvent([[maybe_unused]] const TelemetryEvent& telemetryEvent)
{
}
void TelemetryComponent::Shutdown()
{
}
}
@@ -0,0 +1,45 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/Component/Component.h>
#include <AzCore/std/chrono/chrono.h>
#include "TelemetryBus.h"
namespace Telemetry
{
class TelemetryComponent
: public AZ::Component
, public TelemetryEventsBus::Handler
{
public:
AZ_COMPONENT(TelemetryComponent, "{CE41EE3C-AF98-4B22-BA7C-2D425D1F468A}")
TelemetryComponent() = default;
//////////////////
// AZ::Component
void Activate();
void Deactivate();
static void Reflect(AZ::ReflectContext* context);
//////////////////
//////////////////////////////////////////
// Telemetry::TelemetryEventBus::Handler
void Initialize(const char* applicationName, AZ::u32 processIntervalInSeconds, bool doSDKInitShutdown) override;
void LogEvent(const TelemetryEvent& event) override;
void Shutdown() override;
//////////////////////////////////////////
};
}
@@ -0,0 +1,86 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "StandaloneTools_precompiled.h"
#include "TelemetryEvent.h"
#include "TelemetryBus.h"
namespace Telemetry
{
TelemetryEvent::TelemetryEvent(const char* eventName)
: m_eventName(eventName)
{
}
void TelemetryEvent::SetAttribute(const AZStd::string& name, const AZStd::string& value)
{
m_attributes[name] = value;
}
const AZStd::string& TelemetryEvent::GetAttribute(const AZStd::string& name)
{
static AZStd::string k_emptyString;
AZStd::unordered_map< AZStd::string, AZStd::string >::iterator attributeIter = m_attributes.find(name);
if (attributeIter != m_attributes.end())
{
return attributeIter->second;
}
return k_emptyString;
}
void TelemetryEvent::SetMetric(const AZStd::string& name, double metric)
{
m_metrics[name] = metric;
}
double TelemetryEvent::GetMetric(const AZStd::string& name)
{
AZStd::unordered_map< AZStd::string, double >::iterator metricIter = m_metrics.find(name);
if (metricIter != m_metrics.end())
{
return metricIter->second;
}
return 0.0;
}
void TelemetryEvent::Log()
{
EBUS_EVENT(TelemetryEventsBus, LogEvent, (*this));
}
void TelemetryEvent::ResetEvent()
{
m_metrics.clear();
m_attributes.clear();
}
const char* TelemetryEvent::GetEventName() const
{
return m_eventName.c_str();
}
const TelemetryEvent::AttributesMap& TelemetryEvent::GetAttributes() const
{
return m_attributes;
}
const TelemetryEvent::MetricsMap& TelemetryEvent::GetMetrics() const
{
return m_metrics;
}
}
@@ -0,0 +1,49 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#ifndef TELEMETRY_TELEMETRYEVENT_H
#define TELEMETRY_TELEMETRYEVENT_H
#include <AzCore/std/containers/unordered_map.h>
#include <AzCore/std/string/string.h>
namespace Telemetry
{
class TelemetryEvent
{
public:
typedef AZStd::unordered_map< AZStd::string, AZStd::string > AttributesMap;
typedef AZStd::unordered_map< AZStd::string, double > MetricsMap;
TelemetryEvent(const char* eventName);
void SetAttribute(const AZStd::string& name, const AZStd::string& value);
const AZStd::string& GetAttribute(const AZStd::string& name);
void SetMetric(const AZStd::string& name, double metric);
double GetMetric(const AZStd::string& name);
void Log();
void ResetEvent();
const char* GetEventName() const;
const AttributesMap& GetAttributes() const;
const MetricsMap& GetMetrics() const;
private:
AZStd::string m_eventName;
AttributesMap m_attributes;
MetricsMap m_metrics;
};
}
#endif