From 9a4e2ae1cc364f21cded82f0ac2aa57265b7162a Mon Sep 17 00:00:00 2001 From: Lucas Soares Date: Tue, 27 Oct 2026 13:57:37 -0300 Subject: [PATCH 1/2] Introduce sap qos class to auditlog --- src/sap_cloud_sdk/core/auditlog_ng/client.py | 5 +++++ src/sap_cloud_sdk/core/telemetry/constants.py | 4 ++++ tests/core/unit/auditlog_ng/unit/test_client.py | 10 +++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/sap_cloud_sdk/core/auditlog_ng/client.py b/src/sap_cloud_sdk/core/auditlog_ng/client.py index 0de95f17..196ca2e9 100644 --- a/src/sap_cloud_sdk/core/auditlog_ng/client.py +++ b/src/sap_cloud_sdk/core/auditlog_ng/client.py @@ -38,6 +38,10 @@ from sap_cloud_sdk.core.auditlog_ng.exceptions import ValidationError from sap_cloud_sdk.core.telemetry import Module, Operation, record_metrics from sap_cloud_sdk.core.telemetry.config import ENV_OTLP_PROTOCOL +from sap_cloud_sdk.core.telemetry.constants import ( + ATTR_SAP_QOS_CLASS, + QOS_CLASS_AT_LEAST_ONCE, +) from sap_cloud_sdk.core.runtime_context import get_context from sap_cloud_sdk.core.runtime_context.providers import APP_TENANT_ID, USER_ID from sap_cloud_sdk.ias._context import get_auth_context @@ -249,6 +253,7 @@ def send( "cloudevents.event_id": event_id, "sap.tenancy.tenant_id": tenant_id, "sap.auditlogging.mime_type": mime_type, + ATTR_SAP_QOS_CLASS: QOS_CLASS_AT_LEAST_ONCE, }, ) diff --git a/src/sap_cloud_sdk/core/telemetry/constants.py b/src/sap_cloud_sdk/core/telemetry/constants.py index fdc17890..8138c421 100644 --- a/src/sap_cloud_sdk/core/telemetry/constants.py +++ b/src/sap_cloud_sdk/core/telemetry/constants.py @@ -26,6 +26,10 @@ ATTR_SAP_SDK_VERSION = "sap.cloud_sdk.version" ATTR_SAP_SOLUTION_AREA = "sap.solution_area" +# Attribute keys - SAP QoS (quality of service) +ATTR_SAP_QOS_CLASS = "sap.qos.class" +QOS_CLASS_AT_LEAST_ONCE = "at_least_once" + # Attribute keys - MLflow ATTR_MLFLOW_EXPERIMENT_ID = "mlflow.experiment_id" diff --git a/tests/core/unit/auditlog_ng/unit/test_client.py b/tests/core/unit/auditlog_ng/unit/test_client.py index 8d22a882..d2e617c6 100644 --- a/tests/core/unit/auditlog_ng/unit/test_client.py +++ b/tests/core/unit/auditlog_ng/unit/test_client.py @@ -8,11 +8,18 @@ import pytest -from sap_cloud_sdk.core.auditlog_ng.client import AuditClient, _fill_common_from_auth_context +from sap_cloud_sdk.core.auditlog_ng.client import ( + AuditClient, + _fill_common_from_auth_context, +) from sap_cloud_sdk.core.auditlog_ng.config import AuditLogNGConfig, SCHEMA_URL from sap_cloud_sdk.core.auditlog_ng.exceptions import ValidationError from sap_cloud_sdk.core.auditlog_ng.gen.sap.auditlog.auditevent.v2 import auditevent_pb2 as pb from sap_cloud_sdk.core.telemetry import Module, Operation +from sap_cloud_sdk.core.telemetry.constants import ( + ATTR_SAP_QOS_CLASS, + QOS_CLASS_AT_LEAST_ONCE, +) from sap_cloud_sdk.ias._context import set_auth_context @@ -177,6 +184,7 @@ def test_send_binary_success(self): == "application/protobuf" ) assert kwargs["attributes"]["sap.tenancy.tenant_id"] == "tenant-123" + assert kwargs["attributes"][ATTR_SAP_QOS_CLASS] == QOS_CLASS_AT_LEAST_ONCE assert "cloudevents.event_id" in kwargs["attributes"] finally: patcher.stop() From d4f29f60778b74c5718ae447d9c6b922e739569e Mon Sep 17 00:00:00 2001 From: Lucas Soares Date: Tue, 27 Oct 2026 14:19:06 -0300 Subject: [PATCH 2/2] docs and tests --- src/sap_cloud_sdk/core/auditlog_ng/user-guide.md | 3 +++ tests/core/unit/auditlog_ng/unit/test_client.py | 1 + 2 files changed, 4 insertions(+) diff --git a/src/sap_cloud_sdk/core/auditlog_ng/user-guide.md b/src/sap_cloud_sdk/core/auditlog_ng/user-guide.md index 5021b9f4..d044722b 100644 --- a/src/sap_cloud_sdk/core/auditlog_ng/user-guide.md +++ b/src/sap_cloud_sdk/core/auditlog_ng/user-guide.md @@ -133,6 +133,9 @@ print(f"Sent event with ID: {event_id}") event_id = client.send_json(event) ``` +> **Note:** Every emitted LogRecord carries a fixed `sap.qos.class` attribute set to +> `at_least_once`. The value is always set by the SDK and is not configurable. + ### Close the Client Always close the client when the agent shuts down to flush pending events: diff --git a/tests/core/unit/auditlog_ng/unit/test_client.py b/tests/core/unit/auditlog_ng/unit/test_client.py index d2e617c6..af77c61e 100644 --- a/tests/core/unit/auditlog_ng/unit/test_client.py +++ b/tests/core/unit/auditlog_ng/unit/test_client.py @@ -202,6 +202,7 @@ def test_send_json_success(self): assert ( kwargs["attributes"]["sap.auditlogging.mime_type"] == "application/json" ) + assert kwargs["attributes"][ATTR_SAP_QOS_CLASS] == QOS_CLASS_AT_LEAST_ONCE assert isinstance(kwargs["body"], str) finally: patcher.stop()