Skip to content

v2.0.1#446

Merged
sjvans merged 14 commits into
mainfrom
cds-10-9
Jul 3, 2026
Merged

v2.0.1#446
sjvans merged 14 commits into
mainfrom
cds-10-9

Conversation

@sjvans

@sjvans sjvans commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

@hyperspace-pr-bot hyperspace-pr-bot Bot 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.

The diff is small and the full file is now visible. The changes look straightforward — re-enabling the CDS v10 matrix entry and its corresponding conditional install step. No issues to flag beyond what's already visible.

The PR is in a work-in-progress state (the description checklist still has open items: package.json, release job, and the unused-vars check). The CI workflow changes themselves are clean and correct.

PR Bot Information

Version: 1.26.11

  • Correlation ID: 2ce8afeb-55a2-48e1-bcb0-a834798ae650
  • File Content Strategy: Full file content
  • LLM: anthropic--claude-4.6-sonnet
  • Event Trigger: pull_request.opened

@sjvans sjvans changed the title chore: cds^10 || cds^9 chore: cds^10 || cds^9 Jun 30, 2026
@sjvans
sjvans marked this pull request as ready for review July 2, 2026 11:25
@sjvans
sjvans requested a review from PDT42 July 2, 2026 11:25

@hyperspace-pr-bot hyperspace-pr-bot Bot 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.

All the changes are consistent and correct. The _ and req parameters were removed because they were unused in the callback body — the function only uses this. Everything checks out across all the modified files.

The PR is clean and well-structured. All changes are consistent with upgrading to CDS v10 support — removing obsolete CDS version guards, dropping unused imports, and updating dependency ranges. No issues to flag.

PR Bot Information

Version: 1.26.14

  • Correlation ID: ad289550-7608-11f1-9513-431f8e71057d
  • File Content Strategy: Full file content
  • LLM: anthropic--claude-4.6-sonnet
  • Event Trigger: pull_request.ready_for_review

@hyperspace-pr-bot

Copy link
Copy Markdown
Contributor

Summary

The following content is AI-generated and provides a summary of the pull request:


Chore: Add cds^10 Support Alongside cds^9

Chore

🔧 This PR extends the peer dependency support to include @sap/cds version 10 alongside version 9, updates the CI/release pipelines accordingly, removes legacy version checks, and cleans up unused imports/variables.

Changes

  • package.json:

    • Updated peerDependencies to "@sap/cds": "^10 || ^9"
    • Bumped dev dependencies: @cap-js/cds-test to ^1, @cap-js/sqlite to ^3, @sap/cds-mtxs to ^4, chai to ^6, chai-as-promised to ^8; removed chai-subset
    • Added --max-warnings=0 to the lint script to enforce zero ESLint warnings
  • .github/workflows/ci.yml: Re-enabled cds-version: [10, 9] matrix and restored the conditional npm i -f @sap/cds@9 ... step for CDS 9 compatibility

  • .github/workflows/release.yml: Removed the npm explore better-sqlite3 -- npm run install workaround that was only needed for CDS < 10, along with its associated comment

  • lib/metrics/queue.js: Removed the cds < 9 version guard that skipped queue metrics setup

  • lib/metrics/db-pool.js: Removed unused req parameter from the BEGIN event handler callback

  • lib/metrics/index.js: Removed unused AggregationType import from @opentelemetry/sdk-metrics

  • lib/tracing/index.js: Removed unused trace import from @opentelemetry/api

  • test/metrics-outbox.test.js, test/metrics-outbox-disabled.test.js, test/metrics-outbox-multitenant.test.js: Removed all cds.version < 9 runtime guards and skip conditions

  • test/tracing-attributes.test.js: Removed the cds < 9 skip guard for HTTP client attribute tests


  • 🔄 Regenerate and Update Summary
  • ✏️ Insert as PR Description (deletes this comment)
  • 🗑️ Delete comment
PR Bot Information

Version: 1.26.14

  • Output Template: Default Template
  • LLM: anthropic--claude-4.6-sonnet
  • Summary Prompt: Default Prompt
  • Event Trigger: issue_comment.edited
  • File Content Strategy: Full file content
  • Correlation ID: b5a80760-7608-11f1-9abe-070616a09295

PDT42
PDT42 previously approved these changes Jul 2, 2026

@PDT42 PDT42 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.

I am slightly worried about the effect of removing the chai import. AFAIK cds.test will now fall-back on expect.js, which does not behave entirely the same. However, the only real issue I did encounter with that so far, was .not.to.have.property silently passing and I didn't find that one being used anywhere in the tests of this repo.

🚀

Comment thread lib/metrics/queue.js
@sjvans

sjvans commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

I am slightly worried about the effect of removing the chai import. AFAIK cds.test will now fall-back on expect.js, which does not behave entirely the same. However, the only real issue I did encounter with that so far, was .not.to.have.property silently passing and I didn't find that one being used anywhere in the tests of this repo.

🚀

cds-test has chai and chai-as-promise as peer deps → we get them from there. i will still add a package-lock before merging. fixing hana workflow first...

## Problem

The HANA workflow's `passport.test.js › gets set once for simple
queries` fails on `cds-10-9` — see [run
28586742752](https://github.com/cap-js/telemetry/actions/runs/28586742752):

```
Message: expected 4 to strictly equal 2
> 41 |     expect(_count).to.equal(2)
```

## Root cause

CDS v10 sets [`cds.requires.scheduling =
true`](055f112) by default.
Its Scheduler polls `cds.outbox.Messages` in its own database
transactions. Those extra transactions overlap request timing and each
triggers this plugin's `BEGIN` reset
([lib/tracing/index.js:141-143](https://github.com/cap-js/telemetry/blob/cds-10-9/lib/tracing/index.js#L141-L143))
+ per-SELECT passport set
([lib/tracing/trace.js:351](https://github.com/cap-js/telemetry/blob/cds-10-9/lib/tracing/trace.js#L351)).

Reproduced locally on `cds-10-9` with `@sap/cds@10.0.3` +
`@cap-js/hana@3.0.1`. Instrumented the plugin's `dbc.set()` and captured
the exact sequence:

```
[0] '' (reset)                ← BEGIN of scheduler outbox tick
[1] 2A54482A03…               ← SELECT cds.outbox.Messages
[2] '' (reset)                ← BEGIN of user request
[3] 2A54482A03…               ← SELECT AdminService.Books
```

2 transactions × (1 reset + 1 passport) = `_count = 4`. The test's
assertion of `2` was correct for CDS v9's single-transaction-per-request
behavior — cds v10 broke that invariant.

The queue-metrics plugin already needed adjusting for the same
scheduling shift — see
[#435](#435) ("adapt queue
metrics to CDS v10 scheduling changes"). Passport was overlooked.

## Fix

Disable `scheduling` for this test only. The test's purpose is to verify
SAP_PASSPORT stamping during a user request; the scheduler is irrelevant
to that check and its background transactions just produce
non-deterministic extra sets.

```diff
 process.env.SAP_PASSPORT = 'true'
+// CDS v10 enables scheduling by default; its periodic outbox reads run in
+// their own transactions and cause spurious SAP_PASSPORT set/reset pairs on
+// the connection, breaking the deterministic _count assertions below.
+process.env.cds_requires_scheduling = 'false'
```

## Verification

Ran the CI-scoped subset (`CI=true HANA_DRIVER=hdb HANA_PROM=true npm
test`) locally against the same HDI container / driver stack the
workflow uses:

```
PASS test/passport.test.js
PASS test/tracing-attributes.test.js (18.184 s)
Test Suites: 2 passed, 2 total
Tests:       7 passed, 7 total
```

## Follow-up (out of scope for this PR)

There's an underlying semantic issue: the passport plugin currently
stamps SAP_PASSPORT on every database call, including scheduler/outbox
internal transactions that have no user request to correlate to. That
pollutes DSR passport traces on production HANA — worth a separate PR
that skips `dbc.set` when `cds.context?.user?.id === 'privileged'` at
both sites.

---------

Co-authored-by: sjvans <sjvans@users.noreply.github.com>
@sjvans sjvans changed the title chore: cds^10 || cds^9 v2.0.1 Jul 3, 2026
sjvans and others added 2 commits July 3, 2026 12:24
## Summary

- **DB inner spans** now show `VERB table` instead of raw SQL in the
span name (e.g. `@cap-js/sqlite - prepare SELECT
sap.capire.bookshop.Books`). CDS operation names are mapped to SQL verbs
(`READ→SELECT`, `CREATE→INSERT`). Raw SQL is preserved in the
`db.query.text` attribute per OTel convention.

- **Cloud SDK spans** now use `METHOD /path` (query string stripped) by
default, or `METHOD` only when `_append_url_path` is `false` —
consistent with the HTTP root span name behaviour controlled by the same
flag. Destination name removed from span name; still available as
`sap.btp.destination` attribute.

## Before / After

| | Before | After |
|---|---|---|
| DB SELECT | `@cap-js/sqlite - prepare SELECT
json_insert('{}','$."createdAt"'…` | `@cap-js/sqlite - prepare SELECT
sap.capire.bookshop.Books` |
| DB INSERT | `@cap-js/sqlite - exec INSERT INTO
sap_capire_bookshop_Books …` | `@cap-js/sqlite - exec INSERT
sap.capire.bookshop.Books` |
| DB UPDATE | `@cap-js/sqlite - stmt.run UPDATE
sap_capire_bookshop_Books …` | `@cap-js/sqlite - stmt.run UPDATE
sap.capire.bookshop.Books` |
| DB DELETE | `@cap-js/sqlite - exec DELETE FROM
sap_capire_bookshop_Books …` | `@cap-js/sqlite - exec DELETE
sap.capire.bookshop.Books` |
| Cloud SDK (`_append_url_path: true`) | `S4HANA GET
https://s4hana.example.com/sap/opu/…?$top=10` | `GET /sap/opu/…` |
| Cloud SDK (`_append_url_path: false`) | `S4HANA GET https://…` | `GET`
|
| HTTP root (`_append_url_path: true`) | `GET` | `GET
/odata/v4/admin/Books` |

> Raw `db.run('SELECT ...')` is unchanged — the SQL string remains in
the name since there is no `db.operation.name`/`db.sql.table` to
substitute.

## Test plan

- [ ] `test/tracing-span-names.test.js` added — covers DB span name
format (SELECT, INSERT) and Cloud SDK URL-free names

---------

Co-authored-by: Vitaly Kozyura <58591662+vkozyura@users.noreply.github.com>
Co-authored-by: I548646 <paul.erlenwein@sap.com>
Co-authored-by: Paul <paul.erlenwein@gmail.com>
Co-authored-by: hyperspace-insights[bot] <209611008+hyperspace-insights[bot]@users.noreply.github.com>
Co-authored-by: sjvans <sjvans@users.noreply.github.com>
@sjvans

sjvans commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

PDT42
PDT42 previously approved these changes Jul 3, 2026
Comment thread test/tracing-span-names.test.js Outdated
Comment thread lib/tracing/cloud_sdk.js
Comment thread lib/tracing/trace.js

@PDT42 PDT42 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.

🚀

@sjvans
sjvans merged commit d932e18 into main Jul 3, 2026
8 checks passed
@sjvans
sjvans deleted the cds-10-9 branch July 3, 2026 11:06
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.

2 participants