Skip to content

Conversation

daniyelnnr
Copy link
Contributor

@daniyelnnr daniyelnnr commented Sep 26, 2025

What is the purpose of this pull request?

This PR fixes wrong mapping for some attributes, leading to fluent-bit being unable to create some attributes on OpenSearch, even though logs objects were being sent.

What problem is this solving?

#579 introduced a small bug in log attribute mapping. Attributes like "account," "workspace," and "appId" were present in the object exported to stdout but weren't being mapped correctly in the OpenSearch attributes view. An example is the image below, where we see a gap in the number of logs when filtering by one of the attributes with the affected mapping (you can also see that the issue was reversed after the rollback).

image

This issue was resolved by separating the object exported to stdout and logged to OpenSearch from the object logged by the diagnostics library client.

How should this be manually tested?

Screenshots or example usage

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Requires change to documentation, which has been updated accordingly.

This update modifies the Logger class to streamline the construction of log objects, allowing to support legacy logging approach and the new one based on diagnostics
@daniyelnnr daniyelnnr requested review from arturpimentel and a team September 26, 2025 17:33
@daniyelnnr daniyelnnr self-assigned this Sep 26, 2025
@daniyelnnr daniyelnnr added the bug label Sep 26, 2025
Copy link

@juliobguedes juliobguedes left a comment

Choose a reason for hiding this comment

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

Besides comments, LGTM

Copy link
Contributor

@silvadenisaraujo silvadenisaraujo left a comment

Choose a reason for hiding this comment

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

Agree with comments from @juliobguedes , besides LGTM!

This commit addresses PR review feedback by refactoring the logger to
improve code maintainability and prevent data duplication between console
and diagnostics client logs.

Key changes:
- Created commonLogFields object containing shared fields: __VTEX_IO_LOG,
  level, operationId, requestId, and traceId
- Removed data field from diagnosticsLog by keeping it only in inflatedLog
- Spread commonLogFields at the end of both log objects to maintain key order

The refactoring ensures:
1. Console logs (inflatedLog) include all fields needed for fluent-bit/OpenSearch
2. Diagnostics client logs (diagnosticsLog) use semantic convention keys without
   data duplication
3. Common fields are defined once and reused consistently across both log formats

Addresses review comments from @juliobguedes:
- Comment 1: Remove data from diagnosticsLog to avoid duplications
- Comment 2: Extract commonLogFields to reduce code duplication
@daniyelnnr daniyelnnr removed the request for review from arturpimentel October 7, 2025 17:22
This change adds status code as an attribute for some metrics like request timings and responses sizes
@daniyelnnr daniyelnnr merged commit b41d80d into master Oct 8, 2025
1 of 2 checks passed
@daniyelnnr daniyelnnr deleted the fix/semconv branch October 8, 2025 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants