stellarsecurity/application-insights-laravel
Composer 安装命令:
composer require stellarsecurity/application-insights-laravel
包简介
Stellar Security - Application Insights style telemetry for Laravel (HTTP, DB, jobs, mail, dependencies).
README 文档
README
A lightweight Laravel package that sends telemetry to Azure Application Insights (requests, exceptions, and custom events).
Built by https://stellarsecurity.com
This package is designed to be safe by default:
- Telemetry must never break your application
- Queue sending is disabled by default to avoid silent data loss
- Connection String is the preferred configuration (modern App Insights)
Requirements
- PHP >= 8.1
- Laravel 10+ (also compatible with Laravel 11/12 when using matching illuminate components)
- Guzzle 7.x
Installation
composer require stellarsecurity/application-insights-laravel
Configuration
Publish the config (if your package provides a publish command). If not, create config/stellar-ai.php in your app.
Recommended: Connection String
Set one of the following in your .env:
APPLICATIONINSIGHTS_CONNECTION_STRING=InstrumentationKey=xxxx;IngestionEndpoint=https://westeurope-0.in.applicationinsights.azure.com/
You may also use the package-specific key:
STELLAR_AI_CONNECTION_STRING=InstrumentationKey=xxxx;IngestionEndpoint=https://westeurope-0.in.applicationinsights.azure.com/
Fallback: Instrumentation Key only
STELLAR_AI_INSTRUMENTATION_KEY=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Example config (config/stellar-ai.php)
<?php return [ /* |-------------------------------------------------------------------------- | Application Insights configuration |-------------------------------------------------------------------------- | | Prefer connection string. Fallback to instrumentation key if needed. | */ 'connection_string' => env( 'STELLAR_AI_CONNECTION_STRING', env('APPLICATIONINSIGHTS_CONNECTION_STRING', '') ), 'instrumentation_key' => env( 'STELLAR_AI_INSTRUMENTATION_KEY', env('APPINSIGHTS_INSTRUMENTATIONKEY', '') ), /* |-------------------------------------------------------------------------- | Telemetry behavior |-------------------------------------------------------------------------- */ // Queue is disabled by default to avoid silent data loss when workers are not running. 'use_queue' => env('STELLAR_AI_USE_QUEUE', false), // Buffer limit before flush (helps reduce HTTP calls). 'buffer_limit' => (int) env('STELLAR_AI_BUFFER_LIMIT', 10), // Flush telemetry automatically at the end of the request lifecycle. 'auto_flush' => env('STELLAR_AI_AUTO_FLUSH', true), // Application role name shown in Azure. 'role_name' => env('STELLAR_AI_ROLE_NAME', env('APP_NAME', 'stellar-app')), ];
Queue mode (optional)
By default, telemetry is sent directly (HTTP) to avoid losing data if no workers are running.
If you want to use queues:
STELLAR_AI_USE_QUEUE=true
Then ensure a worker is running in production:
php artisan queue:work
If you enable queue mode without a running worker, telemetry will be delayed (and may appear missing).
What is tracked
Depending on your middleware/service wiring, the package can track:
- HTTP requests
- Exceptions
- Custom events (EventData)
- Dependencies (if you emit dependency telemetry)
Viewing data in Azure
In Azure Portal → Application Insights → Logs (Analytics), run:
union requests, traces, exceptions | order by timestamp desc
If you only want requests:
requests | order by timestamp desc
Common troubleshooting
I see no data at all
- Confirm your app is using the correct Application Insights resource.
- Confirm a valid instrumentation key is resolved.
- If using a connection string, it must include
InstrumentationKey=...
- If using a connection string, it must include
- If queue mode is enabled, confirm workers are running.
- Clear and rebuild config cache after changing
.env:
php artisan config:clear php artisan config:cache
Azure “Search” looks empty, but Logs has data
This is usually a UI filtering issue. Use Logs (Analytics) queries to confirm ingestion.
License
MIT
stellarsecurity/application-insights-laravel 适用场景与选型建议
stellarsecurity/application-insights-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 505 次下载、GitHub Stars 达 2, 最近一次更新时间为 2025 年 11 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 stellarsecurity/application-insights-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 stellarsecurity/application-insights-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 505
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 28
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-28