feat(008): Plugin observability — test run ID correlation and FFI log sink#537
Merged
Merged
Conversation
… sink
Implements the pact-reference side of proposal 008 (Plugin observability
and logging), depending on pact-plugin-driver 1.0.0-beta.5.
pact_consumer:
- Add uuid (v4, optional) under the plugins feature
- Generate a UUID and set it as the thread-local test run ID immediately
before each configure_interaction call in RequestBuilder, ResponseBuilder,
MessageInteractionBuilder, and SyncMessageInteractionBuilder so that the
driver forwards testContext.testRunId to V2 plugins for log correlation
pact_ffi:
- Add log/plugin_sink.rs: FfiPluginLogSink implementing PluginLogSink;
buffers every plugin log entry by plugin instance ID and optionally
forwards to a registered C callback (PluginLogCallback)
- Register FfiPluginLogSink in pactffi_init and pactffi_init_with_log_level
via an OnceLock guard so it is set up exactly once on FFI initialisation
- New exported functions:
pactffi_set_test_run_id — set thread-local test run UUID
pactffi_register_plugin_log_callback — register C callback for live log forwarding
pactffi_get_plugin_logs — retrieve buffered log entries as newline-delimited JSON
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…t_matching Generate a UUID and set it as the thread-local test run ID immediately before calling match_contents in the plugin body comparison path, so that the driver forwards testContext.testRunId to V2 plugins during verification. Also bumps pact-plugin-driver to ~1.0.0-beta.5 in pact_matching. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… only in pact_matching In pact_verifier, generate a UUID at the start of verify_interaction so that all plugin calls for a single interaction (prepare_validation, verify_interaction, and body comparison via pact_matching) share the same test run ID for log correlation. Update pact_matching to only generate a fallback UUID when no test run ID is already set on the thread, so it does not override the one set by the verifier. Also bumps pact-plugin-driver to ~1.0.0-beta.5 in pact_verifier. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the
pact-referenceside of proposal 008 — Plugin observability and logging. Requirespact-plugin-driver≥ 1.0.0-beta.5 (released via pact-plugins PRs #100 and #101).pact_consumeruuid(v4) as an optional dependency under thepluginsfeature.pact_plugin_driver::test_context::set_test_run_idimmediately before everyconfigure_interactioncall inRequestBuilder,ResponseBuilder,MessageInteractionBuilder, andSyncMessageInteractionBuilder. The driver then forwardstestContext.testRunIdto V2-capable plugins so their log entries can be correlated with a specific test.pact_ffilog/plugin_sink.rs(new):FfiPluginLogSinkimplementingPluginLogSink. Buffers every plugin log entry keyed by plugin instance ID. Optionally forwards entries to a registered C callback (PluginLogCallback) for live streaming.FfiPluginLogSinkwith the driver inpactffi_initandpactffi_init_with_log_levelvia anOnceLockguard (set up exactly once).pactffi_set_test_run_id(test_run_id: *const c_char)— set the thread-local test run UUID forwarded in plugin requesttestContextpactffi_register_plugin_log_callback(callback)— register a C function pointer called for each plugin log entry as it arrivespactffi_get_plugin_logs(plugin_instance_id: *const c_char) -> *const c_char— retrieve all buffered log entries for a plugin instance as newline-delimited JSON; caller frees withpactffi_string_deleteTest plan
cargo check/cargo buildpasses across the workspacecargo test --package pact_ffiall passtestContext.testRunIdduringconfigure_interactionwhen called frompact_consumerpactffi_get_plugin_logsreturns structured entries after an FFI-driven test that uses a plugin🤖 Generated with Claude Code