Skip to content

fix: record auditlog ng telemetry on client initialization#139

Merged
tiagoek merged 3 commits into
mainfrom
fix-auditlog-ng-telemetry
May 27, 2026
Merged

fix: record auditlog ng telemetry on client initialization#139
tiagoek merged 3 commits into
mainfrom
fix-auditlog-ng-telemetry

Conversation

@tiagoek
Copy link
Copy Markdown
Contributor

@tiagoek tiagoek commented May 26, 2026

Disclaimer: Do not include SAP-internal or customer-specific information in this PR (e.g. internal system URLs, customer names, tenant IDs, or confidential configurations). This is a public repository.

Description

Moves the ALS v3 (auditlog_ng) AUDITLOG_CREATE_CLIENT capability metric from the public factory wrapper to the shared AuditClient initialization path. This keeps the signal as client/capability initialization rather than audit-event volume, while ensuring direct AuditClient(config) construction emits the same SDK usage telemetry as create_client(config=...).

The factory still records error metrics for validation/configuration failures that happen before AuditClient can be initialized, preserving the previous error telemetry behavior. The package version is bumped to 0.20.2.

Related Issue

Internal tracking: AFSDK-3392

Type of Change

Please check the relevant option:

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Code refactoring
  • Dependency update

How to Test

  1. Run focused telemetry and auditlog NG tests:
    uv run pytest tests/core/unit/test_version.py tests/core/unit/auditlog_ng/unit/test_create_client.py tests/core/unit/auditlog_ng/unit/test_client.py tests/core/unit/telemetry/test_metrics_decorator.py -q
  2. Run non-integration unit tests:
    uv run pytest tests -m 'not integration' -q
  3. Run lint/type/build checks:
    uv run ruff check pyproject.toml src/sap_cloud_sdk/core/auditlog_ng/__init__.py src/sap_cloud_sdk/core/auditlog_ng/client.py src/sap_cloud_sdk/core/telemetry/metrics_decorator.py tests/core/unit/auditlog_ng/unit/test_create_client.py tests/core/unit/auditlog_ng/unit/test_client.py tests/core/unit/telemetry/test_metrics_decorator.py
    uv run ty check
    uv build
  4. Run integration checks with configured service bindings:
    uv run pytest tests/core/integration/auditlog -q
    uv run pytest tests -m integration --ignore=tests/destination/integration -q

Expected result: direct AuditClient(config) and factory-created clients both record exactly one auditlog_ng/create_client capability metric on successful initialization, without instrumenting send() or send_json().

Checklist

Before submitting your PR, please review and check the following:

  • I have read the Contributing Guidelines
  • I have verified that my changes solve the issue
  • I have added/updated automated tests to cover my changes
  • All tests pass locally
  • I have verified that my code follows the Code Guidelines
  • I have updated documentation (if applicable)
  • I have added type hints for all public APIs
  • My code does not contain sensitive information (credentials, tokens, etc.)
  • I have followed Conventional Commits for commit messages

Breaking Changes

None.

Additional Notes

send() and send_json() remain uninstrumented intentionally. The dashboard signal should represent ALS v3 capability/client initialization, not audit event volume.

Local verification performed:

  • 53 passed for focused version/auditlog NG/telemetry tests.
  • 2098 passed, 125 deselected for non-integration tests.
  • 21 passed for AuditLog integration tests with configured bindings.
  • 65 passed, 31 skipped for integration tests excluding Destination.
  • uv run ty check completed with only pre-existing DMS integration warnings.
  • uv build produced sap_cloud_sdk-0.20.2 sdist and wheel.

Full integration was also executed; remaining failures were limited to known Destination integration scenarios and are unrelated to ALS v3 telemetry.

@tiagoek tiagoek marked this pull request as ready for review May 26, 2026 19:28
@tiagoek tiagoek requested a review from a team as a code owner May 26, 2026 19:28
Comment thread CHANGELOG.md Outdated
Comment thread src/sap_cloud_sdk/core/auditlog_ng/__init__.py Outdated
Copy link
Copy Markdown
Member

@jeanscherf jeanscherf left a comment

Choose a reason for hiding this comment

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

Great work!

@tiagoek tiagoek merged commit 08466b2 into main May 27, 2026
10 of 11 checks passed
@tiagoek tiagoek deleted the fix-auditlog-ng-telemetry branch May 27, 2026 13:50
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