-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start tracing IDE indexing time with Skate plugin (#756)
Start tracing IDE indexing time with Skate plugin. This PR adds a new listener that extends `ProjectIndexingHistoryListener` to send a trace when indexing is complete. Example data trace: <img width="329" alt="image" src="https://github.com/slackhq/slack-gradle-plugin/assets/12748234/219b43e4-f17b-4905-b435-4414b354f39c"> https://analytics.tinyspeck.com/v3/explore/1000000001254057 <!-- ⬆ Put your description above this! ⬆ Please be descriptive and detailed. Please read our [Contributing Guidelines](https://github.com/tinyspeck/slack-gradle-plugin/blob/main/.github/CONTRIBUTING.md) and [Code of Conduct](https://slackhq.github.io/code-of-conduct). Don't worry about deleting this, it's not visible in the PR! -->
- Loading branch information
Showing
13 changed files
with
187 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
skate-plugin/src/main/kotlin/com/slack/sgp/intellij/idemetrics/IndexingListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright (C) 2024 Slack Technologies, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.slack.sgp.intellij.idemetrics | ||
|
||
import com.intellij.util.indexing.diagnostic.ProjectIndexingHistory | ||
import com.intellij.util.indexing.diagnostic.ProjectIndexingHistoryListener | ||
import com.intellij.util.indexing.diagnostic.dto.toMillis | ||
import com.slack.sgp.intellij.tracing.SkateSpanBuilder | ||
import com.slack.sgp.intellij.tracing.SkateTracingEvent | ||
import com.slack.sgp.intellij.util.getTraceReporter | ||
import com.slack.sgp.intellij.util.isTracingEnabled | ||
|
||
@Suppress("UnstableApiUsage") | ||
class IndexingListener : ProjectIndexingHistoryListener { | ||
override fun onFinishedIndexing(projectIndexingHistory: ProjectIndexingHistory) { | ||
val currentProject = projectIndexingHistory.project | ||
if (!currentProject.isTracingEnabled()) return | ||
val skateSpanBuilder = SkateSpanBuilder() | ||
skateSpanBuilder.apply { | ||
projectIndexingHistory.indexingReason?.let { | ||
addTag(SkateTracingEvent.Indexing.INDEXING_REASON.name, it.take(200)) | ||
} | ||
addTag( | ||
SkateTracingEvent.Indexing.UPDATING_TIME.name, | ||
projectIndexingHistory.times.totalUpdatingTime.toMillis(), | ||
) | ||
addTag( | ||
SkateTracingEvent.Indexing.SCAN_FILES_DURATION.name, | ||
projectIndexingHistory.times.scanFilesDuration.toMillis(), | ||
) | ||
addTag( | ||
SkateTracingEvent.Indexing.INDEXING_DURATION.name, | ||
projectIndexingHistory.times.indexingDuration.toMillis(), | ||
) | ||
addTag( | ||
SkateTracingEvent.Indexing.WAS_INTERRUPTED.name, | ||
projectIndexingHistory.times.wasInterrupted, | ||
) | ||
addTag( | ||
SkateTracingEvent.Indexing.SCANNING_TYPE.name, | ||
projectIndexingHistory.times.scanningType.name, | ||
) | ||
addTag("event", SkateTracingEvent.Indexing.INDEXING_COMPLETED.name) | ||
} | ||
currentProject | ||
.getTraceReporter() | ||
.createPluginUsageTraceAndSendTrace( | ||
"indexing", | ||
projectIndexingHistory.times.updatingStart.toInstant(), | ||
skateSpanBuilder.getKeyValueList(), | ||
) | ||
} | ||
|
||
override fun onStartedIndexing(projectIndexingHistory: ProjectIndexingHistory) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
skate-plugin/src/main/kotlin/com/slack/sgp/intellij/tracing/SkateTracingEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (C) 2024 Slack Technologies, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.slack.sgp.intellij.tracing | ||
|
||
sealed interface SkateTracingEvent { | ||
val name: String | ||
|
||
enum class ProjectGen : SkateTracingEvent { | ||
DIALOG_OPENED | ||
} | ||
|
||
enum class WhatsNew : SkateTracingEvent { | ||
PANEL_OPENED, | ||
PANEL_CLOSED | ||
} | ||
|
||
enum class HoustonFeatureFlag : SkateTracingEvent { | ||
HOUSTON_FEATURE_FLAG_URL_CLICKED | ||
} | ||
|
||
enum class ModelTranslator : SkateTracingEvent { | ||
MODEL_TRANSLATOR_GENERATED | ||
} | ||
|
||
enum class Indexing : SkateTracingEvent { | ||
INDEXING_REASON, | ||
UPDATING_TIME, | ||
SCAN_FILES_DURATION, | ||
INDEXING_DURATION, | ||
WAS_INTERRUPTED, | ||
SCANNING_TYPE, | ||
INDEXING_COMPLETED, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.