Skip to content

feat(client-generator): send the SDK usage event as the cli-otel CloudEvent - #3371

Open
AlbinaBlazhko17 wants to merge 6 commits into
mainfrom
feat/sdk-usage-strict-event
Open

AlbinaBlazhko17 wants to merge 6 commits into
mainfrom
feat/sdk-usage-strict-event

Conversation

@AlbinaBlazhko17

@AlbinaBlazhko17 AlbinaBlazhko17 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What/Why/How?

The usage telemetry event of generated clients had its own shape: data was an object with usage and sdk maps, so it did not follow the CloudEvent schema of the other Redocly CLI events in @redocly/cli-otel.
The generated TypeScript, Python, Go, and PHP clients now send the com.redocly.sdkUsage.aggregated CloudEvent from @redocly/cli-otel 0.4.0: data holds the operation with its counts, then the SDK.

  • A generated client still has no dependencies. The TypeScript module types its event with the message type of @redocly/cli-otel, and the prepare script inlines that type into the runtime source.
  • The span attributes of every language are what processCloudEventAttributes of @redocly/cli-otel gives for the event. The end-to-end test of each language compares them key by key, so a change of the event in a new @redocly/cli-otel fails the tests until the four runtimes follow.
  • A custom sink receives the new event, so a sink that read data.usage must read the first item of data. The changeset says so.

Reference

Testing

Locally, unit and E2E tests. The events of generated TypeScript, Python, Go, and PHP clients were also sent to a local OpenTelemetry collector.

Screenshots (optional)

Check yourself

  • This PR follows the contributing guide
  • All new/updated code is covered by tests
  • Core code changed? - Tested with other Redocly products (internal contributions only)
  • New package installed? - Tested in different environments (browser/node)
  • Documentation update has been considered

Security

  • The security impact of the change has been considered
  • Code follows company security practices and guidelines

@AlbinaBlazhko17 AlbinaBlazhko17 self-assigned this Nov 5, 2026
@changeset-bot

changeset-bot Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4a416d2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@redocly/client-generator Minor
@redocly/cli Minor
@redocly/openapi-core Minor
@redocly/recheck Minor
@redocly/respect-core Minor
@redocly/reunite-integration Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

📝 Recheck Summary

⚠️ Warnings found • Scanned 1 changed file(s)

  • 0 error(s)
  • 4 warning(s)
  • 1 info

📋 Findings by rule

🟡 technical-english/sentence-length: 0 errors, 2 warnings, 0 info
🔵 technical-english/passive-voice: 0 errors, 0 warnings, 1 info
🟡 semantic-line-breaks: 0 errors, 2 warnings, 0 info

Errors fail the full-tree check. Warnings and info are a worklist and do not block the PR.

📖 Readability of changed files

Automated Readability Index (ARI): a U.S. grade level. Lower is easier to read.

File Base This PR Change
docs/@v2/commands/generate-client.md 6.4 6.3 ±0

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 82.64% (🎯 80%) 21966 / 26578
🔵 Statements 82.2% (🎯 80%) 23839 / 29001
🔵 Functions 84.4% (🎯 80%) 4259 / 5046
🔵 Branches 75.57% (🎯 75%) 16272 / 21531
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/client-generator/src/generators/typescript/telemetry/telemetry.ts 94.59% 85.1% 100% 96.81% 80, 107-108, 110-111, 136, 184, 242, 243, 403
packages/client-generator/src/runtime-sources/go-telemetry.ts 100% 100% 100% 100%
packages/client-generator/src/runtime-sources/php-telemetry.ts 100% 100% 100% 100%
packages/client-generator/src/runtime-sources/python-telemetry.ts 0% 100% 100% 0% 3
packages/client-generator/src/runtime-sources/telemetry.ts 100% 100% 100% 100%
Generated in workflow #13267 for commit 4a416d2 by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Performance Benchmark (Lower is Faster)

CLI Version Bundle Lint Check Config
latest ▓░░░░░░░░░░ 1.01x ± 0.02 ▓░░░░░░░░░░ 1.00x ▓░░░░░░░░░░ 1.00x
next ▓░░░░░░░░░░ 1.00x ▓░░░░░░░░░░ 1.01x ± 0.02 ▓░░░░░░░░░░ 1.02x ± 0.01

@AlbinaBlazhko17
AlbinaBlazhko17 marked this pull request as ready for review November 5, 2026 14:49
@AlbinaBlazhko17
AlbinaBlazhko17 requested review from a team as code owners November 5, 2026 14:49

@vadyvas vadyvas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

};
};
// The package root reaches its types through paths without an extension, which `nodenext`
// cannot resolve, so the types come from their own file. The prepare script inlines them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks bad, but it seems not in this pr

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