Skip to content

Conversation

Parship999
Copy link
Contributor

Which problem is this PR solving?

Description of the changes

  • Problem:
    • when traces contained array valued tags like [value1, value2], the ui showed invalid string type error
    • this happened because collection type attributes were not properly handled during elasticsearch storage
  • Root Cause:
    • In internal/storage/v2/elasticsearch/tracestore/to_dbmodel.go, the attributeToDbTag function only handled ValueTypeMap for JSON serialization
    • ValueTypeSlice (arrays) were falling through to the default case, this causing the type mismatching
  • solution:
    • added pcommon.ValueTypeSlice to the existing case that handles JSON serialization

How was this change tested?

  • Created a test scenario in HotRod that generates array-valued tags (blockers: ["7510-2"])
  • added unit tests to prevent regression
    Screenshot:
Screenshot 2025-07-20 025600

Checklist

Signed-off-by: Parship Chowdhury <i.am.parship@gmail.com>
@yurishkuro
Copy link
Member

  • how does it get stored in ES?
  • how is it returned from query service API in JSON?
  • If it's a string why does the screenshot display it as a JSON array?

@Parship999
Copy link
Contributor Author

  • how does it get stored in ES?
  • how is it returned from query service API in JSON?
  • If it's a string why does the screenshot display it as a JSON array?
  1. in internal/storage/v2/elasticsearch/tracestore/to_dbmodel.go
//Lines 106-107: value conversion
case pcommon.ValueTypeMap, pcommon.ValueTypeSlice:
    tag = dbmodel.KeyValue{Key: key, Value: attr.AsString()}  // JSON string

//Lines 122-123: type assignment  
case pcommon.ValueTypeMap, pcommon.ValueTypeSlice:
    tag.Type = dbmodel.StringType  // stored as StringType
  1. in internal/storage/v2/elasticsearch/tracestore/from_dbmodel.go
//Line 155-156: StringType tags are returned as is
case dbmodel.StringType:
    attributes.PutStr(tag.Key, tagValue)  //'returns JSON string unchanged
  1. this happens in the UI, the UI js detects that the string value looks like JSON and parses it for display. The storage and API always treat it as a string. The UI does the JSON parsing for better visual.

@yurishkuro
Copy link
Member

please include how the value looks in ES JSON (the ticket has the command showing how to load from ES)

@Parship999
Copy link
Contributor Author

please include how the value looks in ES JSON (the ticket has the command showing how to load from ES)

Screenshot 2025-07-21 093129

Copy link

codecov bot commented Jul 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.46%. Comparing base (d827d78) to head (be25ad1).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7350      +/-   ##
==========================================
- Coverage   96.49%   96.46%   -0.03%     
==========================================
  Files         378      378              
  Lines       22910    22910              
==========================================
- Hits        22107    22101       -6     
- Misses        608      612       +4     
- Partials      195      197       +2     
Flag Coverage Δ
badger_v1 9.16% <0.00%> (ø)
badger_v2 1.75% <0.00%> (ø)
cassandra-4.x-v1-manual 11.90% <0.00%> (ø)
cassandra-4.x-v2-auto 1.77% <0.00%> (+0.02%) ⬆️
cassandra-4.x-v2-manual 1.74% <0.00%> (ø)
cassandra-5.x-v1-manual 11.90% <0.00%> (ø)
cassandra-5.x-v2-auto 1.74% <0.00%> (ø)
cassandra-5.x-v2-manual 1.74% <0.00%> (ø)
elasticsearch-6.x-v1 16.74% <0.00%> (ø)
elasticsearch-7.x-v1 16.79% <0.00%> (ø)
elasticsearch-8.x-v1 16.95% <0.00%> (ø)
elasticsearch-8.x-v2 1.75% <0.00%> (ø)
grpc_v1 10.41% <0.00%> (ø)
grpc_v2 1.75% <0.00%> (ø)
kafka-3.x-v1 9.33% <0.00%> (ø)
kafka-3.x-v2 1.75% <0.00%> (ø)
memory_v2 1.75% <0.00%> (ø)
opensearch-1.x-v1 16.83% <0.00%> (ø)
opensearch-2.x-v1 16.83% <0.00%> (ø)
opensearch-2.x-v2 1.75% <0.00%> (ø)
query 1.75% <0.00%> (ø)
tailsampling-processor 0.48% <0.00%> (ø)
unittests 95.42% <100.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yurishkuro yurishkuro added this pull request to the merge queue Jul 21, 2025
auto-merge was automatically disabled July 21, 2025 05:12

Pull Request is not mergeable

Merged via the queue into jaegertracing:main with commit 7948c3b Jul 21, 2025
61 of 64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Incorrect storage / retrieval of collection-type attributes
2 participants