Repository navigation
Add event sinks with OpenTelemetry and Sentry exporters - #5
Merged
Merged
Conversation
createMutationEventStore now takes a limit (1000 by default, so the log
no longer grows without bound) and sinks that receive every event as it
is emitted. A failing sink does not affect the flow.
mutaflow/otel records each flow run as one span with its intermediate
events, status, attempts, duration and invalidations. mutaflow/sentry
adds breadcrumbs and captures failed runs as issues. Both accept objects
shaped like the SDKs, so neither is a dependency; type tests check them
against @opentelemetry/api and @sentry/core. Neither sends input or result.
serializeMutationEvent returns a JSON-safe event that keeps error
details. Terminal events carry durationMs. Devtools show the duration,
render errors instead of {}, and can export and clear the log.
Co-Authored-By: Claude Opus 5.5 <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
The mutation event log can now be sent to production monitoring, not only shown in devtools.
Event log
createMutationEventStorenow keeps the latest 1000 events by default (limit). It used to grow for the life of the page.limit: 0keeps no events and only forwards them to sinks.(event) => voidand receives every event as it is emitted. If a sink throws, the flow is not affected and the error goes toonSinkError(defaultconsole.error).durationMs.flow:success,flow:errorandflow:cancelledevents now carrydurationMs.serializeMutationEvent. Returns a JSON-safe event:code;inputandresultare left out unless asked for.Exporters
mutaflow/otel. Each flow run becomes one span.beforeRun, beforeflow:start, still gets a span.mutaflow/sentry. Adds a breadcrumb per event and capturesflow:erroras an issue tagged with the flow name and stage.captureErrorcan filter the remaining errors.Neither SDK is a dependency. Both sinks accept objects shaped like an OpenTelemetry
Traceror the Sentry SDK.tests/types/observability.tschecks them against the real@opentelemetry/apiand@sentry/coretypes, which are root devDependencies only. Neither sink sendsinputorresult.Devtools
{}, becauseJSON.stringifydropsErrorfields.serializeEventLogis exported.Behaviour changes
Not included
Test plan
npm run typecheckfrom a clean build. This includes the SDK compatibility type tests.npm test: 53/53. New tests cover:durationMs;examples/next-app: typecheck andnext build.🤖 Generated with Claude Code