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

SONARPY-2457 Collect data for the Python version #2252

Merged
merged 2 commits into from
Dec 17, 2024
Merged

Conversation

ghislainpiot
Copy link
Contributor

@ghislainpiot ghislainpiot commented Dec 16, 2024

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm missing some context on this topic, so I might miss things, and I'm taking what was already implemented as reference.

This looks good though! I left some questions for my own comprehension. My only concern is about the strategy for the isVersionSet key that I could see skewed when counting SonarLint.

durationReport.stop();
}

private void setTelemetry(SensorContext context, String[] pythonVersionParameter) {

Choose a reason for hiding this comment

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

The name of the method seems a bit misleading I guess, what we're doing here is update the Python version telemetry rather than "setting it", no? (I initially thought this was about setting a telemetry field to the context...)
What about updatePythonVersionTelemetry ?


public PythonSensor(FileLinesContextFactory fileLinesContextFactory, CheckFactory checkFactory, NoSonarFilter noSonarFilter,
@Nullable PythonCustomRuleRepository[] customRuleRepositories, @Nullable PythonIndexer indexer,
@Nullable SonarLintCache sonarLintCache, AnalysisWarningsWrapper analysisWarnings, SensorTelemetryStorage sensorTelemetryStorage) {

Choose a reason for hiding this comment

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

I'm not sure I understand in which case we should expect this sensorTelemetryStorage to be injected and in which case we should expect to instantiate it ourselves, and what difference it makes, can you explain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A similar point was raised by Maksim. The goal is to be able to inject the storage as a mock and test it that way.
I should probably rewrite it to use Mockito on the sendTelemetryProperty mock on the SensorContextTester

durationReport.stop();
}

private void setTelemetry(SensorContext context, String[] pythonVersionParameter) {
var isVersionSet = pythonVersionParameter.length != 0 || context.runtime().getProduct() == SonarProduct.SONARLINT;

Choose a reason for hiding this comment

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

Why do we consider the version to be set in SonarLint context? Wouldn't that skew the data and imply more people actively set the version than what actually happens?

private void setTelemetry(SensorContext context, String[] pythonVersionParameter) {
var isVersionSet = pythonVersionParameter.length != 0 || context.runtime().getProduct() == SonarProduct.SONARLINT;
if (pythonVersionParameter.length != 0) {
sensorTelemetryStorage.updateMetric(TelemetryMetricKey.PYTHON_VERSION_KEY, String.join(",", pythonVersionParameter));

Choose a reason for hiding this comment

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

So that means we can set more than just booleans for the telemetry?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, CFamily is sending strings.

Copy link
Contributor

@Seppli11 Seppli11 left a comment

Choose a reason for hiding this comment

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

LGTM!
Out of curiosity, why don't we send telemetry from sonarlint? Would it just screw up the data too much?

@ghislainpiot
Copy link
Contributor Author

LGTM! Out of curiosity, why don't we send telemetry from sonarlint? Would it just screw up the data too much?

I don't think telemetry is sent right now on their side anyways.
It would also probably screw up the stats

@ghislainpiot ghislainpiot force-pushed the SONARPY-2457 branch 2 times, most recently from 63aa67f to 0c34b58 Compare December 17, 2024 14:47
Base automatically changed from SONARPY-2451 to master December 17, 2024 14:52
@ghislainpiot ghislainpiot merged commit fc085d2 into master Dec 17, 2024
10 checks passed
@ghislainpiot ghislainpiot deleted the SONARPY-2457 branch December 17, 2024 16:15
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.

3 participants