telexorg/telex-apm 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

telexorg/telex-apm

Composer 安装命令:

composer require telexorg/telex-apm

包简介

A simple APM package for Laravel.

README 文档

README

# Telex APM

**Telex APM** is a simple, installable Laravel package designed to monitor and collect application performance metrics. The package collects data on each backend request and sends these metrics to a specified webhook URL. The package is intended to be easily integrated into any Laravel application.

## Features

- Middleware to collect backend metrics for each request.
- Send collected metrics to a configurable webhook URL.
- Easy installation via Composer.
- Configurable via Laravel's standard configuration file system.

## Requirements

- PHP 7.4 or higher
- Laravel 8.x or higher
- `pdo_sqlite` (if using SQLite for testing purposes)

## Installation

To install the package in your Laravel project, follow these steps:

### 1. Install via Composer

Run the following command in your Laravel project root directory:

```bash
composer require telexorg/telex-apm

2. Publish the Configuration

After installing the package, you need to publish the configuration file:

php artisan vendor:publish --tag=config

This will create a config/apm.php file where you can configure the webhook URL.

3. Configure the Webhook URL

Open the config/apm.php file and set your webhook URL:

return [
    'webhook_url' => 'https://example.com/your-default-webhook-endpoint', // Replace with your actual URL
    '404_errors' => 'https://example.com/your-404-errors-webhook-endpoint', // Replace with your actual URL
    '500_errors' => 'https://example.com/your-500-errors-webhook-endpoint', // Replace with your actual URL
    'app_name' => 'your_app_name', // Replace with your actual app_name
];

Usage

Once installed, paste this code in App/Exceptions/Handler.php in your laravel app,

public function report(Throwable $exception){   
    app('laravel_telex_apm')->handle($exception);
}

This authomatically tracks all errors in your laravel app.

Collected Metrics

The following metrics are collected for each request:

  • HTTP Method (GET, POST, etc.)
  • Request URL
  • Response Status Code
  • Request Duration
  • Request Headers
  • Timestamp
  • Stack Trace
  • Request Message

Testing

To ensure the package is working correctly, you can run your Laravel project in development mode and make a few requests. The metrics collected should be sent to the configured webhook URL.

If you're encountering any errors, you can check Laravel's log files located in storage/logs/laravel.log.

Development

If you want to contribute to the package or modify it:

1. Clone the Repository

Clone the package repository locally:

git clone https://github.com/yourusername/telex-apm.git
cd telex-apm

2. Install Dependencies

Install dependencies using Composer:

composer install

3. Run Tests

You can run tests to ensure everything is working:

vendor/bin/phpunit

Deployment

To make the package public on Packagist, follow these steps:

  1. Ensure you have a Packagist account.
  2. Log in to Packagist and submit your package's repository URL.
  3. Use composer.json to maintain the package metadata.

Contributing

If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are warmly welcome.

Issues

If you encounter any issues, please feel free to open an issue on GitHub.

License

This package is open-source software licensed under the MIT license.

Contact

For more information or support, please reach out to:


### Replace Placeholders
- Replace `"https://github.com/yourusername/telex-apm.git"` with the actual URL of your GitHub repository.
- Update `youremail@example.com` and other placeholder URLs with actual contact information.
- Update the Packagist URL once your package is published.

This `README.md` provides a clear guide for users to install, configure, and use your package, along with instructions for contributing and development. Let me know if you need any additional details or sections!

统计信息

  • 总下载量: 55
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 6
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-11-15