Skip to content

feat(cloudwatch): add CloudWatch client - #4219

Open
thisisabhash wants to merge 8 commits into
mainfrom
feat/v3-cloudwatch-client
Open

feat(cloudwatch): add CloudWatch client#4219
thisisabhash wants to merge 8 commits into
mainfrom
feat/v3-cloudwatch-client

Conversation

@thisisabhash

@thisisabhash thisisabhash commented May 8, 2026

Copy link
Copy Markdown
Member

Issue #

NA

Description

What Changed

New: AmplifyCloudWatchLoggingClient

  • Standalone client conforming to AmplifyFoundation.LogSinkBehavior
  • Namespace-based logging with automatic batching and local file persistence
  • Configurable flush strategy, log level constraints, and per-user filtering
  • Single shared CloudWatchLogsClient instance (created once in init)
  • Per-client file isolation via storagePathIdentifier (prevents collisions between multiple client instances)
  • Per-client CloudWatch stream isolation (stream name includes client identifier)
  • Combine-based events publisher for observing flush/write failures
  • @_spi(AmplifyExperimental) public API surface

New: InternalCloudWatchLogging shared module

  • Extracted common infrastructure used by both the plugin and client:
    • LogFile, LogRotation, LogActor (persistence)
    • LogBatch, LogBatchConsumer, LogBatchProducer, LogEntryRepresentable (protocols)
    • LoggingNetworkMonitor (network connectivity)
    • CloudWatchConstants (SDK limits)
  • All APIs use package access level
  • Plugin and client both depend on this module

Modified: AWSCloudWatchLoggingPlugin

  • Now imports InternalCloudWatchLogging for shared persistence and networking types
  • Removed duplicated files (replaced with shared module imports)
  • Restored original AWSCloudWatchLoggingMonitorDelegate public API
  • No behavior changes

Tests

  • 50+ unit tests for the client covering: LogEntry, LogFile, LogRotation, LogActor, RotatingLogger, RotatingLogBatch, CloudWatchLoggingConsumer, CloudWatchLoggingFilter, CloudWatchLoggingMonitor, session isolation, and the client class itself
  • Integration test host app with tests for flush, enable/disable, and multi-client stream isolation
  • All existing plugin tests pass (59/60, 1 pre-existing flaky timeout)
  • Added AmplifyCloudWatchLoggingClient to CI unit test workflow

Package.swift

  • New targets: InternalCloudWatchLogging, AmplifyCloudWatchLoggingClient (updated), AmplifyCloudWatchLoggingClientTests
  • New library product: AmplifyCloudWatchLoggingClient
  • Updated dependencies for AWSCloudWatchLoggingPlugin and AWSCloudWatchLoggingPluginTests

Testing

  • swift test --filter AmplifyCloudWatchLoggingClientTests — 50+ tests, all pass
  • swift test --filter AWSCloudWatchLoggingPluginTests — 60 tests, 59 pass (1 pre-existing flaky timeout)
  • Integration tests verified manually via Xcode host app

Directory Structure

AmplifyClients/AmplifyCloudWatchLoggingClient/
├── Sources/
│   ├── AmplifyCloudWatchLoggingClient.swift
│   ├── CloudWatchLoggingError.swift
│   ├── CloudWatchLoggingSession.swift
│   ├── CloudWatchLoggingSessionController.swift
│   ├── CloudWatchLogsClientProtocol.swift
│   ├── Configuration/
│   ├── Consumer/
│   ├── Domain/
│   ├── Persistence/
│   ├── Producer/
│   └── Support/
├── Tests/
│   ├── UnitTests/
│   └── IntegrationTests/CloudWatchLoggingClientHostApp/

AmplifyPlugins/Internal/Sources/InternalCloudWatchLogging/
├── Domain/ (LogBatch, LogBatchConsumer, LogBatchProducer, LogEntryRepresentable)
├── Persistence/ (LogActor, LogFile, LogRotation)
└── Support/ (CloudWatchConstants, LoggingNetworkMonitor)

General Checklist

  • Added new tests to cover change, if needed
  • Build succeeds with all target using Swift Package Manager
  • All unit tests pass
  • All integration tests pass
  • Security oriented best practices and standards are followed (e.g. using input sanitization, principle of least privilege, etc)
  • Documentation update for the change if required
  • PR title conforms to conventional commit style
  • New or updated tests include Given When Then inline code documentation and are named accordingly testThing_condition_expectation()
  • If breaking change, documentation/changelog update with migration instructions

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@thisisabhash
thisisabhash requested a review from a team as a code owner May 8, 2026 23:50
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash temporarily deployed to IntegrationTest May 8, 2026 23:50 — with GitHub Actions Inactive
@thisisabhash
thisisabhash marked this pull request as draft May 8, 2026 23:50
@thisisabhash
thisisabhash marked this pull request as ready for review August 10, 2026 17:29
thisisabhash and others added 8 commits August 11, 2026 09:29
* feat(logging): add v3 cloudwatch @SPI definitions

* add privacyinfo
* feat(logging): add v3 cloudwatch @SPI definitions

* add privacyinfo

* chore(logging): move shared code to internal module

* fix unit tests

---------

Co-authored-by: Harsh <6162866+harsh62@users.noreply.github.com>
* feat(logging): add v3 cloudwatch @SPI definitions

* add privacyinfo

* chore(logging): move shared code to internal module

* fix unit tests

* feat(logging): add implementation for cloudwatch client

---------

Co-authored-by: Harsh <6162866+harsh62@users.noreply.github.com>
* feat(logging): add v3 cloudwatch @SPI definitions

* add privacyinfo

* chore(logging): move shared code to internal module

* fix unit tests

* feat(logging): add implementation for cloudwatch client

* chore(logging): add unit tests for cloudwatch client

---------

Co-authored-by: Harsh <6162866+harsh62@users.noreply.github.com>
…ild warnings (#4215)

* feat(logging): add v3 cloudwatch @SPI definitions

* add privacyinfo

* chore(logging): move shared code to internal module

* fix unit tests

* feat(logging): add implementation for cloudwatch client

* chore(logging): add unit tests for cloudwatch client

* chore(logging): refactor code to use shared sdk client

* update code

* chore(logging): add integration tests for cloudwatch client (#4216)
* chore(logging): use unique identifier per client for log streams and local storage path

* enable unit tests in ci/cd

* revert storage path identifier changes

* fix swiftformat issues

* enable flaky test and add doc comments

* update Package.resolved
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.

1 participant