Skip to content

Conversation

aliibii
Copy link

@aliibii aliibii commented Oct 16, 2025

Description

This commit adds plugin execution tracing capability to the OpenTelemetry plugin, allowing users to trace individual plugin phases (rewrite, access, header_filter, body_filter, log) as child spans of the main request trace.

Changes:

  • Added trace_plugins configuration option (default: false, opt-in behaviour)
  • Added plugin_span_kind configuration for observability provider compatibility (default: internal)
  • Enhanced plugin execution with OpenTelemetry span creation and finishing
  • Added request context attributes to plugin spans
  • Updated documentation with examples and usage instructions
  • Added test suite for the new functionality

Features:

  • Plugin Phase Tracing: Creates child spans for each plugin phase execution
  • Span Kind Control: Supports internal (default) and server span kinds for observability provider compatibility
  • Rich Context: Includes HTTP method, URI, hostname, user agent, route info, and service info
  • Configurable: Can be enabled/disabled via trace_plugins configuration
  • Proper Hierarchy: Plugin spans are correctly nested under main request spans
  • Error Handling: Proper error status and message propagation

Which issue(s) this PR fixes:

Resolves #12510

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@aliibii aliibii force-pushed the feat/opentelemetry-plugin-tracing branch from e920d53 to f456f22 Compare October 17, 2025 09:58
This commit adds plugin execution tracing capability to the OpenTelemetry plugin,
allowing users to trace individual plugin phases (rewrite, access, header_filter,
body_filter, log) as child spans of the main request trace.

Changes:
- Added trace_plugins configuration option (default: false, opt-in)
- Added plugin_span_kind configuration for observability provider compatibility
- Enhanced plugin execution with OpenTelemetry span creation and finishing
- Added comprehensive request context attributes to plugin spans
- Updated documentation with examples and usage instructions
- Added comprehensive test suite for the new functionality

Features:
- Plugin Phase Tracing: Creates child spans for each plugin phase execution
- Rich Context: Includes HTTP method, URI, hostname, user agent, route info, and service info
- Configurable: Can be enabled/disabled via trace_plugins configuration
- Span Kind Control: Supports internal (default) and server span kinds for observability provider compatibility
- Proper Hierarchy: Plugin spans are correctly nested under main request spans
- Performance: Minimal overhead when disabled (default behavior)

Configuration:
- trace_plugins: boolean (default: false) - Enable/disable plugin tracing
- plugin_span_kind: string (default: 'internal') - Span kind for plugin spans
  - 'internal': Standard internal operation (may be excluded from metrics)
  - 'server': Server-side operation (typically included in service-level metrics)

This addresses GitHub issue apache#12510 and provides end-to-end tracing visibility
for APISIX plugin execution phases.
@aliibii aliibii force-pushed the feat/opentelemetry-plugin-tracing branch from f456f22 to 8393636 Compare October 17, 2025 10:35
@aliibii aliibii marked this pull request as ready for review October 18, 2025 09:55
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. enhancement New feature or request plugin labels Oct 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request plugin size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: opentelemetry plugin give traces of all other plugin that are added into route

2 participants