Skip to content

Add php-amqp plugin#146

Merged
jmjoy merged 9 commits into
apache:masterfrom
jmjoy:php-amqp
Jun 26, 2026
Merged

Add php-amqp plugin#146
jmjoy merged 9 commits into
apache:masterfrom
jmjoy:php-amqp

Conversation

@jmjoy

@jmjoy jmjoy commented Jun 24, 2026

Copy link
Copy Markdown
Member

Summary

This PR introduces a new php-amqp plugin that traces AMQPExchange::publish() calls as MQ Exit spans, propagates the sw8 header for distributed tracing, and includes a comprehensive e2e test suite. Along the way, phper is upgraded from 0.17.2 to 0.17.5, which switches several phper APIs from mutable to read-only — the changes cascade across execute.rs, style.rs, plugin_mysqli.rs, plugin_memcache.rs, and plugin_psr3.rs.

Changes

New plugin — php-amqp (php-amqplib's C-extension counterpart)

  • src/plugin/plugin_amqp.rs — Hooks AMQPExchange->publish() to create Exit spans with SpanLayer::Mq, extracting the broker peer from AMQPConnection, capturing the exchange name (topic) and routing key (queue), and injecting sw8 into the AMQP message headers.
  • src/plugin/mod.rs — Registers AmqpPlugin.
  • tests/php/fpm/amqp.php — e2e test exercising one-arg through five-arg publish calls, verifying both sw8 injection and preservation of user-supplied headers.
  • tests/e2e.rs — Adds request_fpm_amqp().
  • tests/data/expected_context.yaml — Adds the 5 expected AMQP exit spans and the entry span for /amqp.php, bumping segmentSize from 20 → 21.
  • CI updates: installs librabbitmq-dev and enables amqp PHP extension.

phper 0.17.2 → 0.17.5 upgrade

  • Cargo.toml / Cargo.lock — phper 0.17.20.17.5, phper-alloc 0.16.10.16.3, phper-build 0.15.40.15.6, phper-macros 0.15.20.15.3, phper-sys 0.15.40.15.6.
  • dist-material/LICENSE — Updates version strings for all phper crates.

Refactoring to match phper's read-only API shift

  • src/execute.rs:infer_request_idget_mut_parameter(0).as_mut_z_obj()get_parameter(0).as_z_obj(), get_mut_property("fd")get_property("fd").
  • src/plugin/style.rs — Removes validate_num_args and get_mut_parameter (both mutation-based); adds get_parameter (read-only). Callers no longer pass ApiStyle for arg validation.
  • src/plugin/plugin_mysqli.rs — Rewrites get_peer_by_parameters to accept explicit (class_name, function_name) and determine correct host/port indices per function signature, instead of relying on ApiStyle and mutable params.
  • src/plugin/plugin_memcache.rsget_mut_parameterget_parameter.
  • src/plugin/plugin_psr3.rs — Adds validate_num_args guards so that optional context arguments don't panic on OOB access.

Documentation

  • README.md — Marks php-amqp as supported (✅) for Message Queuing Producer.

@jmjoy jmjoy marked this pull request as ready for review June 25, 2026 01:09
@jmjoy jmjoy requested review from Copilot and wu-sheng June 25, 2026 01:09

This comment was marked as low quality.

@jmjoy jmjoy marked this pull request as draft June 25, 2026 01:41
jmjoy added 5 commits June 25, 2026 10:18
The phper crate update to version 0.17.5 introduces breaking changes,
replacing
mutable parameter access methods (get_mut_parameter, get_mut_property)
with
their immutable counterparts. This also removes the need for manual
argument
materialization in the AMQP plugin, replacing it with the new
materialize_missing API, and simplifies style-based parameter access and
validation.
@jmjoy jmjoy marked this pull request as ready for review June 26, 2026 03:42
@jmjoy jmjoy requested a review from heyanlong June 26, 2026 07:06
@jmjoy jmjoy merged commit 83ec158 into apache:master Jun 26, 2026
18 checks passed
@jmjoy jmjoy deleted the php-amqp branch June 26, 2026 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants