Uploaded image for project: 'James Server'
  1. James Server
  2. JAMES-3587

Deprecate MDCBuild::addContext

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.6.0
    • 3.7.0
    • James Core
    • None

    Description

      Why?

      MDCBuilder::addContext does an implicit call to Object::toString

      There are two reasons:

      • 1. Formatting. For instance ` {"user":"btellier@erugerkuf"}

        ` instead of simply `btellier@erugerkuf`.

      • 2. Performance.

      See the attached flame graphs: James spends ~1.20% of CPU calling Object::toString which correlate closely to MDCBuilder::addContext. This crosses the "valuable to optimize" threashold. Especially calls to MoreObject::toStringHelper(this) are not neglictible.

      h3 How?

      Deprecate the current API and replace it by an API that explicitly requires String or Optional<String> so that the callers understand that they have to pass a string.

      If they decide to pass toString then they need to explicitly call it, and be fully aware of it. Nothing hidden anymore.

      On the philosophy this mimics SLF4J MDC API.

      Adapt all calls made in James code base to use this newer API.

      Also, StructuredLogger API needs to be adapted too.

      I don't think we should remove the deprecated calls

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            btellier Benoit Tellier
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 20m
                20m

                Slack

                  Issue deployment