USACE / USACE/cwms-data-api

Implement support for generated and user provided Trace Id

Open
#1,666 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Java
Stars
28
Forks
25
Avg merge
4d 22h
Merged PRs (30d)
20

Description

Is your feature request related to a problem? Please describe.
Diagnosing issues across systems can be quite difficult, allowing a user request to provide a UUID as a Trace-ID will allow various applications and usages to Better gather logs.

Additionally, while the incident identifier is useful for getting the spot of error, a trace id would make it easier to assosciate all log messages from the start to that point.

Describe the solution you'd like

  • If not provided Generate a Trace-ID to use in the current request, including passing to threads.
  • Take the Trace Id from the X-Trace-ID header and use it for the session, if valid.

Describe alternatives you've considered
Keep guessing which messages are for who?

Additional context

  • Slf4j provides a ThreadLocal "MappedDiagnosticContext", Flogger provides instances of a ScopedContext. I'm not sure how to go about this for Flogger, at least with Javalin, we will likely need to take care to put it in the Javalin Context object and use it when appropriate.

  • OpenDCS recently did this using SLF4j https://github.com/opendcs/opendcs/pull/1845

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how Javalin handles the request Context and how Flogger logging context is applied, using the X-Trace-ID header and the issue's ScopedContext discussion as the starting points. Done means a valid supplied ID is used for the session, otherwise an ID is generated and propagated to request threads and associated log messages.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, observability
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.