Skip to content

Conversation

@Anmol1696
Copy link
Contributor

@Anmol1696 Anmol1696 commented Dec 23, 2025

This pull request introduces enhanced logging and configuration flexibility for both the send-email-link and knative-job-fn services. The main improvements are better observability of job requests and error handling in knative-job-fn, and added support for custom host headers in GraphQL client creation in send-email-link. These changes aid in debugging, traceability, and deployment flexibility.

Enhanced logging and observability in knative-job-fn:

  • Added middleware to log incoming job requests, including relevant headers and a snapshot of the request body, improving traceability and debugging of job invocations.
  • Added logging when a job function completes, capturing worker, job, and database IDs along with the status code.
  • Improved error logging by capturing and outputting detailed error context, including headers, error message, stack trace, and GraphQL response details if available.

GraphQL client configuration improvements in send-email-link:

  • Modified createGraphQLClient to accept an optional environment variable name for the host header, allowing different host headers for different GraphQL endpoints.
  • Updated GraphQL client instantiation to use the appropriate host header environment variables for both the main and meta GraphQL clients.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds comprehensive logging middleware to the knative-job-fn service and introduces support for custom host headers in the send-email-link function's GraphQL clients.

  • Added request/response logging middleware to track incoming job invocations and their completion status
  • Enhanced error logging to capture full error context including GraphQL response details
  • Extended createGraphQLClient to support configurable host headers via environment variables

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
jobs/knative-job-fn/src/index.ts Added three logging points: incoming request middleware, function completion logging, and enhanced error context logging for better observability
functions/send-email-link/src/index.ts Modified createGraphQLClient to accept optional host header environment variable name, enabling separate host header configuration for main and meta GraphQL clients

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +226 to +231
const headers = {
'x-worker-id': req.get('X-Worker-Id'),
'x-job-id': req.get('X-Job-Id'),
'x-database-id': req.get('X-Database-Id'),
'x-callback-url': req.get('X-Callback-Url')
};
Copy link

Copilot AI Dec 23, 2025

Choose a reason for hiding this comment

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

The header extraction logic is duplicated between the request logging middleware (lines 24-29) and the error logging handler (lines 226-231). Consider extracting this into a shared helper function to improve maintainability and ensure consistency.

Copilot uses AI. Check for mistakes.
@Anmol1696 Anmol1696 force-pushed the anmol/fix-function-job branch from 617a5e3 to 964e9d2 Compare December 24, 2025 07:27
@Anmol1696 Anmol1696 merged commit 1fe093a into main Dec 24, 2025
33 checks passed
@Anmol1696 Anmol1696 deleted the anmol/fix-function-job branch December 24, 2025 07:57
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