Repository navigation
feat: introduce sap quality of service attribute to audit logs - #426
Conversation
LucasAlvesSoares
left a comment
There was a problem hiding this comment.
PR Review: #426: feat: introduce sap quality of service attribute to audit logs
Author: LucasAlvesSoares Branch: qos-for-auditlog → main
Verdict:
Summary: Small, well-scoped change adding a hardcoded sap.qos.class="at_least_once" attribute to every emitted audit log record; code is clean and tested, but the JSON path lacks an explicit test assertion and one CI gate (the review label) is still pending.
A: Process & Compliance
| # | Criterion | Status | Finding |
|---|---|---|---|
| A1 | PR template complete | Description, Type of Change, How to Test, and core checklist all present/ticked. "Related Issue" section was removed rather than filled — acceptable since no issue is tracked, but see A3. Not a new module and not security-sensitive, so the two conditional items correctly left unticked. | |
| A2 | Conventional Commits | ✅ | PR title feat: introduce sap quality of service attribute to audit logs is valid. Commit Validation CI job passed. |
| A3 | Issue linked | No Closes #N in the body. Non-blocking. |
|
| A4 | AI-generated code disclosure | ➖ | Change is trivial/mechanical; no disclosure required. |
B: Security & Sensitive Data
| # | Criterion | Status | Finding |
|---|---|---|---|
| B1 | No sensitive data in code | ✅ | Only semantic-convention string constants (sap.qos.class, at_least_once). |
| B2 | No sensitive data in PR body | ✅ | No internal URLs, tenant IDs, or customer names. |
C: Code Quality
| # | Criterion | Status | Finding |
|---|---|---|---|
| C1 | CI checks passing | Code Quality, Tests & Coverage, Build, CodeQL, Commit Validation, Version Bump all pass. Integration Tests fails on tests/agentgateway/integration/test_agw_bdd.py::test_get_ias_client_id_returns_a_nonempty_string (OAuth2 "Missing access token") — a pre-existing, environment-dependent agentgateway failure unrelated to this change. SDK review label present fails pending this review. |
|
| C2 | Version bump | ➖ | No manual pyproject.toml version change. |
| C3 | Type hints | ✅ | No public signatures changed; new symbols are module-level string constants. |
| C4 | No hardcoded values | ✅ | Attribute key and value extracted to constants ATTR_SAP_QOS_CLASS / QOS_CLASS_AT_LEAST_ONCE in core/telemetry/constants.py:30-31, consistent with the existing ATTR_SAP_* convention. |
| C5 | Import organization | ✅ | Top-level grouped import from telemetry.constants in client.py:41-44. |
| C6 | Naming conventions | ✅ | ATTR_SAP_QOS_CLASS matches the ATTR_SAP_* family; value constant is SCREAMING_SNAKE_CASE. |
| C7 | No unused code | ✅ | Both imported constants are used (client.py:256; test assertion). |
| C8 | No unjustified new dependencies | ➖ | No dependency changes. |
| C9 | Proto code freshness | ➖ | No .proto changes. |
D: API & Design
| # | Criterion | Status | Finding |
|---|---|---|---|
| D1 | API future-proofing | ✅ | No new public API surface; attribute emitted internally in AuditClient.send(). |
| D2 | Public API hygiene | ✅ | New constants live in the internal telemetry constants module; nothing added to a public __all__. |
| D3 | Breaking changes marked | ✅ | Purely additive — a new attribute on emitted records; no removed/renamed symbols. |
| D4 | Pagination & tenant filtering | ➖ | No list/query operation. |
| D5 | Telemetry instrumentation | ✅ | This change is telemetry; send() already routes through existing instrumentation and the attribute is placed alongside existing OTel attributes. |
| D6 | Multi-tenancy support | ➖ | No change to tenancy behavior. |
E: Tests & Documentation
| # | Criterion | Status | Finding |
|---|---|---|---|
| E1 | Tests added/updated | test_send_binary_success asserts attributes[ATTR_SAP_QOS_CLASS] == QOS_CLASS_AT_LEAST_ONCE. Good. However test_send_json_success was not extended with the same assertion — the JSON path (send_json → send) shares the attribute dict, so it is covered transitively, but an explicit assertion would guard against future divergence. |
|
| E2 | Documentation quality | The auditlog_ng/user-guide.md is not updated to mention the new sap.qos.class attribute. Minor — the attribute is non-configurable and transparent to callers, so this is optional. |
|
| E2a | Multi-tenancy documentation | ➖ | user-guide.md already contains a ## Multi-tenancy section and is unchanged by this PR. |
| E3 | Module structure compliance | ➖ | No new module. |
❌ Blocking Issues
- None.
⚠️ Non-Blocking Suggestions
- [E1]: Add
assert kwargs["attributes"][ATTR_SAP_QOS_CLASS] == QOS_CLASS_AT_LEAST_ONCEtotest_send_json_successso both serialization paths explicitly assert the QoS attribute. - [C1]: Confirm the
Integration Testsfailure is the pre-existing agentgateway OAuth2 flake and not introduced here (the failing test is unrelated to auditlog). Re-run once the environment token is available. - [A3]: Add
Closes #Nif a tracking issue exists. - [E2]: Optionally note the always-on
sap.qos.class="at_least_once"attribute inauditlog_ng/user-guide.md. - Style (nit): The sibling literals
"sap.tenancy.tenant_id"and"cloudevents.event_id"in the sameemit()call remain inline even thoughATTR_SAP_TENANT_IDalready exists in the constants file. Not introduced by this PR, but the new line makes the inconsistency visible — consider switching the neighbors to the shared constant in a follow-up.
✅ Things Done Well
- Attribute key and value correctly extracted to shared constants rather than inline literals, matching the established
ATTR_SAP_*convention and the correct semantic-convention value (at_least_once, notbest_effort). - Constants placed in
core/telemetry/constants.py— the right home, already owning sibling SAP attributes; the auditlog module already depends on the telemetry package. - Minimal, focused diff (3 files, +18/−1) with a test assertion added.
LucasAlvesSoares
left a comment
There was a problem hiding this comment.
PR Review: #426: feat: introduce sap quality of service attribute to audit logs
Author: LucasAlvesSoares Branch: qos-for-auditlog → main
Verdict: ✅ Ready to Merge
Summary: Clean, additive change adding a hardcoded sap.qos.class="at_least_once" attribute to every emitted audit log record; the two docs and tests commit.
Re-review of head
d4f29f6(2nd commitdocs and tests). Both previously-flagged⚠️ findings (E1, E2) are addressed; nothing new introduced. Diff is now 4 files, +22/−1.
A: Process & Compliance
| # | Criterion | Status | Finding |
|---|---|---|---|
| A1 | PR template complete | Description, Type of Change, How to Test, and core checklist present/ticked. "Related Issue" omitted (no tracked issue). The "updated documentation" checkbox is still unticked even though the user-guide was updated in this PR — tick it for accuracy. Conditional items (new-module e2e, security-review) correctly left unticked. | |
| A2 | Conventional Commits | ✅ | PR title feat: introduce sap quality of service attribute to audit logs is valid; Commit Validation passed. (PRs squash-merge, so the per-commit docs and tests headline is not evaluated.) |
| A3 | Issue linked | No Closes #N in the body. Non-blocking. |
|
| A4 | AI-generated code disclosure | ➖ | Trivial/mechanical change; no disclosure required. |
B: Security & Sensitive Data
| # | Criterion | Status | Finding |
|---|---|---|---|
| B1 | No sensitive data in code | ✅ | Only semantic-convention string constants (sap.qos.class, at_least_once). |
| B2 | No sensitive data in PR body | ✅ | No internal URLs, tenant IDs, or customer names. |
C: Code Quality
| # | Criterion | Status | Finding |
|---|---|---|---|
| C1 | CI checks passing | SDK review label present, Build & Package, Check Version Bump, Commit Validation, REUSE, CLA all pass. Code Quality Checks, Tests & Coverage, Analyze (python), Integration Tests are pending (re-triggered by the 2nd push). Expected to go green; the integration suite's only prior failure was the unrelated agentgateway OAuth2 flake. Not blocking merge pending re-run. |
|
| C2 | Version bump | ➖ | No manual pyproject.toml version change. |
| C3 | Type hints | ✅ | No public signatures changed; new symbols are module-level string constants. |
| C4 | No hardcoded values | ✅ | Key/value extracted to ATTR_SAP_QOS_CLASS / QOS_CLASS_AT_LEAST_ONCE in core/telemetry/constants.py:30-31. |
| C5 | Import organization | ✅ | Top-level grouped import from telemetry.constants in client.py:41-44; test imports at test_client.py:16-19. |
| C6 | Naming conventions | ✅ | ATTR_SAP_QOS_CLASS matches the ATTR_SAP_* family; value constant SCREAMING_SNAKE_CASE. |
| C7 | No unused code | ✅ | Both constants used in client.py:256 and asserted in both send tests. |
| C8 | No unjustified new dependencies | ➖ | No dependency changes. |
| C9 | Proto code freshness | ➖ | No .proto changes. |
D: API & Design
| # | Criterion | Status | Finding |
|---|---|---|---|
| D1 | API future-proofing | ✅ | No new public API surface; attribute emitted internally in AuditClient.send(). |
| D2 | Public API hygiene | ✅ | New constants live in the internal telemetry constants module; nothing added to a public __all__. |
| D3 | Breaking changes marked | ✅ | Purely additive — a new attribute on emitted records. |
| D4 | Pagination & tenant filtering | ➖ | No list/query operation. |
| D5 | Telemetry instrumentation | ✅ | Change is telemetry; attribute placed alongside existing OTel attributes in the already-instrumented send(). |
| D6 | Multi-tenancy support | ➖ | No change to tenancy behavior. |
E: Tests & Documentation
| # | Criterion | Status | Finding |
|---|---|---|---|
| E1 | Tests added/updated | ✅ | Resolved. Both paths now assert the QoS attribute: test_send_binary_success (test_client.py:187) and test_send_json_success (test_client.py:205). |
| E2 | Documentation quality | ✅ | Resolved. user-guide.md:136-137 documents the always-on, non-configurable sap.qos.class="at_least_once" attribute right after the send examples. |
| E2a | Multi-tenancy documentation | ✅ | user-guide.md retains its ## Multi-tenancy section (line 335); the edit does not touch it. |
| E3 | Module structure compliance | ➖ | No new module. |
❌ Blocking Issues
- None.
⚠️ Non-Blocking Suggestions
- [C1]: Let the re-triggered CI finish; confirm
Integration Testspasses (its only prior red was the unrelated agentgateway OAuth2 flake). - [A1]: Tick the "I have updated documentation" checkbox — the user-guide was updated in this PR.
- [A3]: Add
Closes #Nif a tracking issue exists. - Style (nit, pre-existing / out of scope): The sibling literals
"sap.tenancy.tenant_id"and"cloudevents.event_id"in the sameemit()call remain inline; author has chosen to leave these untouched as they predate this branch. Fine for a separate follow-up.
✅ Things Done Well
- Addressed both prior-review
⚠️ items in a focused follow-up commit: explicit QoS assertion on the JSON path and a user-guide note. - Key/value extracted to shared constants matching the
ATTR_SAP_*convention, with the correct semantic-convention value (at_least_once). - Constants placed in
core/telemetry/constants.py— the right home; auditlog already depends on the telemetry package. - Minimal, additive, fully-tested diff (4 files, +22/−1).
Description
Adds the
sap.qos.classquality-of-service attribute, hardcoded toat_least_once, to every audit log record emitted by theauditlog_ngclient.Changes
src/sap_cloud_sdk/core/telemetry/constants.py— addedATTR_SAP_QOS_CLASS = "sap.qos.class"andQOS_CLASS_AT_LEAST_ONCE = "at_least_once".src/sap_cloud_sdk/core/auditlog_ng/client.py— emit the QoS attribute on every audit LogRecord inAuditClient.send().tests/core/unit/auditlog_ng/unit/test_client.py— assert the attribute is set toat_least_onceon emitted records.Type of Change
Please check the relevant option:
How to Test
python -m pytest tests/core/unit/auditlog_ng/unit/test_client.pyAuditClient.send()/send_json()(e.g. via the test's mocked loggeremitcall args).sap.qos.classwith the valueat_least_once, in addition to the existingcloudevents.event_id,sap.tenancy.tenant_id, andsap.auditlogging.mime_typeattributes.Checklist
Before submitting your PR, please review and check the following:
/security-reviewand addressed all ❌ findingsAdditional Notes
at_least_oncefor all audit logs; it is not configurable.