Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep original VCAP-Request-ID for re-enqueued ReoccurringJobs #3208

Conversation

philippthun
Copy link
Member

All background jobs are wrapped in a LoggingContextJob that stores the original VCAP-Request-ID and ensures that the same ID is used (e.g. for logs) while performing the job.

For ReoccurringJobs, this capability got lost when the job was re-enqueued. Adding the next job to the queue did not happen as part of the perform method, but in the success hook. So by using the with_request_id_set method also for the success hock, the re-enqueued job keeps the original VCAP-Request-ID.

The effect can be seen when looking at logs with source cc.service_broker.v2.http_client. When polling for the last operation state of a provisioned service instance, the VCAP-Request-ID was only set for the initial 'fetch' request (which was done in the same job as the 'provision' request). With this change, all subsequent state polls are also logged with "data":{"request_guid":"original-guid",...}.

  • I have reviewed the contributing guide

  • I have viewed, signed, and submitted the Contributor License Agreement

  • I have made this pull request to the main branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

All background jobs are wrapped in a LoggingContextJob that stores the
original VCAP-Request-ID and ensures that the same ID is used (e.g. for
logs) while performing the job.

For ReoccurringJobs, this capability got lost when the job was
re-enqueued. Adding the next job to the queue did not happen as part of
the 'perform' method, but in the 'success' hook. So by using the
'with_request_id_set' method also for the 'success' hock, the
re-enqueued job keeps the original VCAP-Request-ID.

The effect can be seen when looking at logs with source
cc.service_broker.v2.http_client. When polling for the last operation
state of a provisioned service instance, the VCAP-Request-ID was only
set for the initial 'fetch' request (which was done in the same job as
the 'provision' request). With this change, all subsequent state polls
are also logged with "data":{"request_guid":"original-guid",...}.
Copy link
Contributor

@johha johha left a comment

Choose a reason for hiding this comment

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

lgtm 👍

@philippthun philippthun merged commit 5d6ebe6 into cloudfoundry:main Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants