CDCgov / prime-reportstream

ReportStream is a public intermediary tool for delivery of data between different parts of the healthcare ecosystem.
https://reportstream.cdc.gov
Creative Commons Zero v1.0 Universal
65 stars 39 forks source link

Add withLoggingContext to Azure Functions #13923

Open arnejduranovic opened 3 months ago

arnejduranovic commented 3 months ago

User Story

As an en engineer of ReportStream, I want all log messages to be enriched with metadata, so that I can more easily debug issues when going through the logs.

Description/Use Case

By wrapping each azure function's .doWork method with withContext, we can enrich each log message with relevant metadata. See FHIRTranslator for example:

val contextMap = mapOf(
            MDCUtils.MDCProperty.ACTION_NAME to actionHistory.action.actionName.name,
            MDCUtils.MDCProperty.REPORT_ID to message.reportId,
            MDCUtils.MDCProperty.TOPIC to message.topic,
            MDCUtils.MDCProperty.BLOB_URL to message.blobURL
        )
        withLoggingContext(contextMap) {
        ... // any log message here will be enriched with the properties defined in the contextMap
        }

Dev Notes

There are a lot of Azure functions. Prioritize the Universal Pipeline Functions. Others will have to be evaluated to see which ones would benefit from withLoggingContext.

Acceptance Criteria

Andrey-Glazkv commented 2 months ago

Hey team! Please add your planning poker estimate with Zenhub @adegolier @arnejduranovic @brick-green @jack-h-wang @jalbinson @JFisk42 @mkalish @thetaurean