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

[exporter/syslog] Fix handling of multiple structured data elements #37927

Merged
merged 7 commits into from
Mar 6, 2025

Conversation

peffis
Copy link
Contributor

@peffis peffis commented Feb 14, 2025

Description

As reported in issue #33300 this fixes the issue when there are more than one structured data block in the structured_data attributes object. Say you had a structured block like this:

{
    "structured_data": {
        "a@123": {
            "a": "123"
        },
        "b@321": {
            "b": "321"
        }
    }
}

The expected output would then be two sd blocks, like [a@193 a="123"][b@193 b="321"]
, but instead the code returns one array, like [a@193 a="123" b@193 b="321"] which is wrong according to the
RFC5424

Link to tracking issue

Fixes #33300

Testing

A new test for "more than one SD field" was added in the commit, which failed for the original code, but passes now with the fix.

Documentation

No documentation change needed.

The current syslog exporter does not handle structured data well.
In particular, when there is more than one structured data field,
it will put them all in one structured data block rather than in
one block per field as the RFC5424 suggests.

This test is a test for this error.
…ata block

is built up as its own array (rather than as one single array as
it was done before). String builder (strings.Builder) was used
to buffer the final string that is built up.
@peffis peffis requested review from andrzej-stencel and a team as code owners February 14, 2025 09:54
Copy link

linux-foundation-easycla bot commented Feb 14, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@crobert-1
Copy link
Member

Hello @peffis, thanks for your contribution! To be able to move this PR forward the CLA must be signed. Feel free to reach out if you have any questions!

@peffis
Copy link
Contributor Author

peffis commented Feb 17, 2025

Hello @peffis, thanks for your contribution! To be able to move this PR forward the CLA must be signed. Feel free to reach out if you have any questions!

I think (hope) that is checked off now (took some time for me to get clearance from my company admins)

Copy link
Contributor

@rnishtala-sumo rnishtala-sumo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! thank you for contributing! 🚀

@andrzej-stencel andrzej-stencel changed the title Issue 33300 [exporter/syslog] fix format of structured data Mar 6, 2025
@andrzej-stencel andrzej-stencel changed the title [exporter/syslog] fix format of structured data [exporter/syslog] Fix handling of multiple structured data elements Mar 6, 2025
@andrzej-stencel andrzej-stencel added bug Something isn't working ready to merge Code review completed; ready to merge by maintainers and removed bug Something isn't working labels Mar 6, 2025
@songy23 songy23 merged commit 707bcb9 into open-telemetry:main Mar 6, 2025
156 checks passed
@github-actions github-actions bot added this to the next release milestone Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exporter/syslog ready to merge Code review completed; ready to merge by maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

syslog exporter does not format structured data with multiple fields properly
6 participants