1
0

IProfiler.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\Profiler;
  8. use OC\AppFramework\Http\Request;
  9. use OCP\AppFramework\Http\Response;
  10. use OCP\DataCollector\IDataCollector;
  11. /**
  12. * This interface allows to interact with the built-in Nextcloud profiler.
  13. * @since 24.0.0
  14. */
  15. interface IProfiler {
  16. /**
  17. * Add a new data collector to the profiler. This allows to later on
  18. * collect all the data from every registered collector.
  19. *
  20. * @see IDataCollector
  21. * @since 24.0.0
  22. */
  23. public function add(IDataCollector $dataCollector): void;
  24. /**
  25. * Load a profile from a response object
  26. * @since 24.0.0
  27. */
  28. public function loadProfileFromResponse(Response $response): ?IProfile;
  29. /**
  30. * Load a profile from the response token
  31. * @since 24.0.0
  32. */
  33. public function loadProfile(string $token): ?IProfile;
  34. /**
  35. * Save a profile on the disk. This allows to later load it again in the
  36. * profiler user interface.
  37. * @since 24.0.0
  38. */
  39. public function saveProfile(IProfile $profile): bool;
  40. /**
  41. * Find a profile from various search parameters
  42. * @since 24.0.0
  43. */
  44. public function find(?string $url, ?int $limit, ?string $method, ?int $start, ?int $end, ?string $statusCode = null): array;
  45. /**
  46. * Get the list of data providers by identifier
  47. * @return string[]
  48. * @since 24.0.0
  49. */
  50. public function dataProviders(): array;
  51. /**
  52. * Check if the profiler is enabled.
  53. *
  54. * If it is not enabled, data provider shouldn't be created and
  55. * shouldn't collect any data.
  56. * @since 24.0.0
  57. */
  58. public function isEnabled(): bool;
  59. /**
  60. * Set if the profiler is enabled.
  61. * @see isEnabled
  62. * @since 24.0.0
  63. */
  64. public function setEnabled(bool $enabled): void;
  65. /**
  66. * Collect all the information from the current request and construct
  67. * a IProfile from it.
  68. * @since 24.0.0
  69. */
  70. public function collect(Request $request, Response $response): IProfile;
  71. /**
  72. * Clear the stored profiles
  73. * @since 25.0.0
  74. */
  75. public function clear(): void;
  76. }