You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The API server does not have a correlation / trace id to allow root cause analysis in the logs.
For example, the following 2 statements belong to the same request, yet they appear completely unrelated on first reading.
In addition, an optional external correlation id (i.e. defined by the client) will allow the debugging of complex interaction scenarios.
E.g. a number printed in the UI of the app, which users could quote to support to facilitate investigations.
For these reasons, this issue will create 2 correlation ids:
Accept an optional request header X-Correlation-Id.
If defined, use that value in the context as correlation_id. If not defined, ignore.
Also initialize an internal UUID and set in context. This will become the int_correlation_id.
In the middleware create a clone of the SuggaredLogger and standard Logger with the logging fields correlation-id and int_correlation_id (be careful of not creating a child that will not be GC'ed). Ensure that the logger emits logs with the new fields as standard.
Ensure that the code is using the cloned logger across the codebase.
The server returns the external correlation id as header X-Correlation-Id in the response (if defined).
Document the standard request/response header X-Correlation-Id in swagger_gen.go; ensure the header appears in the generated Swagger doc.
Unit tests for the external correlation id support
Unit tests for the internal correlation id support.
The text was updated successfully, but these errors were encountered:
The scope of the task needs to be expanded, b/c of how our logging is setup.
There is a logging middleware function inside utils logging.LogRequest, which also needs to be updated.
Lazily look for a logger in context. If it exists, use that. If it does not and no explicit logger defined, panic. This can be an overloaded or separate function.
Move the correlation id middleware and GetLoggerFromContext to utils.
Use context logger in remaining locations of api-server (e.g. GetNumbersByAddress)
The API server does not have a correlation / trace id to allow root cause analysis in the logs.
For example, the following 2 statements belong to the same request, yet they appear completely unrelated on first reading.
In addition, an optional external correlation id (i.e. defined by the client) will allow the debugging of complex interaction scenarios.
E.g. a number printed in the UI of the app, which users could quote to support to facilitate investigations.
For these reasons, this issue will create 2 correlation ids:
int_correlation_id
), andcorrelation_id
)DoD
X-Correlation-Id
.If defined, use that value in the context as
correlation_id
. If not defined, ignore.int_correlation_id
.SuggaredLogger
and standardLogger
with the logging fieldscorrelation-id
andint_correlation_id
(be careful of not creating a child that will not be GC'ed). Ensure that the logger emits logs with the new fields as standard.X-Correlation-Id
in the response (if defined).X-Correlation-Id
inswagger_gen.go
; ensure the header appears in the generated Swagger doc.The text was updated successfully, but these errors were encountered: