Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: capture message attributes for flow logs #79

Merged
merged 11 commits into from
Dec 19, 2024

Conversation

adesjardin
Copy link
Contributor

@adesjardin adesjardin commented Dec 4, 2024

Closes #78

Here's how it looks in studio
image

Validations:

Either "Attributes expression text" or "Message expression text" should be present while defining the flow-log-configuration
configuration xml:
<avio-logger:flow-log-configs> <avio-logger:flow-logs-config flowName="logger*" messageExpressionText="attributes.headers"/> </avio-logger:flow-log-configs>

Error handling

  • When both the expression attributes are not defined, while building the application logger throws "IllegalStateException" with this exception message "One of attributesExpressionText or messageExpressionText must be defined in flow-logs-config"
image - When `messageExressionText` is defined and resolved to an Object other than String type it will throw `ClassCastException` with message `Message expression text in flow-log-config needs to be a String` image

How it Works

  • When everything is configured correctly
image `Message expression text` that is resolved as String will be appended to the default flow start logger `Attributes expression text` that is resolved as a Map will be appended to the log message as messageAttributes `com.avioconsulting.api.flow: {timestamp=2024-12-18T21:30:22.533Z, appName=logger-testFlow, appVersion=1.0.0, env=local, correlationId=499f0e51-bd87-11ef-a32d-4eb0274c4a15, message=Flow [logger-testFlow1] start Queue-stuff, messageAttributes={host=localhost:8082, cache-control=no-cache, user-agent=PostmanRuntime/7.29.0, postman-token=8cc87bf8-aa82-48c2-8561-11504d54730a, connection=keep-alive, accept=*/*, accept-encoding=gzip, deflate, br}, exception={statusCode=null, detail=null}, location={component=flow, rootContainer=logger-testFlow1, location=logger-testFlow1, fileName=logger-test.xml, lineInFile=45}}` `com.avioconsulting.api.flow: {timestamp=2024-12-18T21:30:22.538Z, appName=logger-testFlow, appVersion=1.0.0, env=local, correlationId=499f0e51-bd87-11ef-a32d-4eb0274c4a15, message=Flow [logger-testFlow1] end, messageAttributes={host=localhost:8082, cache-control=no-cache, user-agent=PostmanRuntime/7.29.0, postman-token=8cc87bf8-aa82-48c2-8561-11504d54730a, connection=keep-alive, accept=*/*, accept-encoding=gzip, deflate, br}, exception={statusCode=null, detail=null}, location={component=flow, rootContainer=logger-testFlow1, location=logger-testFlow1, fileName=logger-test.xml, lineInFile=45}}`
  • flowName accepts wildCards either at the start or at the end example mq-listener* or *mq-listener or * for every Flow

Copy link
Contributor

github-actions bot commented Dec 4, 2024

Test Results

12 tests  ±0   11 ✅ ±0   16s ⏱️ -3s
 4 suites ±0    1 💤 ±0 
 4 files   ±0    0 ❌ ±0 

Results for commit bea33c0. ± Comparison against base commit 2098536.

♻️ This comment has been updated with latest results.

@anilkonakalla anilkonakalla marked this pull request as ready for review December 11, 2024 21:42
@anilkonakalla anilkonakalla requested a review from a team as a code owner December 11, 2024 21:42
@manikmagar manikmagar merged commit effe54e into main Dec 19, 2024
7 checks passed
@manikmagar manikmagar deleted the feat/flow-log-attributes branch December 19, 2024 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Capture additional log data in flow notification logs
3 participants