1
0

IProfiler.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright 2022 Carl Schwan <carl@carlschwan.eu>
  5. *
  6. * @author Carl Schwan <carl@carlschwan.eu>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OCP\Profiler;
  25. use OC\AppFramework\Http\Request;
  26. use OCP\AppFramework\Http\Response;
  27. use OCP\DataCollector\IDataCollector;
  28. /**
  29. * This interface allows to interact with the built-in Nextcloud profiler.
  30. * @since 24.0.0
  31. */
  32. interface IProfiler {
  33. /**
  34. * Add a new data collector to the profiler. This allows to later on
  35. * collect all the data from every registered collector.
  36. *
  37. * @see IDataCollector
  38. * @since 24.0.0
  39. */
  40. public function add(IDataCollector $dataCollector): void;
  41. /**
  42. * Load a profile from a response object
  43. * @since 24.0.0
  44. */
  45. public function loadProfileFromResponse(Response $response): ?IProfile;
  46. /**
  47. * Load a profile from the response token
  48. * @since 24.0.0
  49. */
  50. public function loadProfile(string $token): ?IProfile;
  51. /**
  52. * Save a profile on the disk. This allows to later load it again in the
  53. * profiler user interface.
  54. * @since 24.0.0
  55. */
  56. public function saveProfile(IProfile $profile): bool;
  57. /**
  58. * Find a profile from various search parameters
  59. * @since 24.0.0
  60. */
  61. public function find(?string $url, ?int $limit, ?string $method, ?int $start, ?int $end, string $statusCode = null): array;
  62. /**
  63. * Get the list of data providers by identifier
  64. * @return string[]
  65. * @since 24.0.0
  66. */
  67. public function dataProviders(): array;
  68. /**
  69. * Check if the profiler is enabled.
  70. *
  71. * If it is not enabled, data provider shouldn't be created and
  72. * shouldn't collect any data.
  73. * @since 24.0.0
  74. */
  75. public function isEnabled(): bool;
  76. /**
  77. * Set if the profiler is enabled.
  78. * @see isEnabled
  79. * @since 24.0.0
  80. */
  81. public function setEnabled(bool $enabled): void;
  82. /**
  83. * Collect all the information from the current request and construct
  84. * a IProfile from it.
  85. * @since 24.0.0
  86. */
  87. public function collect(Request $request, Response $response): IProfile;
  88. /**
  89. * Clear the stored profiles
  90. * @since 25.0.0
  91. */
  92. public function clear(): void;
  93. }