承接 openconext/monitor-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

openconext/monitor-bundle

Composer 安装命令:

composer require openconext/monitor-bundle

包简介

A Symfony 6/7 bundle that facilitates health and info endpoints to a Symfony application.

README 文档

README

Code_Checks

A Symfony 5/6/7 bundle that adds an /internal/health and /internal/info endpoint to your application.

The endpoints return JSON responses. The /internal/info endpoint tries to give as much information about the currently installed version of the application as possible. This information is based on the build path of the installation. But also includes the Symfony environment that is currently active and whether the debugger is enabled.

The /internal/health endpoint reports on the health of the application. This information could be used for example by a load balancer. Example output:

{"status":"UP"}

When a health check failed the HTTP Response status code will be 503. And the JSON Response is formatted like this:

{"status":"DOWN", "message":"Lorem ipsum dolor sit"}

❗ Please note that only the first failing health check is reported.

❗ As of version 3.1.0 we started exposing the health and info routes on /internal/. On the next major version we will stop serving the info and health endpoints on /

Installation

  • Add the package to your Composer file

    composer require openconext/monitor-bundle
  • If you don't use Symfony Flex, you must enable the bundle manually in the application:

    // config/bundles.php
    // in older Symfony apps, enable the bundle in config/bundles.php
    return [
    // ...
     OpenConext\MonitorBundle\OpenConextMonitorBundle::class => ['all' => true],
    ];
  • Include the routing configuration in config/routes.yaml by adding:

    open_conext_monitor:
        resource: "@OpenConextMonitorBundle/src/Controller"
        type: attribute
        prefix: /

Note: this is currently done by the bundle itself, with an external dependency called https://github.com/endroid/installer

  • Add security exceptions in config/packages/security.yaml (if this is required at all)
    security:
        firewalls:
            monitor:
                pattern: ^/internal/(info|health)$
                security: false
    
  • The /internal/info and /internal/health endpoints should now be available for everybody. Applying custom access restriction is up to the implementer of this bundle.

Adding Health Checks

The Monitor ships with two health checks. These checks are a

  • Database connection check based on Doctrine configuration
  • Session status check

Create the checker

A HealthCheckInterface can be implemented to create your own health check. The example below shows an example of what an implementation of said interface could look like.

use OpenConext\MonitorBundle\HealthCheck\HealthCheckInterface;
use OpenConext\MonitorBundle\HealthCheck\HealthReportInterface;
use OpenConext\MonitorBundle\Value\HealthReport;

class ApiHealthCheck implements HealthCheckInterface
{
    public function __construct(private readonly MyService $service)
    {
    }

    public function check(HealthReportInterface $report): HealthReportInterface
    {
        if (!$this->service->everythingOk()) {
            // Return a HealthReport with a DOWN status when there are indications the application is not functioning as
            // intended. You can provide an optional message that is displayed alongside the DOWN status.
            return HealthReport::buildStatusDown('Not everything is allright.');
        }
        // By default, return the report that was passed along as a parameter to the check method
        return $report;
    }
}

❗ Please note that the check method receives and returns a HealthReport. The Health report is passed along in the chain of registered health checkers. If everything was OK, just return the report that was passed to the method.

Register the checker

By implementing the HealthCheckInterface you can register your own health check. This interface is tagged automatically, so you don't have to do it yourself.

Overriding a default HealthCheck

To run a custom query with the DoctrineConnectionHealthCheck you will need to override it in your own project.

For example in your ACME bundle that is using the monitor bundle:

services.yaml

    # Override the service in `/src/config/services.yaml`
    OpenConext\MonitorBundle\HealthCheck\DoctrineConnectionHealthCheck:
        # Point to your own implementation of the check
        class: Acme\GreatSuccessBundle\HealthCheck\DoctrineConnectionHealthCheck

The rest of the service configuration is up to your own needs. You can inject arguments, factory calls and other service features as need be.

Release strategy

Please read: https://github.com/OpenConext/Stepup-Deploy/wiki/Release-Management for more information on the release strategy used in Stepup projects.

openconext/monitor-bundle 适用场景与选型建议

openconext/monitor-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 80.93k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2017 年 12 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「monitoring」 「health」 「surfnet」 「stepup」 「OpenConext」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 openconext/monitor-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 openconext/monitor-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 openconext/monitor-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 80.93k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 31
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 12
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2017-12-07