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

Fix Trace List with variable #132

Merged
merged 3 commits into from
Aug 1, 2022
Merged

Fix Trace List with variable #132

merged 3 commits into from
Aug 1, 2022

Conversation

iwysiu
Copy link
Contributor

@iwysiu iwysiu commented Jul 27, 2022

The query editor uses a check for trace id to determine if a Trace List query is a getTrace or getTraceSummaries query. Previously, it did not replace variables before checking, which meant that a variable that represented a trace id would incorrectly get sorted as a getTraceSummaries query.

Structure-wise it would probably be better if the query function determined which type it was, but I wasn't sure we wanted to do that much restructuring.

Fixes #131

@iwysiu iwysiu requested a review from a team as a code owner July 27, 2022 21:35
@iwysiu iwysiu requested review from sunker and fridgepoet and removed request for a team July 27, 2022 21:35
@CLAassistant
Copy link

CLAassistant commented Jul 27, 2022

CLA assistant check
All committers have signed the CLA.

@github-actions
Copy link

Backend code coverage report for PR #132
No changes

@github-actions
Copy link

Frontend code coverage report for PR #132

Plugin Main PR Difference
src 84.21% 84.21% 0%

@iwysiu iwysiu requested a review from sarahzinger July 28, 2022 14:11
Copy link
Member

@fridgepoet fridgepoet left a comment

Choose a reason for hiding this comment

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

LGTM but would prefer someone else approve as well

Copy link
Member

@sarahzinger sarahzinger left a comment

Choose a reason for hiding this comment

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

Looking good just a few clarifying questions first if that's cool!

yarn.lock Outdated
@@ -3841,17 +3841,10 @@ caniuse-api@^3.0.0:
lodash.memoize "^4.1.2"
lodash.uniq "^4.5.0"

caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001135:
Copy link
Member

Choose a reason for hiding this comment

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

was this change intentional? I don't see a change to package.json so it's a bit strange to see a yarn.lock change right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was because drone was complaining about it and I was messing with it https://drone.grafana.net/grafana/x-ray-datasource/86/1/5
I'll leave it for another commit

});
it('sets the query type to getTrace if query is variable for a traceID', () => {
const queryType = queryTypeOptionToQueryType([queryTypeOptions[0].value], '$variable', {
variable: { text: '1-5f048fc1-4f1c9b022d6233dacd96fb84', value: '1-5f048fc1-4f1c9b022d6233dacd96fb84' },
Copy link
Member

Choose a reason for hiding this comment

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

wouldn't the variable be something more like "traceId" rather than an actual traceId?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The form uses a regex to check for something in this format to determine what query type to use, so the value does have to be shaped like an actual traceId. (the string being passed in as the query is $variable)

import { DataSourceInstanceSettings, ScopedVars, VariableModel } from '@grafana/data';
import { TemplateSrv } from '@grafana/runtime';

jest.mock('@grafana/runtime', () => {
Copy link
Member

Choose a reason for hiding this comment

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

it seems like you're updating a mock but not any tests in this file. Is that intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this also needed GetTemplateSrv() to be mocked.

import { TemplateSrv } from '@grafana/runtime';
import { ScopedVars, VariableModel } from '@grafana/data';

jest.mock('@grafana/runtime', () => {
Copy link
Member

Choose a reason for hiding this comment

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

is there a way to just mockout getTemplateSrv ? It seems like that's the only bit you're using right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

switched it to a jest.SpyOn

@iwysiu iwysiu requested a review from sarahzinger August 1, 2022 15:30
Copy link
Member

@sarahzinger sarahzinger left a comment

Choose a reason for hiding this comment

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

🆒

@iwysiu iwysiu merged commit ac33fb4 into main Aug 1, 2022
@iwysiu iwysiu deleted the iwysiu/131 branch August 1, 2022 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

x-ray data source variable binding not working for Trace List query parameter
4 participants