macpaw/symfony-otel-bundle
Composer 安装命令:
composer require macpaw/symfony-otel-bundle
包简介
README 文档
README
A comprehensive OpenTelemetry integration bundle for Symfony applications that provides automatic instrumentation, custom span creation, and distributed tracing capabilities.
Features
- Automatic Instrumentation - Built-in instrumentations for HTTP requests, database operations, and more
- Custom Instrumentations - Easy-to-use framework for creating custom instrumentations
- Middleware System - Extensible middleware system for span customization
- Exception Handling - Automatic span cleanup and error recording
- Docker Support - Complete development environment with Tempo and Grafana
- Performance Optimized - Support for both HTTP and gRPC transport protocols
- OpenTelemetry Compliant - Follows OpenTelemetry specifications and semantic conventions
Quick Overview
This bundle provides a configured OpenTelemetry integration for Symfony applications, offering:
- Automatic telemetry collection via kernel event listeners
- Custom instrumentation framework for business logic
- Built-in support for distributed tracing
- Complete testing and development environment
Bundle Overview
This bundle is a wrapper around the official OpenTelemetry PHP SDK bundle that simplifies integration and provides additional instrumentation capabilities for Symfony applications.
Key characteristics:
- Transport-agnostic - Uses standard OpenTelemetry SDK environment variables for transport configuration
- Framework-focused - Provides Symfony-specific instrumentation and middleware
- Extensible - Easy to add custom instrumentations and span processors
Built-in Features
- Request Execution Time Tracking - Automatic HTTP request timing
- Exception Handling - Automatic span cleanup and error recording
- Custom Instrumentations - Framework for creating custom telemetry collection
For detailed instrumentation guide, see Instrumentation Guide.
Environment Variables
The bundle supports all standard OpenTelemetry SDK environment variables. For complete configuration reference, see Configuration Guide.
Essential variables:
OTEL_SERVICE_NAME- Your service nameOTEL_TRACER_NAME- Tracer nameOTEL_EXPORTER_OTLP_ENDPOINT- Collector endpointOTEL_EXPORTER_OTLP_PROTOCOL- Transport protocol (grpc/http/protobuf)
Transport Configuration
Important: This bundle is transport-agnostic - it doesn't handle transport configuration directly. All transport settings are managed through standard OpenTelemetry SDK environment variables.
Recommended for production:
# Install gRPC support composer require open-telemetry/transport-grpc pecl install grpc # may take a time to compile - 30-40 minutes # Configure gRPC endpoint OTEL_EXPORTER_OTLP_ENDPOINT=http://collector:4317 OTEL_EXPORTER_OTLP_PROTOCOL=grpc
Default HTTP endpoint: http://collector:4318
Transport protocols supported:
grpc- High performance, recommended for productionhttp/protobuf- Standard HTTP with protobuf encodinghttp/json- HTTP with JSON encoding (slower)
Note: Our bundle supports all transport protocols supported by the OpenTelemetry PHP SDK since we don't decorate the transport layer. For complete transport configuration options, see the official OpenTelemetry PHP Exporters documentation.
For detailed Docker setup and development environment configuration, see Docker Development Guide.
Documentation
-
Installation Guide - Complete installation and setup instructions
-
Configuration Reference - Bundle configuration and environment variables
-
Instrumentation Guide - Built-in instrumentations and custom development
-
Docker Development - Local development environment setup
-
Testing Guide - Testing, trace visualization, and troubleshooting
-
OpenTelemetry Basics - OpenTelemetry concepts and fundamentals
-
Contributing Guide - How to contribute to the project
Quick Start
-
Install the bundle:
composer require macpaw/symfony-otel-bundle
-
Enable in your application:
// config/bundles.php return [ Macpaw\SymfonyOtelBundle\SymfonyOtelBundle::class => ['all' => true], ];
-
Configure environment variables:
OTEL_SERVICE_NAME=your-service-name OTEL_TRACER_NAME=your-tracer-name OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
-
Start testing:
make up open http://localhost:8080
Usage
For detailed usage instructions, see Testing Guide.
macpaw/symfony-otel-bundle 适用场景与选型建议
macpaw/symfony-otel-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 63 次下载、GitHub Stars 达 9, 最近一次更新时间为 2025 年 07 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 macpaw/symfony-otel-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 macpaw/symfony-otel-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 63
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-31