Skip to content

Conversation

Manik2708
Copy link
Contributor

Which problem is this PR solving?

Description of the changes

  • Implement FindTraces for memory backend

How was this change tested?

  • Unit Tests

Checklist

Signed-off-by: Manik2708 <mehtamanik96@gmail.com>
Signed-off-by: Manik2708 <mehtamanik96@gmail.com>
Signed-off-by: Manik2708 <mehtamanik96@gmail.com>
Signed-off-by: Manik2708 <mehtamanik96@gmail.com>
Signed-off-by: Manik2708 <mehtamanik96@gmail.com>
Signed-off-by: Manik2708 <mehtamanik96@gmail.com>
Signed-off-by: Manik2708 <mehtamanik96@gmail.com>
Signed-off-by: Manik2708 <mehtamanik96@gmail.com>
Signed-off-by: Manik2708 <mehtamanik96@gmail.com>
@Manik2708 Manik2708 requested a review from a team as a code owner April 21, 2025 19:29
@Manik2708 Manik2708 requested a review from albertteoh April 21, 2025 19:29
@Manik2708
Copy link
Contributor Author

@yurishkuro This PR is for getting a direction. Can we expect some OTLP parameters like scope version, name, span kind, status code and message as a tag from the user? (This is assumed in this PR)

Copy link

codecov bot commented Apr 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.22%. Comparing base (7d66726) to head (5315370).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7062      +/-   ##
==========================================
+ Coverage   96.20%   96.22%   +0.01%     
==========================================
  Files         358      358              
  Lines       21596    21689      +93     
==========================================
+ Hits        20777    20870      +93     
  Misses        613      613              
  Partials      206      206              
Flag Coverage Δ
badger_v1 9.90% <ø> (ø)
badger_v2 2.05% <ø> (ø)
cassandra-4.x-v1-manual 14.89% <ø> (ø)
cassandra-4.x-v2-auto 2.04% <ø> (ø)
cassandra-4.x-v2-manual 2.04% <ø> (ø)
cassandra-5.x-v1-manual 14.89% <ø> (ø)
cassandra-5.x-v2-auto 2.04% <ø> (ø)
cassandra-5.x-v2-manual 2.04% <ø> (ø)
elasticsearch-6.x-v1 20.23% <ø> (ø)
elasticsearch-7.x-v1 20.31% <ø> (ø)
elasticsearch-8.x-v1 20.49% <ø> (ø)
elasticsearch-8.x-v2 2.05% <ø> (ø)
grpc_v1 11.44% <ø> (ø)
grpc_v2 2.05% <ø> (ø)
kafka-3.x-v1 10.17% <ø> (ø)
kafka-3.x-v2 2.05% <ø> (ø)
memory_v2 2.05% <ø> (ø)
opensearch-1.x-v1 20.36% <ø> (ø)
opensearch-2.x-v1 20.36% <ø> (ø)
opensearch-2.x-v2 2.05% <ø> (ø)
query 2.05% <ø> (ø)
tailsampling-processor 0.55% <ø> (ø)
unittests 95.04% <100.00%> (+0.02%) ⬆️

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
Copy link
Member

Right now we only support search either by otel attributes (at any level) or by some first class fields like span name. Status search is by tag error=true. Other otel fields not supported.

@Manik2708
Copy link
Contributor Author

Right now we only support search either by otel attributes (at any level) or by some first class fields like span name. Status search is by tag error=true. Other otel fields not supported.

So what should we do on getting them in attributes? simply remove them? Currently I have extracted the required information from the tags, for example if the key is w3c.tracestate then value is assumed as TraceState, if key is otlp.scope.version then Scope.Version. Is this correct or should we simply remove these attributes?

@yurishkuro
Copy link
Member

I don't think we need to worry about those right now, it should be implemented as a storage-agnostic solution by extending the search API to support first class fields like span.status, scope.name, scope.version explicitly. #7063

Signed-off-by: Manik2708 <mehtamanik96@gmail.com>
Manik2708 added 3 commits May 6, 2025 02:19
Signed-off-by: Manik2708 <mehtamanik96@gmail.com>
Signed-off-by: Manik2708 <mehtamanik96@gmail.com>
@Manik2708 Manik2708 requested a review from yurishkuro May 5, 2025 20:54
Manik2708 added 2 commits May 6, 2025 15:02
Signed-off-by: Manik2708 <mehtamanik96@gmail.com>
@Manik2708 Manik2708 requested a review from yurishkuro May 6, 2025 09:46
Signed-off-by: Manik2708 <mehtamanik96@gmail.com>
Manik2708 added 4 commits May 10, 2025 23:00
Signed-off-by: Manik2708 <mehtamanik96@gmail.com>
Signed-off-by: Manik2708 <mehtamanik96@gmail.com>
Signed-off-by: Manik2708 <mehtamanik96@gmail.com>
@Manik2708 Manik2708 requested a review from yurishkuro May 10, 2025 17:39
@yurishkuro yurishkuro requested a review from Copilot May 10, 2025 20:52
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements the FindTraces functionality for the memory backend while updating the internal Tenant structure and associated tests.

  • Updated Tenant struct: changed ids from a slice to a map and traces from a map to a slice of pointer wrappers.
  • Implemented FindTraces in both Tenant and Store with error handling for non-positive search depths.
  • Adjusted test cases and fixtures to account for the new structure and additional span fields.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

File Description
internal/storage/v2/memory/tenant.go Updated Tenant struct and eviction logic; implemented findTraces.
internal/storage/v2/memory/memory_test.go Modified tests to access traces via new ids mapping and slice structure.
internal/storage/v2/memory/memory.go Added FindTraces implementation in the Store with error handling.
internal/storage/v2/memory/fixtures/*.json Updated fixture files to reflect new span kind and traceState values.
Comments suppressed due to low confidence (1)

internal/storage/v2/memory/tenant.go:27

  • [nitpick] Consider renaming 'tracesById' to 'tracesByID' for consistency with Go naming conventions.
type tracesById struct {

Manik2708 added 3 commits May 11, 2025 19:56
Signed-off-by: Manik2708 <mehtamanik96@gmail.com>
Signed-off-by: Manik2708 <mehtamanik96@gmail.com>
@Manik2708 Manik2708 requested a review from yurishkuro May 11, 2025 14:31
}

func validSpan(resourceAttributes, scopeAttributes pcommon.Map, span ptrace.Span, query tracestore.TraceQueryParams) bool {
_, errAttributeFound := query.Attributes.Get(errorAttribute)
Copy link
Member

Choose a reason for hiding this comment

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

What if the input is error=false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am confused for that case. What if user has entered a string for error attribute, it will still be converted to attribute and val.Bool() would return false. Currently in both cases (when user has entered false and a string) it will return both unset and ok status spans. To fix this should we compare strings? For example errAttr.AsString() == "false"?

Manik2708 added 3 commits May 13, 2025 11:31
Signed-off-by: Manik2708 <mehtamanik96@gmail.com>
Signed-off-by: Manik2708 <mehtamanik96@gmail.com>
@Manik2708 Manik2708 requested a review from yurishkuro May 18, 2025 04:46
Signed-off-by: Yuri Shkuro <github@ysh.us>
Signed-off-by: Yuri Shkuro <github@ysh.us>
Signed-off-by: Yuri Shkuro <github@ysh.us>
Signed-off-by: Yuri Shkuro <github@ysh.us>
@yurishkuro yurishkuro enabled auto-merge May 18, 2025 17:10
@yurishkuro yurishkuro added this pull request to the merge queue May 18, 2025
Merged via the queue into jaegertracing:main with commit 1be2293 May 18, 2025
58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/storage changelog:exprimental Change to an experimental part of the code v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants