Skip to content

Create new Message Envelope page with new 25.2 features #19542

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

katmayb
Copy link
Contributor

@katmayb katmayb commented Apr 23, 2025

Fixes DOC-11555, DOC-12241, DOC-12307

This PR adds the new enriched envelope format for changefeed messages to docs and restructures our content on changefeed message envelopes.

Includes:

New Changefeed Message Envelope page

  • Use case example for new and existing options
  • Field reference
  • Envelope option reference
  • Preview label for enriched envelope content
  • Content on envelopes moved from the Changefeed Messages page
  • A general overview on envelopes and intro

Other

  • Removed the envelope content from here to the new page.
  • Adjustments to option descriptions on the CREATE CHANGEFEED page.

Preview

New Changefeed Message Envelope page

Copy link

netlify bot commented Apr 23, 2025

Deploy Preview for cockroachdb-interactivetutorials-docs canceled.

Name Link
🔨 Latest commit d33b480
🔍 Latest deploy log https://app.netlify.com/sites/cockroachdb-interactivetutorials-docs/deploys/681397ecfa315d0008983e6b

Copy link

netlify bot commented Apr 23, 2025

Deploy Preview for cockroachdb-api-docs canceled.

Name Link
🔨 Latest commit d33b480
🔍 Latest deploy log https://app.netlify.com/sites/cockroachdb-api-docs/deploys/681397ec927ab10008a3f6e8

Copy link

netlify bot commented Apr 23, 2025

Netlify Preview

Name Link
🔨 Latest commit d33b480
🔍 Latest deploy log https://app.netlify.com/sites/cockroachdb-docs/deploys/681397ec81894200089e84ed
😎 Deploy Preview https://deploy-preview-19542--cockroachdb-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@katmayb katmayb force-pushed the message-envelope-25.2 branch 2 times, most recently from 4ffb586 to 2acfa53 Compare April 25, 2025 20:58
@katmayb katmayb force-pushed the message-envelope-25.2 branch from 0f9cb68 to 6804b9d Compare May 1, 2025 15:30
@katmayb katmayb force-pushed the message-envelope-25.2 branch from 6804b9d to d33b480 Compare May 1, 2025 15:48
<a id="resolved-option"></a>`resolved` | Emit `resolved` timestamps in a format depending on the connected sink. **Note:** The `resolved` timestamp is emitted as a separate message, and has its own envelope containing a `resolved` key and a timestamp value as a string. For more details on the `resolved` options, refer to [Resolved messages]({% link {{ page.version.version }}/changefeed-messages.md %}#resolved-messages). | All
<a id="updated-option"></a>`updated` | Add an [`"updated"`](#updated) timestamp field to each message, showing the commit time of the change. When the changefeed runs an initial scan or a [schema change backfill]({% link {{ page.version.version }}/changefeed-messages.md %}#schema-changes-with-column-backfill), the `"updated"` field will reflect the time of the scan or backfill, not the MVCC timestamp. If you use `updated` with [`enriched_properties=source`](#enriched-properties-option), the `"updated"` field will be replaced with `"ts_ns"` and `"ts_hlc"` in the [`"source"`](#source) fields. **Note:** `envelope=enriched` with the `updated` option will not produce a change event commit timestamp in the message—to include the timestamp, use `updated` with `envelope=enriched, enriched_properties=source, updated`. | All

### `envelope` option examples
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All this content except the enriched part was existing.

New content begins again in the Field Reference section.

@katmayb katmayb changed the title WIP Create new Message Envelope page with new 25.2 features Create new Message Envelope page with new 25.2 features May 1, 2025
@katmayb katmayb marked this pull request as ready for review May 1, 2025 15:50
@katmayb katmayb requested review from rohan-joshi, asg0451 and aerfrei May 1, 2025 15:58
Copy link

@aerfrei aerfrei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read through the new page. Everything was clear and accurate! Thanks so much for this

Copy link

@asg0451 asg0451 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you also add a note either to the ordering guarantees or to the ts_ns enriched section like we discussed?

~~~


- If you need to order messages when using `envelope=enriched`, you must also use `enriched_properties='source` with the `updated` option in order to include the [`"ts_hlc"` and `"ts_ns"`](#source) commit timestamps in the `"source"` field:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing ending single quote after source

CREATE CHANGEFEED FOR TABLE products INTO 'kafka://localhost:9092' WITH envelope=enriched, enriched_properties=source, updated;
~~~
~~~
{"after": {"category": "Home & Kitchen", "created_at": "2025-04-30T20:02:35.40316", "description": "Adjustable LED desk lamp with touch controls", "id": "4b36388a-f7e6-4b95-9f78-3aee9e2060d6", "in_stock": true, "name": "LED Desk Lamp", "price": 22.30}, "op": "c", "source": {"changefeed_sink": "kafka", "cluster_id": "585e6512-ea54-490a-8f1d-50c8d182a2e6", "cluster_name": "", "database_name": "test", "db_version": "v25.2.0-beta.2", "job_id": "1068153948173991937", "node_id": "1", "node_name": "localhost", "origin": "cockroachdb", "primary_keys": ["id"], "schema_name": "public", "source_node_locality": "", "table_name": "products", "ts_hlc": "1746045115619002000.0000000000", "ts_ns": 1746045115619002000}, "ts_ns": 1746045115679811000}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is annoying to read. maybe we should split it across multiple lines?


### `"payload"`

The change event data. `"payload"` is a wrapper only with [webhook]({% link {{ page.version.version }}/changefeed-sinks.md %}#webhook-sink) sinks and when the [`enriched_properties`](#enriched-properties-option) options is used.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess there are two different payloads in question here, which is a little confusing. can you try to disambiguate them?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this organization/format doesnt make that much sense given that we're mixing fields from various envelopes together. this makes it seem like you can get all these fields but actually you only get a subset depending on envelope

The name of the table that generated the change. This field appears in certain contexts:

- In sinkless changefeeds (those created with [`EXPERIMENTAL CHANGEFEED FOR`]({% link {{ page.version.version }}/changefeed-for.md %}) or `CREATE CHANGEFEED ... WITH sinkless`), the output includes a `"table"` field for each row change, because a single sinkless feed could cover multiple tables.
- In the [`enriched`](#enriched) envelope, the [fully qualified table name]({% link {{ page.version.version }}/sql-name-resolution.md %}) is typically part of the [`"source"`](#source) field (as `"database"`, `"schema"`, `"table"` sub-fields), rather than a separate top-level `"table"` field.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

database_name, echema_name, table_name

- `"changefeed_sink"`: The [sink]({% link {{ page.version.version }}/changefeed-sinks.md %}) type receiving the changefeed (e.g., `"kafka"`, `"sinkless buffer"`).
- `"cluster_id"`: The [unique ID]({% link {{ page.version.version }}/cockroach-start.md %}#standard-output).
- `"cluster_name"`: The name, [if configured]({% link {{ page.version.version }}/cockroach-start.md %}#flags-cluster-name).
- `"db_version"`: The CockroachDB version.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing database_name. are any others missing too?

- `"field"`: The name of field.
- `"type"`: The type of the field.
- `"optional"`: This is a boolean field that defines whether a field may be absent in the `"payload"` section of the envelope depending on the configuration.
- `"name"`: The name of the described schema.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if type=array then items will have the array element type

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