@idpartner/tracing
v0.0.1
Published
This library provides tools for thread-safe tracing.
Downloads
2
Keywords
Readme
@idpartner/tracing
This library provides tools for thread-safe tracing.
Table of Contents
Installation
yarn add @idpartner/tracing
API
tracingStorage
getData(key: string): any
key
: The key for the value to retrieve from the async local storage.- Description: Obtains data from the async local storage using a specified key.
setData(key: string, value: any): void
key
: The key for the value to set in the async local storage.value
: The value to set.- Description: Sets data in the async local storage using a specified key and value.
tracingMiddlewares
retrieveAndSetTracingData(req, res, next): void
req
: The request object.res
: The response object (not used).next
: The next middleware function.- Description: Retrieves the
x-verification-id
andx-fapi-interaction-id
from the request (session, headers, or query) and stores them in the async local storage.
logIncomingRequestWithTracingData(req, res, next): void
req
: The request object.res
: The response object.next
: The next middleware function.- Description: Logs the incoming request along with any available tracing data using Morgan.
tracingRequestInterceptor
addTracingDataToRequestHeaders(config: object): object
config
: The Axios request config object.- Description: Adds an Axios interceptor to inject
x-verification-id
andx-fapi-interaction-id
headers into outgoing requests.
tracingUrl
addTracingData(url: string): string
url
: The URL to which tracing data will be added.- Description: Adds
x-verification-id
andx-fapi-interaction-id
as query parameters to the provided URL.