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

[WOR-1560] WSM uses Stairway 1.0.0's native MDC support #1666

Merged
merged 9 commits into from
Mar 20, 2024

Conversation

okotsopoulos
Copy link
Contributor

@okotsopoulos okotsopoulos commented Mar 7, 2024

https://broadworkbench.atlassian.net/browse/WOR-1560

Objective

WSM uses Stairway 1.0.0's native MDC (mapped diagnostic context) support, rather than populating the log MDC itself on flight state transitions.

How?

To achieve this, I first upgraded to the latest terra-common-lib, from which we get our Stairway dependency. Then I was able to drastically simplify our MdcHook: it is now StairwayLoggingHook, and does what it says on the tin (supplement logging on notable state transitions). I removed now-unused code, including cleaning up JobBuilder's job initialization which no longer has to serialize the calling thread's MDC and write it to the input map.

Because this TCL version got rid of Flagsmith, and WSM used Flagsmith in its user-level feature flagging (a Verily artifact), I excised Flagsmith from our repo to allow this upgrade and ticketed further clean-up here (we discussed in refinement that we wanted to fully remove AWS code from the repo): https://broadworkbench.atlassian.net/browse/WOR-1559

Other Dependency Upgrades

I had some trouble with dependencies straight out of the box: OTEL dependencies, and a Google BOM conflict within our repo.

I learned that Spring Boot Dependency Manager for Spring Boot 3.1.2 pulls in opentelemetry-bom:1.25.0 as a dependency.

Using the BOM (bill of materials) to manage OTEL dependencies is preferred to managing them individually: the BOM makes sure that they remain compatible with one another.

The only OTEL dependencies that WSM needs to define directly are:

  1. opentelemetry-api so that we can construct OpenTelemetry objects (versioned by the BOM, which is itself versioned by Spring Boot dependency manager)
  2. opentelemetry-instrumentation-annotations so that we can use the @WithSpan annotation (not versioned by the BOM)

terra-common-lib defines the OTEL deps it needs, they are available as runtime dependencies so we don't need to redefine them. But it does not use the BOM to version them, or Spring Boot dependency manager... it versions them directly at 1.34.1 (and 2.0.0 for instrumentation).

I found when removing the OTEL deps that WSM didn't need, I also needed to instruct our Spring Boot dependency manager to pin opentelemetry-bom to a higher version compatible with TCL's OTEL dependencies.

Demonstration

I deployed the latest version of this feature branch to my Bee, and triggered a flight. The resulting logs have their jsonPayload populated as we'd expect:

  • Calling thread's context over the entirety of the flight (that's where jsonPayload.requestId comes from)
  • Flight-specific context over the entirety of the flight
  • Step-specific context over the entirety of each step

A jsonPayload for a log emitted during a step:
Screenshot 2024-03-18 at 1 00 39 PM

All logs for the request, with flightId and flightStepNumber added to the summary line:

Screenshot 2024-03-18 at 1 02 08 PM

This is now enabled as needed via TCL's terra.common.tracing.stackdriverExportEnabled property.
TCL upgrade will have removed it.  All of our AWS functionality is unsupported, so default to disabled.
Ticket to fully clean up FeatureService and related code: WOR-1559
This required OTEL dependency upgrades for bootRun to work, following DataBiosphere/terra-common-lib#131
Is there a better way to get these from TCL without redefining them downstream?
MdcHook is greatly reduced and renamed to StairwayLoggingHook: it now only logs at notable state transitions.
This now matches the integration version as well as the version in TCL.
@okotsopoulos okotsopoulos marked this pull request as ready for review March 18, 2024 17:07
@okotsopoulos okotsopoulos requested a review from a team as a code owner March 18, 2024 17:07
@okotsopoulos okotsopoulos requested review from cahrens and aherbst-broad and removed request for a team March 18, 2024 17:07
@blakery blakery self-requested a review March 18, 2024 17:16
Copy link
Contributor

@blakery blakery left a comment

Choose a reason for hiding this comment

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

Sorry - I went through everything yesterday, but forgot to hit the button!

I learned that Spring Boot Dependency Manager pulls in opentelemetry-bom as a dependency.
For our Spring Boot version 3.1.2, opentelemetry-bom has version 1.25.0.
Using the BOM (bill of materials) to manage OTEL dependencies is preferred to managing them individually: the BOM makes sure that they remain compatible with one another.
The only OTEL dependencies that WSM needs to define directly are:
1. opentelemetry-api so that we can construct OpenTelemetry objects (versioned by the BOM, which is itself versioned by Spring Boot dependency manager)
2. opentelemetry-instrumentation-annotations so that we can use the @WithSpan annotation

terra-common-lib defines the OTEL deps it needs, they are available as runtime dependencies so we don't need to redefine them.
But it does not use the BOM to version them, or Spring Boot dependency manager.  It versions them directly at 1.34.1.
I found when removing the OTEL deps that WSM didn't need, I also needed to instruct our Spring Boot dependency manager to pin opentelemetry-bom at a higher version
compatible with TCL's OTEL dependencies.
@okotsopoulos okotsopoulos force-pushed the okotsopo-WOR-1560-stairway-native-mdc branch from eda6738 to 8aef8d6 Compare March 20, 2024 17:15
Copy link

sonarcloud bot commented Mar 20, 2024

Please retry analysis of this Pull-Request directly on SonarCloud

After merging in the main branch, I noticed that our Google BOM versions have again diverged.
There is a wider mystery here as to why Dependabot is not picking up on some dependencies, but for now, bringing this one up to date.
Copy link

sonarcloud bot commented Mar 20, 2024

Copy link

sonarcloud bot commented Mar 20, 2024

@okotsopoulos okotsopoulos merged commit c051847 into main Mar 20, 2024
19 checks passed
@okotsopoulos okotsopoulos deleted the okotsopo-WOR-1560-stairway-native-mdc branch March 20, 2024 18:38
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.

3 participants