Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not log requests to the health endpoint #1897

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this
* [#1835](/~https://github.com/shlinkio/shlink/issues/1835) Docker image is now built only when a release is tagged, and new tags are included, for minor and major versions.
* [#1055](/~https://github.com/shlinkio/shlink/issues/1055) Update OAS definition to v3.1.
* [#1885](/~https://github.com/shlinkio/shlink/issues/1885) Update to chronos 3.0.
* [#1896](/~https://github.com/shlinkio/shlink/issues/1896) Requests to health endpoint are no longer logged.

### Deprecated
* [#1783](/~https://github.com/shlinkio/shlink/issues/1783) Deprecated support for openswoole. RoadRunner is the best replacement, with the same capabilities, but much easier and convenient to install and manage.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"php-middleware/request-id": "^4.1",
"pugx/shortid-php": "^1.1",
"ramsey/uuid": "^4.7",
"shlinkio/shlink-common": "dev-main#8253378 as 5.7",
"shlinkio/shlink-common": "dev-main#4e859a7 as 5.7",
"shlinkio/shlink-config": "dev-main#c0aa01f as 2.5",
"shlinkio/shlink-event-dispatcher": "dev-main#bd3a62b as 3.1",
"shlinkio/shlink-importer": "^5.1",
Expand Down
1 change: 0 additions & 1 deletion module/Core/config/dependencies.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Psr\EventDispatcher\EventDispatcherInterface;
use Shlinkio\Shlink\Common\Doctrine\EntityRepositoryFactory;
use Shlinkio\Shlink\Config\Factory\ValinorConfigFactory;
use Shlinkio\Shlink\Core\ErrorHandler;
use Shlinkio\Shlink\Core\Options\NotFoundRedirectOptions;
use Shlinkio\Shlink\Importer\ImportedLinksProcessorInterface;
use Shlinkio\Shlink\IpGeolocation\Resolver\IpLocationResolverInterface;
Expand Down
2 changes: 1 addition & 1 deletion module/Core/src/Model/DeviceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ enum DeviceType: string

public static function matchFromUserAgent(string $userAgent): ?self
{
$detect = new MobileDetect(userAgent: $userAgent); // @phpstan-ignore-line
$detect = new MobileDetect(userAgent: $userAgent);

return match (true) {
// $detect->is('iOS') && $detect->isTablet() => self::IOS, // TODO To detect iPad only
Expand Down
27 changes: 27 additions & 0 deletions module/Rest/config/access-logs.config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace Shlinkio\Shlink\Rest;

use Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory;
use Laminas\Stdlib\ArrayUtils\MergeReplaceKey;
use Shlinkio\Shlink\Common\Middleware\AccessLogMiddleware;

return [

'access_logs' => [
'ignored_paths' => [
Action\HealthAction::ROUTE_PATH,
],
],

// This config needs to go in this file in order to override the value defined in shlink-common
ConfigAbstractFactory::class => [
// Use MergeReplaceKey to overwrite what was defined in shlink-common, instead of merging it
AccessLogMiddleware::class => new MergeReplaceKey(
[AccessLogMiddleware::LOGGER_SERVICE_NAME, 'config.access_logs.ignored_paths'],
),
],

];
2 changes: 1 addition & 1 deletion module/Rest/src/Action/HealthAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class HealthAction extends AbstractRestAction
private const STATUS_PASS = 'pass';
private const STATUS_FAIL = 'fail';

protected const ROUTE_PATH = '/health';
public const ROUTE_PATH = '/health';
protected const ROUTE_ALLOWED_METHODS = [self::METHOD_GET];

public function __construct(private EntityManagerInterface $em, private AppOptions $options)
Expand Down
3 changes: 2 additions & 1 deletion module/Rest/test/ConfigProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ public function properConfigIsReturned(): void
{
$config = ($this->configProvider)();

self::assertCount(4, $config);
self::assertCount(5, $config);
self::assertArrayHasKey('dependencies', $config);
self::assertArrayHasKey('auth', $config);
self::assertArrayHasKey('entity_manager', $config);
self::assertArrayHasKey('access_logs', $config);
self::assertArrayHasKey(ConfigAbstractFactory::class, $config);
}

Expand Down
Loading