Skip to content

Conversation

@HollywoodTonight
Copy link
Contributor

Overview

Adds end-to-end trace ID propagation across SpaceCat services, enabling distributed tracing for debugging and monitoring.

Changes

1. Log Wrapper Enhancement (spacecat-shared-utils)

  • Enhanced logWrapper to automatically include traceId in log messages
  • Extracts trace ID from AWS X-Ray or context for correlation

2. SQS Message Propagation (spacecat-shared-utils)

  • sendMessage() automatically includes traceId in message payload
  • sqsEventAdapter() extracts traceId from incoming messages and stores in context.traceId

3. HTTP Header Support (spacecat-shared-http-utils)

  • enrichPathInfo() extracts x-trace-id header from incoming HTTP requests
  • Stores trace ID in context.traceId for propagation

4. New Utility Function (spacecat-shared-utils)

  • addTraceIdHeader(headers, context) - Helper to add x-trace-id to outgoing HTTP requests
  • Exported from @adobe/spacecat-shared-utils

HollywoodTonight and others added 3 commits November 4, 2025 13:00
- Add getTraceId() function to extract AWS X-Ray trace IDs
- Enhance logWrapper to include both jobId and traceId in logs
- Add comprehensive test coverage for trace ID functionality
- Update TypeScript definitions
- Update README with trace ID documentation
@github-actions
Copy link

github-actions bot commented Nov 6, 2025

This PR will trigger a minor release when merged.

@HollywoodTonight HollywoodTonight requested a review from a team November 6, 2025 13:05
HollywoodTonight and others added 4 commits November 6, 2025 15:27
- Handle explicit traceId: null to opt-out of trace propagation
- Jobs Dispatcher can send individual job messages without shared traceId
- Each downstream Lambda will generate its own X-Ray trace
- Add test case for opt-out behavior
Copy link
Contributor

@iuliag iuliag left a comment

Choose a reason for hiding this comment

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

See adobe/spacecat-audit-worker#1506 (review)
What if the traceId marker is added directly to log and contextualLog is left as it was before (since we don't know the reasoning behind why it was introduced like this by the Import as a Service team)?
@solaris007 any veto against this approach?

…logging

- Modify logWrapper to enhance context.log in place instead of creating contextualLog
- No code changes needed in consuming services - existing context.log calls automatically include trace IDs
- Set context.contextualLog as an alias for backward compatibility check
- Update tests to verify context.log is enhanced directly
- Update README to clarify no code changes are needed

This addresses reviewer feedback to make trace ID inclusion transparent without requiring code changes throughout the codebase.
@HollywoodTonight
Copy link
Contributor Author

I've been hasty and already did the changes 😃

@solaris007
Copy link
Member

looking good now i think :)

i'd go a step further:

  • a common request is that "services" or "components" could be identified, e.g. for api-service the individual controller, or in the audit worker the individual handler, etc.
  • make sure that on coralogix all dashboard queries that may break with this change are adjusted...

@iuliag
Copy link
Contributor

iuliag commented Nov 19, 2025

Add the above for iteration 2: https://wiki.corp.adobe.com/display/AEMSites/AEM+Sites+Optimizer+-+Tracing#AEMSitesOptimizerTracing-Iteration2

@HollywoodTonight HollywoodTonight merged commit ed1fb61 into main Nov 20, 2025
7 checks passed
@HollywoodTonight HollywoodTonight deleted the LLMO-1023-atudoran branch November 20, 2025 08:55
HollywoodTonight added a commit that referenced this pull request Nov 20, 2025
This commit triggers the release of PR #1097 which adds end-to-end trace ID propagation:
- Enhanced logWrapper to include traceId in logs
- SQS message propagation of trace IDs
- HTTP header support for x-trace-id
- New addTraceIdHeader utility function

Ref: #1097
HollywoodTonight added a commit that referenced this pull request Nov 20, 2025
This PR triggers the semantic-release for the trace ID propagation
feature that was merged in #1097 but didn't get released due to
incorrect commit message format.

## Changes
- Empty commit with proper `feat:` prefix to trigger release

## Related
- Implements: #1097
- Needed for: adobe/spacecat-audit-worker#1520

Once merged, this will release:
- `@adobe/spacecat-shared-utils@1.76.0` (currently 1.75.0)
- `@adobe/spacecat-shared-http-utils@1.19.0` (currently 1.18.2)
HollywoodTonight added a commit that referenced this pull request Nov 20, 2025
This commit triggers the release for trace ID propagation feature from PR #1097.

Changes include:
- Enhanced logWrapper to automatically include traceId in log messages
- SQS message trace ID propagation via sendMessage/sqsEventAdapter
- HTTP header trace ID extraction via x-trace-id header
- New addTraceIdHeader utility function

This enables end-to-end distributed tracing across SpaceCat services.

Related: #1097, #1152
HollywoodTonight added a commit that referenced this pull request Nov 20, 2025
## Problem

PR #1152 was merged with a proper `feat:` commit message, but
semantic-release did not trigger a release. This happened because:

- **Empty commits are ignored by `semantic-release-monorepo`**
- The monorepo plugin filters commits to only include those that modify
files within each package directory
- Since #1152 was an empty commit with no file changes, it wasn't
associated with any package
- Result: Both `spacecat-shared-utils` and `spacecat-shared-http-utils`
were not released despite having new features from #1097

## Solution

This PR adds documentation updates to both affected packages:
- **`spacecat-shared-utils`**: Added release note for trace ID
propagation
- **`spacecat-shared-http-utils`**: Added release note for trace ID
extraction

The commit includes:
- Proper `feat(utils,http-utils):` prefix following conventional commits
- Actual file modifications in both package directories
- Will be correctly recognized by `semantic-release-monorepo`

## Changes from PR #1097

The original trace ID propagation feature includes:
- Enhanced `logWrapper` to automatically include `traceId` in log
messages
- SQS message trace ID propagation via
`sendMessage()`/`sqsEventAdapter()`
- HTTP header trace ID extraction via `x-trace-id` header
- New `addTraceIdHeader()` utility function

This enables end-to-end distributed tracing across SpaceCat services.

## Expected Releases

Once merged, semantic-release will publish:
- `@adobe/spacecat-shared-utils@1.76.0` (currently 1.75.0)
- `@adobe/spacecat-shared-http-utils@1.19.0` (currently 1.18.2)

## Related

- Implements: #1097
- Supersedes: #1152
- Needed for: adobe/spacecat-audit-worker#1520
solaris007 pushed a commit that referenced this pull request Nov 20, 2025
@solaris007
Copy link
Member

🎉 This PR is included in version @adobe/spacecat-shared-http-utils-v1.19.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

solaris007 pushed a commit that referenced this pull request Nov 20, 2025
@solaris007
Copy link
Member

🎉 This PR is included in version @adobe/spacecat-shared-utils-v1.76.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants