[ide starter] AT-107 Moving intellij.tools.ide.metrics.collector to community part of the repo

GitOrigin-RevId: 8d8572ac402c29ac3206b942a2398722f1e239a0
This commit is contained in:
Nikita Kudrin
2023-10-09 13:51:05 +03:00
committed by intellij-monorepo-bot
parent bea62c231b
commit 80b8f5971e
34 changed files with 4470 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
<component name="libraryTable">
<library name="kotlin-test-assertions-core-jvm" type="repository">
<properties maven-id="io.kotest:kotest-assertions-core-jvm:5.5.4">
<verification>
<artifact url="file://$MAVEN_REPOSITORY$/io/kotest/kotest-assertions-core-jvm/5.5.4/kotest-assertions-core-jvm-5.5.4.jar">
<sha256sum>3acf3de882ec2c714dfc173cc382c38a5aee70c3f2bdda732583916845226d0c</sha256sum>
</artifact>
<artifact url="file://$MAVEN_REPOSITORY$/io/kotest/kotest-assertions-shared-jvm/5.5.4/kotest-assertions-shared-jvm-5.5.4.jar">
<sha256sum>9977d913ef1fccf2e2663b5906d955fdf8215d0ec48265d669b01e05179e2043</sha256sum>
</artifact>
<artifact url="file://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar">
<sha256sum>58812de60898d976fb81ef3b62da05c6604c18fd4a249f5044282479fc286af2</sha256sum>
</artifact>
<artifact url="file://$MAVEN_REPOSITORY$/io/kotest/kotest-common-jvm/5.5.4/kotest-common-jvm-5.5.4.jar">
<sha256sum>a2a4d02b86b2e849e514d18dbdf4b29e2e9d091e3c6f4d9d028db9cdc55dd28b</sha256sum>
</artifact>
<artifact url="file://$MAVEN_REPOSITORY$/io/kotest/kotest-assertions-api-jvm/5.5.4/kotest-assertions-api-jvm-5.5.4.jar">
<sha256sum>8b1c3e582e2f6f662261f3f45a6d723f3dd8d8b2b0b86a3f7d8e6c966eca0568</sha256sum>
</artifact>
</verification>
<exclude>
<dependency maven-id="org.jetbrains.kotlin:kotlin-stdlib-jdk8" />
<dependency maven-id="org.jetbrains.kotlin:kotlin-stdlib-common" />
<dependency maven-id="org.jetbrains.kotlin:kotlin-reflect" />
<dependency maven-id="org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm" />
<dependency maven-id="org.jetbrains.kotlinx:kotlinx-coroutines-jdk8" />
<dependency maven-id="io.github.java-diff-utils:java-diff-utils" />
</exclude>
</properties>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/io/kotest/kotest-assertions-core-jvm/5.5.4/kotest-assertions-core-jvm-5.5.4.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/io/kotest/kotest-assertions-shared-jvm/5.5.4/kotest-assertions-shared-jvm-5.5.4.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/io/kotest/kotest-common-jvm/5.5.4/kotest-common-jvm-5.5.4.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/io/kotest/kotest-assertions-api-jvm/5.5.4/kotest-assertions-api-jvm-5.5.4.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/io/kotest/kotest-assertions-core-jvm/5.5.4/kotest-assertions-core-jvm-5.5.4-javadoc.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/io/kotest/kotest-assertions-shared-jvm/5.5.4/kotest-assertions-shared-jvm-5.5.4-javadoc.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0-javadoc.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/io/kotest/kotest-common-jvm/5.5.4/kotest-common-jvm-5.5.4-javadoc.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/io/kotest/kotest-assertions-api-jvm/5.5.4/kotest-assertions-api-jvm-5.5.4-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/io/kotest/kotest-assertions-core-jvm/5.5.4/kotest-assertions-core-jvm-5.5.4-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/io/kotest/kotest-assertions-shared-jvm/5.5.4/kotest-assertions-shared-jvm-5.5.4-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/io/kotest/kotest-common-jvm/5.5.4/kotest-common-jvm-5.5.4-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/io/kotest/kotest-assertions-api-jvm/5.5.4/kotest-assertions-api-jvm-5.5.4-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@@ -0,0 +1,24 @@
<component name="libraryTable">
<library name="mockito-junit-jupiter" type="repository">
<properties jar-repository-id="central-proxy" maven-id="org.mockito:mockito-junit-jupiter:5.5.0">
<verification>
<artifact url="file://$MAVEN_REPOSITORY$/org/mockito/mockito-junit-jupiter/5.5.0/mockito-junit-jupiter-5.5.0.jar">
<sha256sum>9e77065ec6e70b84905bb49136f210877db7fa3ff80e90d91c07879148175efc</sha256sum>
</artifact>
</verification>
<exclude>
<dependency maven-id="org.mockito:mockito-core" />
<dependency maven-id="org.junit.jupiter:junit-jupiter-api" />
</exclude>
</properties>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/mockito/mockito-junit-jupiter/5.5.0/mockito-junit-jupiter-5.5.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/mockito/mockito-junit-jupiter/5.5.0/mockito-junit-jupiter-5.5.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/mockito/mockito-junit-jupiter/5.5.0/mockito-junit-jupiter-5.5.0-sources.jar!/" />
</SOURCES>
</library>
</component>

1
.idea/modules.xml generated
View File

@@ -1129,6 +1129,7 @@
<module fileurl="file://$PROJECT_DIR$/plugins/toml/core/intellij.toml.core.iml" filepath="$PROJECT_DIR$/plugins/toml/core/intellij.toml.core.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/toml/json/intellij.toml.json.iml" filepath="$PROJECT_DIR$/plugins/toml/json/intellij.toml.json.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/toml/tests/intellij.toml.tests.iml" filepath="$PROJECT_DIR$/plugins/toml/tests/intellij.toml.tests.iml" />
<module fileurl="file://$PROJECT_DIR$/tools/intellij.tools.ide.metrics.collector/intellij.tools.ide.metrics.collector.iml" filepath="$PROJECT_DIR$/tools/intellij.tools.ide.metrics.collector/intellij.tools.ide.metrics.collector.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/performanceTesting/commands-model/intellij.tools.ide.performanceTesting.commands.iml" filepath="$PROJECT_DIR$/plugins/performanceTesting/commands-model/intellij.tools.ide.performanceTesting.commands.iml" />
<module fileurl="file://$PROJECT_DIR$/jps/antLayout/intellij.tools.jps.antTasks.iml" filepath="$PROJECT_DIR$/jps/antLayout/intellij.tools.jps.antTasks.iml" />
<module fileurl="file://$PROJECT_DIR$/jps/standalone-builder/intellij.tools.jps.build.standalone.iml" filepath="$PROJECT_DIR$/jps/standalone-builder/intellij.tools.jps.build.standalone.iml" />

View File

@@ -0,0 +1,4 @@
.idea
out
.gradle
build

View File

@@ -0,0 +1,17 @@
### Metric Collector
#### Overview
Extension library for [starter](https://github.com/JetBrains/intellij-ide-starter/tree/master/intellij.tools.ide.starter)
that provides metrics collection.
Supported metrics:
* Indexing
* Opentelemetry-based metrics
To get the metrics from OpenTelemetry invoke `com.intellij.tools.ide.metrics.collector.metrics.OpenTelemetryKt.getOpenTelemetry`
and pass the span name you're interested in. Default span name for all commands from performance test is `performance_test`.
To find out which spans were collected you can open `opentelemetry.json` file in log folder. The recommended viewer is [Jaeger](https://www.jaegertracing.io/).
To get inspection metrics invoke `com.intellij.tools.ide.metrics.collector.starter.metrics.IndexingMetricsKt.extractIndexingMetrics`.

View File

@@ -0,0 +1,58 @@
apply plugin: 'java'
apply plugin: 'kotlin'
group = "com.jetbrains.intellij.tools"
buildscript {
ext.kotlin_version = '1.8.0'
ext.jackson_version = '2.14.1'
repositories {
maven { url = "https://cache-redirector.jetbrains.com/maven-central" }
maven { url = "https://cache-redirector.jetbrains.com/intellij-dependencies" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
sourceSets {
main.kotlin.srcDirs += 'src'
test.kotlin.srcDirs += 'testSrc'
test.resources {
srcDirs "testResources"
includes = ["**/*.*"]
}
}
repositories {
maven { url = "https://cache-redirector.jetbrains.com/maven-central" }
maven { url = "https://cache-redirector.jetbrains.com/intellij-dependencies" }
maven { url = "https://www.jetbrains.com/intellij-repository/releases" }
maven { url = "https://www.jetbrains.com/intellij-repository/snapshots" }
maven { url = "https://www.jetbrains.com/intellij-repository/nightly" }
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.intellij.deps:gradle-api:7.4"
implementation('com.jetbrains.intellij.platform:lang-impl:LATEST-EAP-SNAPSHOT')
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
implementation "com.fasterxml.jackson.module:jackson-module-kotlin:$jackson_version"
implementation "com.jetbrains.intellij.tools:ide-starter"
testImplementation 'io.kotest:kotest-assertions-core-jvm:5.5.4'
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.1'
}
configurations {
implementation.exclude(group: 'com.jetbrains.infra')
}
kotlin {
jvmToolchain(17)
}

View File

@@ -0,0 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -0,0 +1,244 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# 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.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

View File

@@ -0,0 +1,92 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="kotlin-language" name="Kotlin">
<configuration version="5" platform="JVM 17" allPlatforms="JVM [17]" useProjectSettings="false">
<compilerSettings>
<option name="additionalArguments" value="-Xjvm-default=all -opt-in=kotlin.time.ExperimentalTime" />
</compilerSettings>
<compilerArguments>
<stringArguments>
<stringArg name="jvmTarget" arg="17" />
<stringArg name="apiVersion" arg="1.9" />
<stringArg name="languageVersion" arg="1.9" />
</stringArguments>
</compilerArguments>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/testResources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/testSrc" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="intellij.platform.lang.impl" />
<orderEntry type="library" name="jackson" level="project" />
<orderEntry type="library" name="jackson-databind" level="project" />
<orderEntry type="library" name="jackson-module-kotlin" level="project" />
<orderEntry type="library" scope="TEST" name="kotlin-test-assertions-core-jvm" level="project" />
<orderEntry type="library" scope="TEST" name="JUnit5" level="project" />
<orderEntry type="library" scope="TEST" name="mockito" level="project" />
<orderEntry type="library" scope="TEST" name="mockito-junit-jupiter" level="project" />
<orderEntry type="module" module-name="intellij.platform.diagnostic.telemetry" />
<orderEntry type="library" name="opentelemetry" level="project" />
</component>
</module>

View File

@@ -0,0 +1,2 @@
rootProject.name = "ide-metrics-collector"
includeBuild "../intellij.tools.ide.starter"

View File

@@ -0,0 +1,28 @@
package com.intellij.tools.ide.metrics.collector.analysis
import com.intellij.tools.ide.metrics.collector.collector.PerformanceMetrics
enum class Conclusion {
UNKNOWN,
FASTER,
PROBABLY_FASTER,
SAME,
PROBABLY_SLOWER,
SLOWER
}
interface FailureAnalysis {
fun analyseResults(sortedPreviousMetrics: MutableList<PerformanceMetrics>,
metricName: String,
currentResult: Number,
testName: String,
notifierHook: (Conclusion) -> Unit)
}
class NoFailureAnalysis: FailureAnalysis {
override fun analyseResults(sortedPreviousMetrics: MutableList<PerformanceMetrics>,
metricName: String,
currentResult: Number,
testName: String,
notifierHook: (Conclusion) -> Unit) {}
}

View File

@@ -0,0 +1,14 @@
package com.intellij.tools.ide.metrics.collector.collector
import com.intellij.tools.ide.metrics.collector.analysis.Conclusion
data class CompareSetting(
val compareWithPrevResults: Boolean = false,
val table: String = "",
val notifierHook: ((Conclusion) -> Unit) = { }
) {
companion object {
val notComparing = CompareSetting(false)
val withComparing = CompareSetting(true)
}
}

View File

@@ -0,0 +1,34 @@
package com.intellij.tools.ide.metrics.collector.collector
import io.opentelemetry.api.common.Attributes
import io.opentelemetry.sdk.metrics.data.LongPointData
import io.opentelemetry.sdk.metrics.internal.data.ImmutableLongPointData
enum class MetricsSelectionStrategy {
EARLIEST,
/** Usually used to collect gauges */
LATEST,
MINIMUM,
MAXIMUM,
SUM,
AVERAGE;
fun selectMetric(metrics: List<LongPointData>): LongPointData {
return when (this) {
EARLIEST -> metrics.minBy { it.startEpochNanos }
LATEST -> metrics.maxBy { it.epochNanos }
MINIMUM -> metrics.minBy { it.value }
MAXIMUM -> metrics.maxBy { it.value }
SUM -> ImmutableLongPointData.create(selectMetric(metrics).startEpochNanos,
selectMetric(metrics).epochNanos,
Attributes.empty(),
metrics.sumOf { it.value })
AVERAGE -> ImmutableLongPointData.create(selectMetric(metrics).startEpochNanos,
selectMetric(metrics).epochNanos,
Attributes.empty(),
selectMetric(metrics).value / metrics.size)
}
}
}

View File

@@ -0,0 +1,37 @@
package com.intellij.tools.ide.metrics.collector.collector
import com.intellij.openapi.util.BuildNumber
import com.intellij.tools.ide.metrics.collector.publishing.ApplicationMetricDto
import java.time.OffsetDateTime
data class PerformanceMetrics(
val buildNumber: BuildNumber,
val generatedTime: OffsetDateTime,
val projectName: String,
val machineName: String,
val branchName: String,
val os: String,
val metrics: List<Metric>
) {
sealed class MetricId {
abstract val name: String
/**
* Metric used to measure duration of events in ms
*/
data class Duration(override val name: String) : MetricId()
/**
* Metric used to count the number of times an event has occurred
*/
data class Counter(override val name: String) : MetricId()
}
data class Metric(val id: MetricId, val value: Long, val compareSetting: CompareSetting = CompareSetting.notComparing)
}
fun PerformanceMetrics.Metric.toJson() = ApplicationMetricDto(
n = id.name,
d = if (id is PerformanceMetrics.MetricId.Duration) this.value else null,
c = if (id is PerformanceMetrics.MetricId.Counter) this.value else null
)

View File

@@ -0,0 +1,39 @@
package com.intellij.tools.ide.metrics.collector.collector
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.intellij.tools.ide.metrics.collector.publishing.ApplicationMetricDto
import com.intellij.openapi.util.BuildNumber
import com.intellij.openapi.util.SystemInfo
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter
@JsonIgnoreProperties(ignoreUnknown = true)
data class PerformanceMetricsDto(
val generated: String,
val project: String,
val os: String,
val osFamily: String,
val runtime: String,
val build: String,
val buildDate: String,
val productCode: String,
val metrics: List<ApplicationMetricDto>
) {
companion object {
fun create(
projectName: String,
buildNumber: BuildNumber,
metrics: Collection<PerformanceMetrics.Metric>
) = PerformanceMetricsDto(
generated = ZonedDateTime.now().format(DateTimeFormatter.RFC_1123_DATE_TIME),
project = projectName,
os = SystemInfo.getOsNameAndVersion(),
osFamily = SystemInfo.getOsFamily().toString(),
runtime = SystemInfo.JAVA_VENDOR + " " + SystemInfo.JAVA_VERSION + " " + SystemInfo.JAVA_RUNTIME_VERSION,
build = buildNumber.asStringWithoutProductCode(),
buildDate = ZonedDateTime.now().format(DateTimeFormatter.RFC_1123_DATE_TIME),
productCode = buildNumber.productCode,
metrics = metrics.map { it.toJson() }
)
}
}

View File

@@ -0,0 +1,9 @@
package com.intellij.tools.ide.metrics.collector.collector
import java.util.*
data class MetricData<T : Number>(val name: String, val data: DataPoint<T>)
data class DataPoint<T : Number>(val value: T, val measurementTime: Date)
data class MetricGroup(val name: String, val metrics: Map<String, LinkedList<DataPoint<*>>>)

View File

@@ -0,0 +1,155 @@
package com.intellij.tools.ide.metrics.collector.metrics
import com.intellij.tools.ide.metrics.collector.collector.PerformanceMetrics.Metric
import com.intellij.tools.ide.metrics.collector.collector.PerformanceMetrics.MetricId.Counter
import com.intellij.tools.ide.metrics.collector.collector.PerformanceMetrics.MetricId.Duration
import com.intellij.tools.ide.metrics.collector.telemetry.MetricSpanProcessor
import com.intellij.tools.ide.metrics.collector.telemetry.OpentelemetryJsonParser
import com.intellij.tools.ide.metrics.collector.telemetry.SpanFilter
import com.intellij.tools.ide.metrics.collector.telemetry.SpanInfoProcessor
import com.intellij.openapi.diagnostic.logger
import com.intellij.util.alsoIfNull
import java.io.File
import kotlin.math.pow
import kotlin.math.sqrt
const val TOTAL_TEST_TIMER_NAME: String = "test"
const val DEFAULT_SPAN_NAME: String = "performance_test"
data class MetricWithAttributes(val metric: Metric,
val attributes: MutableList<Metric> = mutableListOf())
private val logger = logger<OpentelemetryJsonParser>()
/**
* Reports duration of `nameSpan` and all its children spans.
* Besides, all attributes are reported as counters.
* If there are multiple values with the same name:
* 1. They will be re-numbered `<value>_1`, `<value>_2`, etc. and the sum will be recorded as `<value>`.
* 2. In the sum value, mean value and standard deviation of attribute value will be recorded
* 2a. If attribute ends with `#max`, in sum the max of max will be recorded
* 3a. If attribute ends with `#mean_value`, the mean value of mean values will be recorded
*/
fun getMetricsFromSpanAndChildren(file: File, filter: SpanFilter): List<Metric> {
val spanElements = OpentelemetryJsonParser(filter).getSpanElements(file)
val metricSpanProcessor = MetricSpanProcessor()
val spanToMetricMap = spanElements.map { metricSpanProcessor.process(it) }
.filterNotNull()
.groupBy { it.metric.id.name }
return combineMetrics(spanToMetricMap)
}
/**
* Returns a list of metrics based on the difference between two spans.
*
* @param name The name of the metric.
* @param file The file containing the spans.
* @param fromSpanName The name of the "from" span.
* @param toSpanName The name of the "to" span.
* @return A list of metrics.
* @throws IllegalStateException if the fromSpan or toSpan is null.
* @throws IllegalArgumentException if the size of the toSpans is not greater than or equal to the size of the fromSpans.
*/
fun getMetricsBasedOnDiffBetweenSpans(name: String, file: File, fromSpanName: String, toSpanName: String) : List<Metric> {
val betweenSpanProcessor = SpanInfoProcessor()
val spanElements = OpentelemetryJsonParser(SpanFilter.containsIn(listOf(fromSpanName, toSpanName))).getSpanElements(file)
val spanToMetricMap = spanElements
.map { betweenSpanProcessor.process(it) }
.filterNotNull()
.groupBy { it.name }
val fromSpanMetrics = spanToMetricMap[fromSpanName].alsoIfNull { throw IllegalStateException("Spans $fromSpanName is null") }!!
val toSpanMetrics = spanToMetricMap[toSpanName].alsoIfNull { throw IllegalStateException("Spans $toSpanName is null") }!!
assert(toSpanMetrics.size >= fromSpanMetrics.size) {
"Size of toSpans (${toSpanMetrics.size}) must be >= size of fromSpans(${fromSpanMetrics.size})"
}
val metrics = mutableListOf<MetricWithAttributes>()
val sortedFromSpans = fromSpanMetrics.sortedByDescending { info -> info.startTimestamp }
val spanIds = sortedFromSpans.map { it.spanId }.toSet()
val sortedToSpans = toSpanMetrics.sortedByDescending { info -> info.startTimestamp }.filter { spanIds.contains(it.parentSpanId) }
for(i in fromSpanMetrics.indices) {
val currentToSpan = sortedToSpans[i]
val currentFromSpan = sortedFromSpans[i]
if (currentFromSpan.spanId != currentToSpan.parentSpanId) {
logger.warn(
"Current span $fromSpanName with spanId ${currentToSpan.spanId} have ${currentToSpan.parentSpanId}, but expected ${currentFromSpan.spanId}")
}
val duration = currentToSpan.startTimestamp - currentFromSpan.startTimestamp + currentToSpan.duration
val metric = MetricWithAttributes(Metric(Duration(name), duration))
metrics.add(metric)
}
return combineMetrics(mapOf(name to metrics))
}
fun getSpansMetricsMap(file: File,
spanFilter: SpanFilter = SpanFilter { true }): Map<String, List<MetricWithAttributes>> {
val spanElements = OpentelemetryJsonParser(spanFilter).getSpanElements(file)
val metricSpanProcessor = MetricSpanProcessor()
val spanToMetricMap = spanElements.map { metricSpanProcessor.process(it) }
.filterNotNull()
.groupBy { it.metric.id.name }
return spanToMetricMap
}
private fun combineMetrics(metrics: Map<String, List<MetricWithAttributes>>): List<Metric> {
val result = mutableListOf<Metric>()
metrics.forEach { entry ->
if (entry.value.size == 1) {
val metric = entry.value.first()
result.addAll(getAttributes(entry.key, metric))
if (metric.metric.id.name != TOTAL_TEST_TIMER_NAME) {
result.add(metric.metric)
}
}
else {
var counter = 1
val mediumAttributes: MutableMap<String, MutableList<Long>> = mutableMapOf()
entry.value.forEach { metric ->
val value = metric.metric.value
val spanUpdatedName = entry.key + "_$counter"
result.add(Metric(Duration(spanUpdatedName), value))
result.addAll(getAttributes(spanUpdatedName, metric))
getAttributes(entry.key, metric).forEach {
val key = it.id.name
val collection = mediumAttributes.getOrDefault(key, mutableListOf())
collection.add(it.value)
mediumAttributes[key] = collection
}
counter++
}
for (attr in mediumAttributes) {
if (attr.key.endsWith("#max")) {
result.add(Metric(Duration(attr.key), attr.value.max()))
continue
}
if (attr.key.endsWith("#p90")) {
continue
}
if (attr.key.endsWith("#mean_value")) {
result.add(Metric(Duration(attr.key), attr.value.average().toLong()))
continue
}
result.add(Metric(Duration(attr.key + "#mean_value"), attr.value.average().toLong()))
result.add(Metric(Duration(attr.key + "#standard_deviation"), standardDeviation(attr.value)))
}
val sum = entry.value.sumOf { it.metric.value }
val mean = sum / entry.value.size
val standardDeviation = standardDeviation(entry.value.map { it.metric.value })
result.add(Metric(Duration(entry.key), sum))
result.add(Metric(Duration(entry.key + "#mean_value"), mean))
result.add(Metric(Duration(entry.key + "#standard_deviation"), standardDeviation))
}
}
return result
}
private fun <T : Number> standardDeviation(data: Collection<T>): Long {
val mean = data.map { it.toDouble() }.average()
return sqrt(data.map { (it.toDouble() - mean).pow(2) }.average()).toLong()
}
private fun getAttributes(spanName: String, metric: MetricWithAttributes): Collection<Metric> {
return metric.attributes.map { attributeMetric ->
Metric(Counter("$spanName#" + attributeMetric.id.name), attributeMetric.value)
}
}

View File

@@ -0,0 +1,14 @@
package com.intellij.tools.ide.metrics.collector.metrics
import com.intellij.tools.ide.metrics.collector.collector.PerformanceMetrics
fun String.createPerformanceMetricCounter(): PerformanceMetrics.MetricId.Counter = PerformanceMetrics.MetricId.Counter(this)
fun String.createPerformanceMetricDuration(): PerformanceMetrics.MetricId.Duration = PerformanceMetrics.MetricId.Duration(this)
fun findMetricValue(metrics: List<PerformanceMetrics.Metric>, metric: PerformanceMetrics.MetricId.Duration): Number = try {
metrics.first { it.id.name == metric.name }.value
}
catch (e: NoSuchElementException) {
throw NoSuchElementException("Metric with name '${metric.name}' wasn't found")
}

View File

@@ -0,0 +1,27 @@
package com.intellij.tools.ide.metrics.collector.publishing
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.annotation.JsonInclude
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
data class ApplicationMetricDto(
/**
* Metric name.
*/
val n: String,
/**
* Used for "duration" metrics.
*/
val d: Long? = null,
/**
* Used for "counter" metrics.
*/
val c: Long? = null,
val v: Long? = d ?: c
) {
init {
require((d != null) xor (c != null))
}
}

View File

@@ -0,0 +1,63 @@
package com.intellij.tools.ide.metrics.collector.telemetry
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import java.io.File
class OpentelemetryJsonParser(private val spanFilter: SpanFilter) {
private fun getSpans(file: File): JsonNode {
val json = file.readText()
//TODO workaround for non valid intermediate json
val root = jacksonObjectMapper().readTree(if (json.endsWith(",")) json else "$json]}]}")
val data = root.get("data")
if (data == null || data.isEmpty) {
throw IllegalArgumentException("Not 'data' node in json")
}
if (data[0] == null || data[0].isEmpty) {
throw IllegalArgumentException("First data element is absent")
}
val allSpans = data[0].get("spans")
if (allSpans == null || allSpans.isEmpty)
throw IllegalStateException("No spans was found")
return allSpans
}
private fun getParentToSpansMap(file: File): Map<String, Set<SpanElement>> {
val indexParentToChild = mutableMapOf<String, MutableSet<SpanElement>>()
val spans = getSpans(file)
for (span in spans) {
val parentSpanId = span.getParentSpanId()
if (parentSpanId != null) {
indexParentToChild.getOrPut(parentSpanId) { mutableSetOf() }.add(span.toSpanElement())
}
}
return indexParentToChild
}
fun getSpanElements(file: File): Sequence<SpanElement> {
val spans = getSpanElements(getSpans(file))
val index = getParentToSpansMap(file)
val filter = spans.filter { spanElement -> spanFilter.filter.invoke(spanElement.name) }
val result = mutableSetOf<SpanElement>()
filter.forEach {
result.add(it)
processChild(result, it, index)
}
return result.asSequence()
}
private fun processChild(result: MutableSet<SpanElement>, parent: SpanElement, index: Map<String, Collection<SpanElement>>) {
index[parent.spanId]?.forEach {
if (parent.isWarmup) {
it.isWarmup = true
}
result.add(it)
processChild(result, it, index)
}
}
private fun getSpanElements(node: JsonNode): Sequence<SpanElement> {
return node.iterator().asSequence().map { it.toSpanElement() }
}
}

View File

@@ -0,0 +1,66 @@
package com.intellij.tools.ide.metrics.collector.telemetry
import com.fasterxml.jackson.databind.JsonNode
import kotlin.math.roundToLong
/**
* Represents a span element that defines a unit of work or a segment of time.
*
* @property isWarmup Indicates whether this span element is a warm-up span.
* @property name The name of the span element.
* @property duration The duration of the span element in milliseconds.
* @property startTimestamp The timestamp when the span element started, in milliseconds.
* @property spanId The unique identifier for the span element.
* @property parentSpanId The unique identifier of the parent span element, if any.
* @property tags The list of key-value pairs representing the tags associated with the span element.
*/
data class SpanElement(var isWarmup: Boolean,
val name: String,
val duration: Long,
val startTimestamp: Long,
val spanId: String,
val parentSpanId: String?,
val tags: List<Pair<String, String>>)
fun JsonNode.toSpanElement(): SpanElement {
val spanName = this.spanName()
val duration = getDuration(this)
val startTimestamp = getStartTime(this)
val tags = getTags(this)
val isWarmup = isWarmup(tags)
val spanId = this.get("spanID").textValue()
val parentSpanId = this.getParentSpanId()
return SpanElement(isWarmup, spanName, duration, startTimestamp, spanId, parentSpanId, tags)
}
fun JsonNode.spanName(): String {
return this.get("operationName").textValue()
}
fun JsonNode.getParentSpanId(): String? {
this.get("references")?.forEach { reference ->
if (reference.get("refType")?.textValue() == "CHILD_OF") {
val spanId = reference.get("spanID").textValue()
return spanId
}
}
return null
}
private fun getTags(span: JsonNode): List<Pair<String, String>> {
val tags = mutableListOf<Pair<String, String>>()
span.get("tags")?.forEach { tag ->
val attributeName = tag.get("key").textValue()
val textValue = tag.get("value").textValue()
tags.add(Pair(attributeName, textValue))
}
return tags
}
private fun getDuration(span: JsonNode) = (span.get("duration").longValue() / 1000.0).roundToLong()
private fun getStartTime(span: JsonNode) = (span.get("startTime").longValue() / 1000.0).roundToLong()
private fun isWarmup(tags: List<Pair<String, String>>): Boolean {
return tags.find { it.first == "warmup" && it.second == "true" } != null
}

View File

@@ -0,0 +1,9 @@
package com.intellij.tools.ide.metrics.collector.telemetry
class SpanFilter(val filter: (String) -> Boolean) {
companion object {
fun equals(name: String) = SpanFilter { it == name }
fun containsIn(names: List<String>) = SpanFilter { it in names }
fun contain(substring: String) = SpanFilter { it.contains(substring) }
}
}

View File

@@ -0,0 +1,10 @@
package com.intellij.tools.ide.metrics.collector.telemetry
class SpanInfoProcessor : SpanProcessor<SpanElement> {
override fun process(span: SpanElement): SpanElement? {
if (!span.isWarmup) {
return span
}
return null
}
}

View File

@@ -0,0 +1,48 @@
package com.intellij.tools.ide.metrics.collector.telemetry
import com.intellij.tools.ide.metrics.collector.collector.PerformanceMetrics
import com.intellij.tools.ide.metrics.collector.metrics.MetricWithAttributes
interface SpanProcessor<T> {
/**
* Processes the given `span` element.
*
* @param span The `SpanElement` to process.
* @return The result of the processing, or `null` if no result is available.
*/
fun process(span: SpanElement): T?
}
class MetricSpanProcessor : SpanProcessor<MetricWithAttributes> {
override fun process(span: SpanElement): MetricWithAttributes? {
if (!span.isWarmup && (span.duration > 0 || !shouldAvoidIfZero(span))) {
val metrics = MetricWithAttributes(PerformanceMetrics.Metric(PerformanceMetrics.MetricId.Duration(span.name), span.duration))
populateAttributes(metrics, span)
return metrics
}
return null
}
}
private fun shouldAvoidIfZero(span: SpanElement): Boolean {
span.tags.forEach { tag ->
val attributeName = tag.first
if (attributeName == "avoid_null_value") {
tag.second.runCatching { toBoolean() }.onSuccess {
return it
}
}
}
return false
}
private fun populateAttributes(metric: MetricWithAttributes, span: SpanElement) {
span.tags.forEach { tag ->
val attributeName = tag.first
tag.second.runCatching { toInt() }.onSuccess {
metric.attributes.add(PerformanceMetrics.Metric(PerformanceMetrics.MetricId.Counter(attributeName), it.toLong()))
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,288 @@
package com.intellij.tools.ide.metrics.collector
import com.intellij.tools.ide.metrics.collector.collector.PerformanceMetrics.Metric
import com.intellij.tools.ide.metrics.collector.collector.PerformanceMetrics.MetricId.Counter
import com.intellij.tools.ide.metrics.collector.collector.PerformanceMetrics.MetricId.Duration
import com.intellij.tools.ide.metrics.collector.metrics.getMetricsBasedOnDiffBetweenSpans
import com.intellij.tools.ide.metrics.collector.metrics.getMetricsFromSpanAndChildren
import com.intellij.tools.ide.metrics.collector.telemetry.SpanFilter
import io.kotest.matchers.collections.shouldContainAll
import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder
import org.junit.jupiter.api.Test
import java.nio.file.Paths
import kotlin.io.path.div
class OpenTelemetryTest {
private val openTelemetryReports by lazy {
Paths.get(this::class.java.classLoader.getResource("opentelemetry")!!.toURI())
}
@Test
fun testContainsInFilter() {
val spanNames = listOf("%findUsages", "run activity")
val file = (openTelemetryReports / "opentelemetry.json").toFile()
val expected = spanNames.map { spanName ->
getMetricsFromSpanAndChildren(file, SpanFilter.equals(spanName))
}.flatten()
val result = getMetricsFromSpanAndChildren(file, SpanFilter.containsIn(spanNames))
result.shouldContainExactlyInAnyOrder(expected)
}
@Test
fun metricsCorrectlyCollected() {
val metrics = getMetricsFromSpanAndChildren((openTelemetryReports / "opentelemetry.json").toFile(), SpanFilter.equals("%findUsages"))
metrics.shouldContainExactlyInAnyOrder(listOf(
Metric(Duration("%findUsages_1"), 531),
Metric(Duration("%findUsages_2"), 4110),
Metric(Duration("%findUsages_3"), 3090),
Metric(Duration("%findUsages"), 7731),
Metric(Duration("%findUsages#mean_value"), 2577),
Metric(Duration("%findUsages#standard_deviation"), 1505),
Metric(Duration("FindUsagesManager.startProcessUsages_1"), 510),
Metric(Counter("FindUsagesManager.startProcessUsages_1#number_of_found_usages"), 1),
Metric(Duration("FindUsagesManager.startProcessUsages_2"), 4107),
Metric(Counter("FindUsagesManager.startProcessUsages_2#number_of_found_usages"), 549),
Metric(Duration("FindUsagesManager.startProcessUsages_3"), 3088),
Metric(Counter("FindUsagesManager.startProcessUsages_3#number_of_found_usages"), 844),
Metric(Duration("FindUsagesManager.startProcessUsages"), 7705),
Metric(Duration("FindUsagesManager.startProcessUsages#mean_value"), 2568),
Metric(Duration("FindUsagesManager.startProcessUsages#standard_deviation"), 1513),
Metric(Duration("FindUsagesManager.startProcessUsages#number_of_found_usages#mean_value"), 464),
Metric(Duration("FindUsagesManager.startProcessUsages#number_of_found_usages#standard_deviation"), 349),
))
}
@Test
fun metricsWithSingleSpan() {
val metrics = getMetricsFromSpanAndChildren((openTelemetryReports / "opentelemetry_with_main_timer.json").toFile(),
SpanFilter.equals("performance_test"))
metrics.shouldContainExactlyInAnyOrder(listOf(
Metric(Duration("performance_test"), 13497),
Metric(Duration("delayType"), 3739),
Metric(Counter("test#max_awt_delay"), 141),
Metric(Counter("test#average_awt_delay"), 8),
))
}
@Test
fun metricsCorrectlyCollected2() {
val metrics = getMetricsFromSpanAndChildren((openTelemetryReports / "opentelemetry2.json").toFile(),
SpanFilter.equals("performance_test"))
metrics.shouldContainExactlyInAnyOrder(listOf(
Metric(Duration("performance_test"), 81444),
Metric(Duration("timer_1"), 1184),
Metric(Counter("timer_1#average_awt_delay"), 3),
Metric(Counter("timer_1#max_awt_delay"), 57),
Metric(Duration("timer_2"), 1519),
Metric(Counter("timer_2#average_awt_delay"), 7),
Metric(Counter("timer_2#max_awt_delay"), 84),
Metric(Duration("timer"), 2703),
Metric(Duration("timer#mean_value"), 1351),
Metric(Duration("timer#standard_deviation"), 167),
Metric(Duration("findUsages_1"), 1205),
Metric(Duration("findUsages_2"), 1184),
Metric(Counter("findUsages_2#number_of_found_usages"), 1384),
Metric(Duration("findUsages#standard_deviation"), 10),
Metric(Duration("findUsages"), 2389),
Metric(Duration("findUsages#mean_value"), 1194),
Metric(Duration("timer#max_awt_delay#mean_value"), 70),
Metric(Duration("timer#max_awt_delay#standard_deviation"), 13),
Metric(Duration("findUsages#number_of_found_usages#mean_value"), 1384),
Metric(Duration("findUsages#number_of_found_usages#standard_deviation"), 0),
Metric(Duration("timer#average_awt_delay#mean_value"), 5),
Metric(Duration("timer#average_awt_delay#standard_deviation"), 2),
))
}
@Test
fun metricsCorrectlyCollectedAvoidingZeroValue() {
val metrics = getMetricsFromSpanAndChildren((openTelemetryReports / "opentelemetry_with_zero_values.json").toFile(),
SpanFilter.equals("performance_test"))
metrics.shouldContainExactlyInAnyOrder(listOf(
Metric(Duration("performance_test"), 27990),
Metric(Duration("firstCodeAnalysis"), 1726),
Metric(Duration("typing_1"), 158),
Metric(Duration("typing_2"), 44),
Metric(Duration("typing_3"), 5),
Metric(Duration("typing_4"), 3),
Metric(Duration("typing_5"), 3),
Metric(Duration("typing_6"), 3),
Metric(Duration("typing"), 216),
Metric(Duration("typing#mean_value"), 36),
Metric(Duration("typing#standard_deviation"), 56),
Metric(Duration("completion_1"), 539),
Metric(Counter("completion_1#number"), 635),
Metric(Duration("completion_2"), 149),
Metric(Counter("completion_2#number"), 635),
Metric(Duration("completion_3"), 131),
Metric(Counter("completion_3#number"), 635),
Metric(Duration("completion_4"), 116),
Metric(Counter("completion_4#number"), 635),
Metric(Duration("completion_5"), 109),
Metric(Counter("completion_5#number"), 635),
Metric(Duration("completion#number#mean_value"), 635),
Metric(Duration("completion#number#standard_deviation"), 0),
Metric(Duration("completion"), 1044),
Metric(Duration("completion#mean_value"), 208),
Metric(Duration("completion#standard_deviation"), 165),
Metric(Duration("invokeCompletion_1"), 543),
Metric(Counter("invokeCompletion_1#caretOffset"), 270),
Metric(Duration("invokeCompletion_2"), 150),
Metric(Counter("invokeCompletion_2#caretOffset"), 270),
Metric(Duration("invokeCompletion_3"), 131),
Metric(Counter("invokeCompletion_3#caretOffset"), 270),
Metric(Duration("invokeCompletion_4"), 117),
Metric(Counter("invokeCompletion_4#caretOffset"), 270),
Metric(Duration("invokeCompletion_5"), 110),
Metric(Counter("invokeCompletion_5#caretOffset"), 270),
Metric(Duration("invokeCompletion#caretOffset#mean_value"), 270),
Metric(Duration("invokeCompletion#caretOffset#standard_deviation"), 0),
Metric(Duration("invokeCompletion"), 1051),
Metric(Duration("invokeCompletion#mean_value"), 210),
Metric(Duration("invokeCompletion#standard_deviation"), 166),
Metric(Duration("performCompletion_1"), 303),
Metric(Counter("performCompletion_1#lookupsFound"), 635),
Metric(Duration("performCompletion_2"), 59),
Metric(Counter("performCompletion_2#lookupsFound"), 635),
Metric(Duration("performCompletion_3"), 63),
Metric(Counter("performCompletion_3#lookupsFound"), 635),
Metric(Duration("performCompletion_4"), 50),
Metric(Counter("performCompletion_4#lookupsFound"), 635),
Metric(Duration("performCompletion_5"), 50),
Metric(Counter("performCompletion_5#lookupsFound"), 635),
Metric(Duration("performCompletion#lookupsFound#mean_value"), 635),
Metric(Duration("performCompletion#lookupsFound#standard_deviation"), 0),
Metric(Duration("performCompletion"), 525),
Metric(Duration("performCompletion#mean_value"), 105),
Metric(Duration("performCompletion#standard_deviation"), 99),
Metric(Duration("ComboEditorCompletionContributor"), 3),
Metric(Duration("ContextFeaturesContributor_1"), 17),
Metric(Duration("ContextFeaturesContributor_2"), 1),
Metric(Duration("ContextFeaturesContributor_3"), 1),
Metric(Duration("ContextFeaturesContributor_4"), 1),
Metric(Duration("ContextFeaturesContributor_5"), 1),
Metric(Duration("ContextFeaturesContributor"), 21),
Metric(Duration("ContextFeaturesContributor#mean_value"), 4),
Metric(Duration("ContextFeaturesContributor#standard_deviation"), 6),
Metric(Duration("LiveTemplateCompletionContributor_1"), 274),
Metric(Duration("LiveTemplateCompletionContributor_2"), 58),
Metric(Duration("LiveTemplateCompletionContributor_3"), 62),
Metric(Duration("LiveTemplateCompletionContributor_4"), 49),
Metric(Duration("LiveTemplateCompletionContributor_5"), 49),
Metric(Duration("LiveTemplateCompletionContributor"), 492),
Metric(Duration("LiveTemplateCompletionContributor#mean_value"), 98),
Metric(Duration("LiveTemplateCompletionContributor#standard_deviation"), 87),
Metric(Duration("FilePathCompletionContributor"), 1),
Metric(Duration("UrlPathReferenceCompletionContributor"), 3),
Metric(Duration("PhpNamedArgumentsCompletionContributor"), 9),
Metric(Duration("PhpKeywordsCompletionContributor"), 5),
Metric(Duration("PhpCompletionContributor_1"), 194),
Metric(Duration("PhpCompletionContributor_2"), 56),
Metric(Duration("PhpCompletionContributor_3"), 60),
Metric(Duration("PhpCompletionContributor_4"), 47),
Metric(Duration("PhpCompletionContributor_5"), 47),
Metric(Duration("PhpCompletionContributor"), 404),
Metric(Duration("PhpCompletionContributor#mean_value"), 80),
Metric(Duration("PhpCompletionContributor#standard_deviation"), 56),
Metric(Duration("CssClassOrIdReferenceCompletionContributor"), 2),
Metric(Duration("LegacyCompletionContributor"), 1),
Metric(Duration("arrangeItems_1"), 70),
Metric(Duration("arrangeItems_2"), 43),
Metric(Duration("arrangeItems_3"), 21),
Metric(Duration("arrangeItems_4"), 15),
Metric(Duration("arrangeItems_5"), 13),
Metric(Duration("arrangeItems_6"), 12),
Metric(Duration("arrangeItems_7"), 12),
Metric(Duration("arrangeItems_8"), 10),
Metric(Duration("arrangeItems_9"), 11),
Metric(Duration("arrangeItems_10"), 12),
Metric(Duration("arrangeItems_11"), 11),
Metric(Duration("arrangeItems_12"), 12),
Metric(Duration("arrangeItems_13"), 10),
Metric(Duration("arrangeItems_14"), 9),
Metric(Duration("arrangeItems_15"), 10),
Metric(Duration("arrangeItems"), 271),
Metric(Duration("arrangeItems#mean_value"), 18),
Metric(Duration("arrangeItems#standard_deviation"), 16),
Metric(Counter("test#max_awt_delay"), 714),
Metric(Counter("test#average_awt_delay"), 7),
))
}
@Test
fun metricsWithAttributesMaxAndMeanValue() {
val metrics = getMetricsFromSpanAndChildren((openTelemetryReports / "opentelemetry_with_max_mean_attributes.json").toFile(),
SpanFilter.equals("performance_test"))
metrics.shouldContainAll(listOf(
Metric(Duration("typing#latency#max"), 51),
Metric(Duration("typing#latency#mean_value"), 3),
))
}
@Test
fun opentelemetryWithWarmupSpans() {
val metrics = getMetricsFromSpanAndChildren((openTelemetryReports / "opentelemetry_with_warmup_spans.json").toFile(),
SpanFilter.equals("performance_test"))
metrics.shouldContainAll(listOf(
Metric(Duration("localInspections#mean_value"), 369),
Metric(Duration("localInspections_1"), 375),
Metric(Duration("localInspections_2"), 373),
Metric(Duration("localInspections_3"), 367),
Metric(Duration("localInspections_4"), 361),
Metric(Duration("localInspections_5"), 370),
Metric(Duration("localInspections"), 1846),
Metric(Duration("localInspections#Warnings#mean_value"), 4),
Metric(Counter("localInspections_1#Warnings"), 4),
))
val find = metrics.find { it.id.name == "localInspections_6" }
assert(find == null) {
"Must be 5 localInspections"
}
}
@Test
fun diffBetweenMetrics() {
val metrics = getMetricsBasedOnDiffBetweenSpans("semanticHighlighting",
(openTelemetryReports / "opentelemetry_with_warmup_spans.json").toFile(),
"localInspections", "GeneralHighlightingPass")
metrics.shouldContainAll(listOf(
Metric(Duration("semanticHighlighting_1"), 349),
Metric(Duration("semanticHighlighting_2"), 339),
Metric(Duration("semanticHighlighting_3"), 341),
Metric(Duration("semanticHighlighting_4"), 350),
Metric(Duration("semanticHighlighting_5"), 351),
Metric(Duration("semanticHighlighting"), 1730),
Metric(Duration("semanticHighlighting#mean_value"), 346),
))
val find = metrics.find { it.id.name == "semanticHighlighting_6" }
assert(find == null) {
"Must be 5 semanticHighlighting"
}
}
@Test
fun findUsageWithWarmUp() {
val metrics = getMetricsFromSpanAndChildren((openTelemetryReports / "opentelemetry_findUsage_with_warmup.json").toFile(),
SpanFilter.equals("performance_test"))
metrics.shouldContainAll(listOf(
Metric(Duration("findUsagesParent_1"), 362),
Metric(Duration("findUsagesParent_2"), 337),
Metric(Duration("findUsagesParent_3"), 336),
Metric(Duration("findUsagesParent_4"), 320),
Metric(Duration("findUsagesParent_5"), 350),
Metric(Duration("findUsagesParent_6"), 342),
Metric(Duration("findUsagesParent_7"), 340),
Metric(Duration("findUsagesParent_8"), 289),
Metric(Duration("findUsagesParent_9"), 326),
Metric(Duration("findUsagesParent_10"), 340),
))
val find = metrics.find { it.id.name == "findUsagesParent_11" }
assert(find == null) {
"Must be 10 findUsagesParent"
}
}
}