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(trace-details): query service changes for trace details #6906

Merged
merged 6 commits into from
Jan 23, 2025

Conversation

vikrantgupta25
Copy link
Member

@vikrantgupta25 vikrantgupta25 commented Jan 22, 2025

Summary

Related Issues / PR's

contributes to - #6132

Screenshots

NA

Affected Areas and Manually Tested Areas

@github-actions github-actions bot added the enhancement New feature or request label Jan 22, 2025
Copy link

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

1 similar comment
Copy link

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Reviewed everything up to 835d7a3 in 3 minutes and 20 seconds

More details
  • Looked at 1369 lines of code in 16 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. pkg/query-service/app/server.go:161
  • Draft comment:
    Ensure fluxIntervalForTraceDetail is consistently used across all instances. Currently, it is passed as nil here, which might lead to unexpected behavior.
  • Reason this comment was not posted:
    Marked as duplicate.
2. pkg/query-service/app/server.go:183
  • Draft comment:
    Ensure fluxIntervalForTraceDetail is consistently used across all instances. Currently, it is passed as nil here, which might lead to unexpected behavior.
  • Reason this comment was not posted:
    Marked as duplicate.
3. pkg/query-service/app/server.go:134
  • Draft comment:
    Ensure fluxIntervalForTraceDetail is consistently used across all instances. Currently, it is passed as nil here, which might lead to unexpected behavior.
  • Reason this comment was not posted:
    Comment did not seem useful.
4. pkg/query-service/interfaces/interface.go:44
  • Draft comment:
    Do not add non-ClickHouse related functions to the ClickHouseReader interface. Use the DAO in the telemetry instance to access such information instead.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment seems to be based on a misunderstanding. This is a general Reader interface, not a ClickHouseReader interface. The new functions are trace-related operations which fit with other trace operations already in the interface (like SearchTraces). The interface already contains many non-ClickHouse specific operations. The comment appears to be enforcing a rule that doesn't apply here.
    I could be wrong about the broader context - maybe there's a reason these specific functions should be handled differently from other trace operations. There might be architectural decisions I'm not aware of.
    Even with potential missing context, the evidence strongly suggests this is a general interface for reading various types of data, including traces. The new methods are consistent with existing patterns in the interface.
    The comment should be deleted because it appears to be based on a misunderstanding of the interface's purpose and scope. The new methods are consistent with the interface's existing functionality.

Workflow ID: wflow_shWExKQEufwO4YOY


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 90476d7 in 1 minute and 32 seconds

More details
  • Looked at 1313 lines of code in 10 files
  • Skipped 0 files when reviewing.
  • Skipped posting 9 drafted comments based on config settings.
1. pkg/query-service/app/clickhouseReader/reader.go:160
  • Draft comment:
    The import alias for the cache package has been changed from cacheV2 to cache, but the variable name cacheV2 is still used in some places. Ensure consistency in naming to avoid confusion.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
2. pkg/query-service/app/clickhouseReader/reader.go:175
  • Draft comment:
    The import alias for the cache package has been changed from cacheV2 to cache, but the variable name cacheV2 is still used in some places. Ensure consistency in naming to avoid confusion.
  • Reason this comment was not posted:
    Marked as duplicate.
3. pkg/query-service/app/clickhouseReader/reader.go:186
  • Draft comment:
    The import alias for the cache package has been changed from cacheV2 to cache, but the variable name cacheV2 is still used in some places. Ensure consistency in naming to avoid confusion.
  • Reason this comment was not posted:
    Marked as duplicate.
4. pkg/query-service/app/clickhouseReader/reader.go:288
  • Draft comment:
    The import alias for the cache package has been changed from cacheV2 to cache, but the variable name cacheV2 is still used in some places. Ensure consistency in naming to avoid confusion.
  • Reason this comment was not posted:
    Marked as duplicate.
5. pkg/query-service/app/clickhouseReader/reader.go:1454
  • Draft comment:
    The import alias for the cache package has been changed from cacheV2 to cache, but the variable name cacheV2 is still used in some places. Ensure consistency in naming to avoid confusion.
  • Reason this comment was not posted:
    Marked as duplicate.
6. pkg/query-service/app/clickhouseReader/reader.go:1553
  • Draft comment:
    The import alias for the cache package has been changed from cacheV2 to cache, but the variable name cacheV2 is still used in some places. Ensure consistency in naming to avoid confusion.
  • Reason this comment was not posted:
    Marked as duplicate.
7. pkg/query-service/app/traces/tracedetail/flamegraph.go:1
  • Draft comment:
    Avoid using the component/index.tsx file structure approach, as it makes it difficult to debug and find components using global search tools like VS Code.
  • Reason this comment was not posted:
    Comment was not on a valid diff hunk.
8. pkg/query-service/app/traces/tracedetail/waterfall.go:1
  • Draft comment:
    Avoid using the component/index.tsx file structure approach, as it makes it difficult to debug and find components using global search tools like VS Code.
  • Reason this comment was not posted:
    Marked as duplicate.
9. pkg/query-service/model/cacheable.go:1
  • Draft comment:
    Avoid using the component/index.tsx file structure approach, as it makes it difficult to debug and find components using global search tools like VS Code.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_zzD5Kbzef6WEAE9V


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on a1d3d6f in 38 seconds

More details
  • Looked at 166 lines of code in 5 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. pkg/query-service/app/traces/tracedetail/flamegraph.go:91
  • Draft comment:
    The logic for adjusting lowerLimit and upperLimit is repeated in GetSelectedSpansForFlamegraphForRequest and GetSelectedSpans in waterfall.go. Consider refactoring this into a helper function to improve maintainability.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The function GetSelectedSpansForFlamegraphForRequest in flamegraph.go has redundant code for adjusting the lowerLimit and upperLimit. The same logic is repeated in GetSelectedSpans in waterfall.go. This redundancy can be refactored into a helper function to improve code maintainability.
2. pkg/query-service/app/traces/tracedetail/waterfall.go:106
  • Draft comment:
    The parameter isPartOfPreOrder in traverseTrace could be renamed to something more descriptive to indicate its purpose more clearly, such as shouldIncludeInPreOrder.
  • Reason this comment was not posted:
    Confidence changes required: 20%
    The traverseTrace function in waterfall.go has a parameter isPartOfPreOrder that is used to determine if a node should be added to the preOrderTraversal. This logic is correct, but the name isPartOfPreOrder could be more descriptive to indicate its purpose more clearly.
3. pkg/query-service/app/traces/tracedetail/waterfall.go:106
  • Draft comment:
    Avoid using inline styles in React components. Instead, use external stylesheets, CSS classes, or styled components.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The function traverseTrace in waterfall.go has been modified to include an additional parameter isPartOfPreOrder, which is used to determine whether to append the node to the pre-order traversal. This change is consistent with the logic of maintaining a pre-order traversal based on certain conditions.

Workflow ID: wflow_Av3v4ufTz2pUfriC


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

ee/query-service/main.go Outdated Show resolved Hide resolved
pkg/query-service/app/clickhouseReader/reader.go Outdated Show resolved Hide resolved
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on b33aa74 in 29 seconds

More details
  • Looked at 340 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. pkg/query-service/app/traces/tracedetail/waterfall.go:4
  • Draft comment:
    The use of the slices package for the Contains function is a good replacement for the custom contains function. This improves code readability and maintainability.
  • Reason this comment was not posted:
    Confidence changes required: 10%
    The slices package is used for the Contains function, which is a good replacement for the custom contains function. This change is appropriate and improves code readability.
2. pkg/query-service/app/traces/tracedetail/waterfall.go:81
  • Draft comment:
    The slices.Contains function is used correctly in place of the custom contains function. This change is appropriate and improves code readability. This is also applicable at line 130.
  • Reason this comment was not posted:
    Confidence changes required: 10%
    The slices.Contains function is used correctly in place of the custom contains function. This change is appropriate and improves code readability.
3. pkg/query-service/app/traces/tracedetail/waterfall.go:78
  • Draft comment:
    The contains function is defined but not used. Consider removing it to clean up the code.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The function contains is defined but not used anywhere in the code. It should be removed to clean up the code.

Workflow ID: wflow_l5aBhccFBv3WkfPC


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 52ad95e in 1 minute and 27 seconds

More details
  • Looked at 44 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. pkg/query-service/app/clickhouseReader/reader.go:1456
  • Draft comment:
    The function signature has changed, adding traceDetailsQuery as a parameter. Ensure all invocations of GetSpansForTrace are updated accordingly.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The change in the function signature of GetSpansForTrace requires updating all its invocations. The PR author has done this, but it's important to ensure that all invocations are updated correctly. The change involves adding a new parameter traceDetailsQuery.
2. pkg/query-service/app/clickhouseReader/reader.go:1469
  • Draft comment:
    Logging SQL queries can expose sensitive information. Ensure this complies with security and privacy policies.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The SQL query string is being logged, which can be useful for debugging but may expose sensitive information. It's important to ensure that logging this information does not violate any security or privacy policies.
3. pkg/query-service/app/clickhouseReader/reader.go:1523
  • Draft comment:
    Ensure that fmt.Sprintf usage for SQL query construction does not allow user input to affect the query structure, preventing SQL injection.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The SQL query string is being constructed using fmt.Sprintf, which is generally safe here because the table names are not user inputs. However, it's important to ensure that no user input can affect the query structure to prevent SQL injection.
4. pkg/query-service/app/clickhouseReader/reader.go:1456
  • Draft comment:
    Avoid adding non-ClickHouse related parameters like traceDetailsQuery to the ClickHouseReader interface. Use the DAO in the telemetry instance to access such information instead.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment appears to be incorrect. The traceDetailsQuery parameter is directly related to ClickHouse functionality as it contains SQL queries executed against ClickHouse. This is not a non-ClickHouse related parameter. The parameter is used to make the query reusable across different trace detail retrieval scenarios.
    Could I be wrong about the parameter's purpose? Maybe there's a better architectural pattern for handling different query variations?
    While there could be other patterns, passing the query as a parameter is a valid approach here since it's still directly related to ClickHouse functionality. The parameter name could be clearer but the functionality is appropriate.
    The comment should be deleted as it incorrectly identifies traceDetailsQuery as a non-ClickHouse related parameter when it is actually a ClickHouse SQL query parameter.

Workflow ID: wflow_p5S9N3tt3nQuDGoC


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@vikrantgupta25 vikrantgupta25 merged commit 1e61e6c into main Jan 23, 2025
18 checks passed
@vikrantgupta25 vikrantgupta25 deleted the feat/trace-details-query-service branch January 23, 2025 18:46
Copy link
Member

@nityanandagohain nityanandagohain left a comment

Choose a reason for hiding this comment

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

I have done some basic review, I will review the logics more. But please add test to review the logic otherwise it is really difficult.

}

if time.Since(time.UnixMilli(int64(cachedTraceData.EndTime))) < r.fluxIntervalForTraceDetail {
zap.L().Info("the trace end time falls under the flux interval, skipping getWaterfallSpansForTraceWithMetadata cache", zap.String("traceID", traceID))
Copy link
Member

Choose a reason for hiding this comment

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

debug log ?

}

if err != nil {
zap.L().Info("cache miss for getWaterfallSpansForTraceWithMetadata", zap.String("traceID", traceID))
Copy link
Member

Choose a reason for hiding this comment

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

I see redundant logs.

}
totalSpans = uint64(len(searchScanResponses))

processingBeforeCache := time.Now()
Copy link
Member

Choose a reason for hiding this comment

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

this part can be it's own function ?


// traverse through the map and append each node to the children array of the parent node
// and add the missing spans
for _, spanNode := range spanIdToSpanNodeMap {
Copy link
Member

@nityanandagohain nityanandagohain Jan 26, 2025

Choose a reason for hiding this comment

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

this part as well, with tests.


processingBeforeCache := time.Now()
for _, item := range searchScanResponses {
ref := []model.OtelSpanRef{}
Copy link
Member

Choose a reason for hiding this comment

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

duplicate parts from GetWaterfallSpansForTraceWithMetadata

return selectedSpanIndex
}

func getPathFromRootToSelectedSpanId(node *model.Span, selectedSpanId string, uncollapsedSpans []string, isSelectedSpanIDUnCollapsed bool) (bool, []string) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't see any test cases for functions in these files.

}

func (c *GetWaterfallSpansForTraceWithMetadataCache) MarshalBinary() (data []byte, err error) {
return json.Marshal(c)
Copy link
Member

Choose a reason for hiding this comment

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

Is this required ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants