AWSMetricsSystemComponent.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AWSMetricsBus.h>
  10. #include <AzCore/Component/Component.h>
  11. #include <AzCore/Console/IConsole.h>
  12. #include <AzCore/std/smart_ptr/unique_ptr.h>
  13. namespace AWSMetrics
  14. {
  15. class MetricsManager;
  16. //! Gem System Component. Responsible for instantiating and managing the Metrics Manager
  17. class AWSMetricsSystemComponent
  18. : public AZ::Component
  19. , protected AWSMetricsRequestBus::Handler
  20. {
  21. public:
  22. AZ_COMPONENT(AWSMetricsSystemComponent, "{D6252A35-6A8E-4E8B-BFC6-FCBE80E5A626}");
  23. AWSMetricsSystemComponent();
  24. ~AWSMetricsSystemComponent();
  25. static void Reflect(AZ::ReflectContext* context);
  26. static void ReflectMetricsAttribute(AZ::ReflectContext* reflection);
  27. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  28. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  29. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  30. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
  31. protected:
  32. ////////////////////////////////////////////////////////////////////////
  33. // AWSMetricsRequestBus interface implementation
  34. bool SubmitMetrics(const AZStd::vector<MetricsAttribute>& metricsAttributes, int eventPriority = 0,
  35. const AZStd::string& eventSourceOverride = "", bool bufferMetrics = true) override;
  36. void FlushMetrics() override;
  37. ////////////////////////////////////////////////////////////////////////
  38. ////////////////////////////////////////////////////////////////////////
  39. // AZ::Component interface implementation
  40. void Init() override;
  41. void Activate() override;
  42. void Deactivate() override;
  43. ////////////////////////////////////////////////////////////////////////
  44. using Attributes = AZStd::vector<MetricsAttribute>;
  45. struct AttributeSubmissionList
  46. {
  47. AZ_TYPE_INFO(AttributeSubmissionList, "{B1106C14-D22B-482F-B33E-B6E154A53798}");
  48. static void Reflect(AZ::ReflectContext* reflection);
  49. Attributes attributes;
  50. };
  51. private:
  52. AZ_CONSOLEFUNC(AWSMetricsSystemComponent, DumpStats, AZ::ConsoleFunctorFlags::Null, "Dumps stats for sending metrics");
  53. AZ_CONSOLEFUNC(
  54. AWSMetricsSystemComponent, EnableOfflineRecording, AZ::ConsoleFunctorFlags::Null, "Enable/disable the offline recording");
  55. //! Console commands.
  56. void DumpStats(const AZ::ConsoleCommandContainer& arguments);
  57. void EnableOfflineRecording(const AZ::ConsoleCommandContainer& arguments);
  58. AZStd::unique_ptr<MetricsManager> m_metricsManager; //!< Pointer to the metrics manager which handles the metrics submission
  59. };
  60. } // namespace AWSMetrics