← Back to Pull requests

feat: add optional message telemetry hooks for OpenTelemetry integration #442

Open
gibson9583 opened this pull request with 2743 lines diff across 22 files
View on GitHub
gibson9583 gibson9583 commented on Sep 15, 2026 17:43 UTC
Author

Summary

Adds an optional message telemetry bridge to the engine so an extension can observe message processing and maintain trace context across destination-chain and JavaScript worker handoffs.

This provides the engine integration points needed by the OpenTelemetry plugin. SDK setup, exporters, sampling, configuration and durable trace-continuity policy remain extension responsibilities.

Closes #432

Changes

  • Add a MessageTelemetry.Provider contract with observations for source processing, destination attempts, filtering/transformation, sending and response transformation.

  • Transfer context across destination-chain and JavaScript executors, activating it only when work starts and restoring the worker's previous context when it finishes.

  • Add an ingress callback before the source map becomes read-only and is first persisted, allowing a provider to prepare private propagation metadata.

  • Carry optional dispatch context through native source-to-destination and destination-to-destination handoffs. The context uses a transient, owner-keyed slot on ConnectorMessage, with compare-and-set publication to prevent older or reentrant callbacks from overwriting a newer reservation.

  • Keep destination observations open through retry handling and engine cleanup, including DAO/queue cleanup attempts and status-lock release.

  • Document the provider contract, lifecycle boundaries and behavior matrix.
  • Compatibility and failure handling

  • No new runtime dependencies or database schema changes.

  • With no provider installed, observation hooks are no-ops and executor wrapping returns the original task.

  • Dispatch context is excluded from Java and XML serialization; the existing Java serialization identity is preserved. Providers must keep this context bounded, immutable and free of message content or live SDK resources.

  • Ordinary provider callback failures are isolated from message processing and produce one fixed warning per installation, without exception content. VM errors and ThreadDeath retain fatal handling.

  • Provider registration allows one active installation; closing an old registration cannot detach a newer provider.
  • Validation

    Regression coverage includes synchronous and queued processing, parallel destinations, retries, persisted PENDING messages, filtering and transformation failures, callback failures, cleanup ordering, executor rejection/cancellation, and JavaScript context restoration.

    Diff: 2743 lines (+2482 / -261) across 22 files Reviewer: pacmano1 Review duration: 77651m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.79) × (1 − Review Confidence (0.73)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.79 · 2743 lines diff across 22 files
    0.79
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.55 · 3 substantive comment(s)
    0.55
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    73%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.400
    Mass File Touch mass_file_touch
    0.080
    Real PR Conversation Timeline
    5 items
    github-actions[bot] github-actions[bot] commented on Sep 15, 2026 17:53 UTC
    Bot

    Test Results


    132 files  + 9  132 suites  +9   3m 24s ⏱️ + 1m 35s
    766 tests +76  766 ✅ +76  0 💤 ±0  0 ❌ ±0 
    778 runs  +76  778 ✅ +76  0 💤 ±0  0 ❌ ±0 

    Results for commit d5799f27. ± Comparison against base commit 9359d9a8.

    [test-results]:data:application/gzip;base64,H4sIACuGqWoC/13MSw7CIBSF4a00jB3ArXCLmzHllRDbYniMjHsXSa3o8P9Och7E+cUmchnYCKeBpOJzl6bEOfuwVQB6rlDH/J5RiE9dU9H6n27+Xoke4Ga//ICNMcRdYtnaJ057HJedfB9bd4et+z8d1tXnGsRwlNIBKscNcqqc1QKZZEDHSY4KwVAK1gB5vgBAT1UvCQEAAA==

    jonbartels jonbartels commented on Sep 15, 2026 17:58 UTC
    Contributor

    @gibson9583 - I have not reviewed yet, but one of the first things that jumps out at me is that the PR needs links or docs for:
    wheres the plugin?
    Why can't the plugin add its own endpoints instead of modifying core OIE?
    what data elements are exposed?
    are there docker-compose files, integration tests, etc that would be useful for testing or demonstrating what this does?

    gibson9583 gibson9583 commented on Oct 06, 2026 11:47 UTC
    Author

    @gibson9583 - I have not reviewed yet, but one of the first things that jumps out at me is that the PR needs links or docs for:

    > wheres the plugin?

    > Why can't the plugin add its own endpoints instead of modifying core OIE?

    > what data elements are exposed?

    > are there docker-compose files, integration tests, etc that would be useful for testing or demonstrating what this does?

    Hey @jonbartels - I'm not ready to share my plugin repo public but I can share a compiled plugin for you. The PR should be able to stand on its own however.

    There is a doc contained in the PR that should describe the items you have questioned.

    pacmano1 pacmano1 requested changes on Oct 15, 2026 14:14 UTC
    Changes Requested Reviewer

    Nothing uses this yet. The doc in the PR says the plugin can't start on this engine yet and performance hasn't been measured. I'd want the plugin, or at least a small sample provider, running against this branch before core takes the API. Otherwise we can't tell which parts are needed, for example the owner-keyed slot on ConnectorMessage vs. a source map entry, which already travels with every destination.

    The failure warning never shows up. Stock log4j2.properties has rootLogger = ERROR and nothing for MessageTelemetry, so the WARN is filtered. I ran a provider whose callbacks all throw: messages processed normally and mirth.log had nothing. Allowing WARN for that logger showed the line once per install. Log at ERROR, or add the logger to log4j2.properties.

    Unrelated fix inside. The fallback statusUpdateLock unlock in DestinationConnector fixes an existing leak when dao.close() throws. Separate issue and PR please.

    Style. One-line try { ...; } catch (...) { ...; throw x; }, several statements per line, and braceless if/else don't match the rest of the codebase.

    The doc reads like a dev log ("reduced engine development slice", "old plugin", "adapter"). Rewrite it for someone reading the repo, or move it to the PR description.

    How to verify steps are missing.

    Reviewers
    Assignees
    gibson9583 gibson9583
    Labels
    risk: low confidence: 73.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 78.5% (HIGH) · Higher = larger blast radius
    78.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 73.3% · Lower = rushed or shallow review
    73.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21.0% · Safe to merge
    21.0%