Skip to content

Conversation

@mckn
Copy link
Collaborator

@mckn mckn commented Nov 28, 2025

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

@github-actions
Copy link
Contributor

github-actions bot commented Nov 28, 2025

Hello! 👋 This repository uses Auto for releasing packages using PR labels.

✨ This PR can be merged. It will not be considered when calculating future versions of the npm packages and will not appear in the changelogs.

@mckn mckn self-assigned this Nov 28, 2025
@mckn mckn moved this from 📬 Triage to 🔬 In review in Plugins Platform / Grafana Community Nov 28, 2025
@mckn mckn added the no-changelog Don't include in changelog and version calculations label Nov 28, 2025
Copy link
Contributor

@andresmgot andresmgot left a comment

Choose a reason for hiding this comment

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

Content looks good to me 👍 (maybe wait for a proper docs review)

instanceSettings: DataSourceInstanceSettings<MyDataSourceOptions>,
private readonly templateSrv: TemplateSrv = getTemplateSrv()
) {
super(instanceSettings);
Copy link
Contributor

Choose a reason for hiding this comment

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

is this missing the intialization code?

this.templateSrv = templateSrv

Copy link
Contributor

Choose a reason for hiding this comment

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

I also thought the normal way of doing this was calling getTemplateSrv() in place where you need it. does storing it in a class variable make a difference?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is automatically assigned since it is marked as private readonly and will get the instance when the datasource is constructed.

It is the same, just two different ways of doing the same thing. The reason why I changed it was because our internal datasources uses this pattern so I thought it would be smart to suggest to use the same in the docs. WDYT?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog Don't include in changelog and version calculations

Projects

Status: 🔬 In review

Development

Successfully merging this pull request may close these issues.

3 participants