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

Logs: Deprecated showContextToggle in DataSourceWithLogsContextSupport #77232

Merged
merged 7 commits into from
Oct 31, 2023

Conversation

matyax
Copy link
Contributor

@matyax matyax commented Oct 26, 2023

This function used to control the visibility of the show context button, but that has changed and it was now returning a hardcoded true.

Currently, the method to identify log data sources that support Logs Context is to check if they implement DataSourceWithLogsContextSupport through the hasLogsContextSupport guard. Without implementing this interface it's impossible to support the feature, thus this is the way data sources indicate if the option should be available or not.

Additionally, made the row argument mandatory, first because it was being sent by the caller (LogRowMessage), but more importantly because it helps to provide support for Logs Context in mixed data sources. See #76623

Deprecation notice

Since Grafana 10.3 we're deprecating the showContextToggle data source method. To signal support of Logs Context, it is enough to implement the DataSourceWithLogsContextSupport interface.

Which issue(s) does this PR fix?:

Fixes #66819
Related with #73568 and #73565

Special notes for your reviewer:

There should be no function change with this deprecation.

@github-actions
Copy link
Contributor

Backend code coverage report for PR #77232
No changes

@github-actions
Copy link
Contributor

github-actions bot commented Oct 27, 2023

Frontend code coverage report for PR #77232

Plugin Main PR Difference
explore 85.33% 85.33% 0%
elasticsearch 83.66% 83.66% 0%
loki 86.18% 86.18% 0%

@svennergr
Copy link
Contributor

I am not sure we want to do this? showContextToggle can still be used to determine if the button should be shown for certain log lines. Even though we currently don't use it in any of our internal data sources, it's still something we could keep?

@matyax
Copy link
Contributor Author

matyax commented Oct 27, 2023

can still be used to determine if the button should be shown for certain log lines

Does it have a valid use case or we would be keeping it "just in case"?

Personally, I'm not a fan of keeping code for "just in case we need it" purposes, and having 3 data sources returning a harcoded true make a better argument for removing it.

@matyax
Copy link
Contributor Author

matyax commented Oct 27, 2023

@ivanahuckova what do you think? Keep? Deprecate?

@ivanahuckova
Copy link
Member

@matyax have you checked (maybe trough github search) if any other plugin uses it? If not and we don't see any reason to have it, I wouldn't be opposed to deprecating it.

@matyax
Copy link
Contributor Author

matyax commented Oct 27, 2023

There doesn't seem to be any other data source implementing it https://github.com/search?q=+showContextToggle%28&type=code

packages/grafana-data/src/types/logs.ts Outdated Show resolved Hide resolved

return false;
showContextToggle = (row: LogRowModel): boolean => {
return hasLogsContextSupport(this.props.datasourceInstance);
};
Copy link
Member

Choose a reason for hiding this comment

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

Technically, we should not change this because we are only deprecating showContextToggle and not removing it. But as we found out that there are not plugins using it, I THINK it should be fine.

But we should definitely update plugins documentation and remove showContextToggle from there https://github.com/grafana/plugin-tools/blob/41a70bffa66ef0b22a690ac0a7b687fe7ec5264f/docusaurus/docs/tutorials/build-a-logs-data-source-plugin.md?plain=1#L400. And also remove it from https://github.com/grafana/grafana-plugin-examples/blob/main/examples/datasource-logs/src/datasource.ts#L101.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@matyax matyax changed the title Logs: showContextToggle in DataSourceWithLogsContextSupport is now deprecated Logs: Deprecated showContextToggle in DataSourceWithLogsContextSupport Oct 27, 2023
@matyax
Copy link
Contributor Author

matyax commented Oct 27, 2023

@svennergr Any concern with these changes?

matyax and others added 3 commits October 31, 2023 12:15
Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
@matyax matyax force-pushed the matyax/deprecate-show-context-toggle branch from 401a5da to ec9a0df Compare October 31, 2023 11:15
@matyax matyax enabled auto-merge (squash) October 31, 2023 11:30
@@ -156,10 +156,6 @@ export class CloudWatchDatasource
);
}

showContextToggle() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@grafana/aws-datasources FYI.

@matyax matyax merged commit d7c50eb into main Oct 31, 2023
18 checks passed
@matyax matyax deleted the matyax/deprecate-show-context-toggle branch October 31, 2023 11:37
ssama88 pushed a commit to ssama88/grafana that referenced this pull request Oct 31, 2023
…ort (grafana#77232)

* Logs: deprecate showContextToggle

* Logs: make row mandatory on showContextToggle prop

* DataSourceWithLogsContextSupport: make showContextToggle optional

* Loki: update test

* Update packages/grafana-data/src/types/logs.ts

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>

* Prettier

* showContextToggle: update deprecation

---------

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
@aangelisc aangelisc modified the milestones: 10.3.x, 10.2.3 Dec 21, 2023
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.

Logs: Deprecate showContextToggle
4 participants