NewRelicWrapper.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\NewRelicReporting\Model;
  7. /**
  8. * Wrapper for New Relic functions
  9. *
  10. * @codeCoverageIgnore
  11. */
  12. class NewRelicWrapper
  13. {
  14. /**
  15. * Wrapper for 'newrelic_add_custom_parameter' function
  16. *
  17. * @param string $param
  18. * @param string|int $value
  19. * @return bool
  20. */
  21. public function addCustomParameter($param, $value)
  22. {
  23. if (extension_loaded('newrelic')) {
  24. newrelic_add_custom_parameter($param, $value);
  25. return true;
  26. }
  27. return false;
  28. }
  29. /**
  30. * Wrapper for 'newrelic_notice_error' function
  31. *
  32. * @param \Exception $exception
  33. * @return void
  34. */
  35. public function reportError($exception)
  36. {
  37. if (extension_loaded('newrelic')) {
  38. newrelic_notice_error($exception->getMessage(), $exception);
  39. }
  40. }
  41. /**
  42. * Wrapper for 'newrelic_set_appname'
  43. *
  44. * @param string $appName
  45. * @return void
  46. */
  47. public function setAppName(string $appName)
  48. {
  49. if (extension_loaded('newrelic')) {
  50. newrelic_set_appname($appName);
  51. }
  52. }
  53. /**
  54. * Checks whether newrelic-php5 agent is installed
  55. *
  56. * @return bool
  57. */
  58. public function isExtensionInstalled()
  59. {
  60. if (extension_loaded('newrelic')) {
  61. return true;
  62. }
  63. return false;
  64. }
  65. }