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

fix(tracing): Ensure clean MDC context at top coroutine scopes #1845

Merged
merged 4 commits into from
Mar 4, 2021

Conversation

luispollo
Copy link
Contributor

Follow-up to #1841. Following the discussion and recommendations in Kotlin/kotlinx.coroutines#985, this PR adds an empty MDCContext to all top-level coroutine scopes where withTracingContext is used, in an attempt to remove left-over X-SPINNAKER-RESOURCE-IDs when switching threads.

Hopefully fixes #1122.

@@ -15,6 +15,8 @@ class TracingSupport {
companion object {
const val X_SPINNAKER_RESOURCE_ID = "X-SPINNAKER-RESOURCE-ID"

val clearMDC: MDCContext = MDCContext(emptyMap())
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be emptyMDC - when I read it as a parameter I thought it was a function that cleared the mdc context.

Actually, I think any wording for this - "empty", "clean", "clear" would have given me the same thought. Maybe blankMDC? Change if you think that is more helpful or clear, if you don't think it adds anything feel free to ignore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to blankMDC.

@@ -34,13 +34,13 @@ class VerificationRunner(
}

if (statuses.anyStillRunning) {
log.debug("Verification already running for {}", environment.name)
log.debug("Verification already running for environment {} of application {}", environment.name, deliveryConfig.application)
Copy link
Contributor

Choose a reason for hiding this comment

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

ooo thank you thank you

Copy link
Contributor

@emjburns emjburns left a comment

Choose a reason for hiding this comment

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

I hope this fixes things!!!!!!!!!

@luispollo luispollo added the ready to merge Approved and ready for merge label Mar 4, 2021
@mergify mergify bot added the auto merged label Mar 4, 2021
@mergify mergify bot merged commit 935da9b into spinnaker:master Mar 4, 2021
osoriano pushed a commit to osoriano/keel that referenced this pull request Sep 2, 2023
…aker#1845)

* fix(tracing): Ensure clean MDC context at top coroutine scopes

* fix(pr): Rename clearMDC to blankMDC per review

* chore(logs): Improve log message for stale promotion checks

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto merged ready to merge Approved and ready for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

X-SPINNAKER-RESOURCE-ID correlates to wrong resource in logs
2 participants