Skip to content

feat(envelopes): add CloudWatch Logs envelope support#195

Merged
j-d-ha merged 11 commits into
mainfrom
feature/#135-add-CloudWatch-Logs-envelope
Nov 28, 2025
Merged

feat(envelopes): add CloudWatch Logs envelope support#195
j-d-ha merged 11 commits into
mainfrom
feature/#135-add-CloudWatch-Logs-envelope

Conversation

@j-d-ha

@j-d-ha j-d-ha commented Nov 28, 2025

Copy link
Copy Markdown
Collaborator

🚀 Pull Request

📋 Summary

This PR adds comprehensive support for CloudWatch Logs events in AWS Lambda functions through new envelope classes. The implementation provides both a base envelope for raw log data access and a strongly-typed generic envelope for automatic payload deserialization.

Key Features:

  • CloudWatchLogsEnvelope - Base envelope providing access to raw CloudWatch Logs data (gzip-compressed, base64-encoded)
  • CloudWatchLogsEnvelope<T> - Generic envelope with automatic JSON deserialization of log messages to strongly-typed payloads
  • Comprehensive unit tests with 100% code coverage
  • Full XML documentation
  • Sample events and usage examples in README

Related Packages Updated:

  • Updated README files for Kafka, ALB, SNS, and SQS envelopes to maintain consistency
  • Added default JSON serialization options for Lambda in EnvelopeOptions

✅ Checklist

  • My changes build cleanly
  • I've added/updated relevant tests
  • I've added/updated documentation or README
  • I've followed the coding style for this project
  • I've tested the changes locally (if applicable)

🧪 Related Issues or PRs

Closes #135


💬 Notes for Reviewers

Focus Areas:

  • Review the payload extraction logic in CloudWatchLogsEnvelopeBase - it handles base64 decoding and gzip decompression
  • Check the generic deserialization approach in CloudWatchLogsEnvelope<T> for consistency with other envelope implementations
  • Verify the README examples are clear and accurate

Implementation Details:

  • The base class exposes AwsLogs property for the raw CloudWatch Logs data structure
  • The generic version automatically deserializes each log message to the specified payload type
  • Both envelopes handle the CloudWatch Logs specific encoding (base64 + gzip)
  • Default JSON serialization options are now available via EnvelopeOptions.DefaultJsonSerializerOptions

Test Coverage:

  • Unit tests cover all public APIs, edge cases, and error scenarios
  • Tests use AutoFixture with NSubstitute for dependency injection
  • Sample events provided in SAMPLE_EVENTS.md for reference

- Added a new CloudWatch Logs envelope project under `src/Envelopes`.
- Updated the solution file to include the new project.
- Configured project metadata including multi-targeting `.NET 8.0`, `.NET 9.0`, and `.NET 10.0`.
- Added dependencies on `Amazon.Lambda.Core` and related abstractions.
- Included `README.md` with package metadata.
…yload extraction

- Added `CloudWatchLogsEnvelopeBase<T>` as an abstract base for processing CloudWatch Logs events.
- Added `CloudWatchLogsEnvelope<T>` for payload extraction using `System.Text.Json`.
- Introduced `Amazon.Lambda.CloudWatchLogsEvents` v2.2.0 dependency in the project.
- Updated project file with the required package reference.
- Added detailed XML documentation to `CloudWatchLogsEnvelopeBase<T>` and `CloudWatchLogsEnvelope<T>`.
- Documented methods, properties, and classes to improve code clarity and maintainability.
- Included remarks and examples for better understanding of CloudWatch Logs deserialization.
- Introduced `CloudWatchLogsEnvelopeTests` for validating envelope payload extraction and deserialization.
- Covered scenarios including valid data, camel case deserialization, null data, and invalid JSON handling.
- Verified the `JsonIgnore` attribute on `DataContent` property to prevent unintended serialization.
- Enhanced test coverage for `CloudWatchLogsEnvelope` and its derived functionality.
- Updated test project to reference `AwsLambda.Host.Envelopes.CloudWatchLogs` project.
…s events

- Introduced `CloudWatchLogsEnvelope<T>` for deserializing and managing CloudWatch Logs events payloads.
- Added `AwsLambda.Host.Envelopes.CloudWatchLogs` project to the solution file with required dependencies.
- Provided documentation and examples in `README.md` and `SAMPLE_EVENTS.md`.
- Updated example project to reference the new CloudWatch Logs envelope project.
- Included support for custom deserialization through inheritance and extensibility.
- Renamed the launch profile from "Lambda.Host.Example.HelloWorld" to "Local" in `launchSettings.json`.
- Updated the project to align with a consistent naming convention for local debugging.
- Introduced `LambdaDefaultJsonOptions` providing AWS Lambda-specific JSON settings.
- Included default ignore condition, case insensitivity, and AWS-compliant naming policy.
- Added specialized converters for `DateTime`, `MemoryStream`, `ConstantClass`, and byte arrays.
- Enhanced extensibility for handling AWS Lambda event serialization.
…xtraction

- Introduced `CloudWatchLogsEnvelope<T>` for structured log message deserialization.
- Refactored `CloudWatchLogsEnvelopeBase<T>` to support decoded and decompressed payload handling.
- Added `AwsLogsEnvelope` and `LogEventEnvelope` classes for structured data representation.
- Enhanced `ExtractPayload` to handle both plain text and JSON-based log messages efficiently.
…uidance

- Clarified the usage of `CloudWatchLogsEnvelope` and `CloudWatchLogsEnvelope<T>` for log processing.
- Highlighted differences in handling plain string vs. JSON log messages.
- Improved code examples to align with new envelope functionality and corrected placeholders.
- Refined table descriptions to reflect updated class structures and use cases.
- Updated custom deserialization section with clearer explanations and examples.
…udWatchLogsEnvelope<T>`

- Expanded test coverage for both generic and non-generic `ExtractPayload` scenarios.
- Added tests for multiple log events, camel case deserialization, and metadata population.
- Verified proper handling of null message content and invalid JSON scenarios.
- Added inheritance tests to confirm envelopes derive from `CloudWatchLogsEvent`.
- Validated `JsonIgnore` attributes for preventing unintended serialization.
- Standardized the format of "Related Packages" tables across multiple README files.
- Added missing CloudWatch Logs package entry to the tables.
- Improved consistency in package ordering within the tables.
@github-actions github-actions Bot added the type: feat New feature label Nov 28, 2025
@sonarqubecloud

sonarqubecloud Bot commented Nov 28, 2025

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@j-d-ha j-d-ha changed the title feat(cloudwatch-logs): add CloudWatch Logs envelope support feat(envelopes): add CloudWatch Logs envelope support Nov 28, 2025
@j-d-ha
j-d-ha merged commit 82312bf into main Nov 28, 2025
6 of 7 checks passed
@j-d-ha
j-d-ha deleted the feature/#135-add-CloudWatch-Logs-envelope branch November 28, 2025 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feat New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(envelopes): add CloudWatch Logs envelope

1 participant