mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 13:31:28 +07:00
Introduce customizable IJPerfMetricsDto
We support double values for some databases so base class should be customizable but at the same time we want to enforce Long for all other DBs GitOrigin-RevId: 8ee4c538f8bd8ec584758ca05c4b7d6148d1f85f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
01c2920b53
commit
4ec3401b61
@@ -3,11 +3,11 @@ package com.intellij.cce.report
|
||||
|
||||
import com.google.gson.GsonBuilder
|
||||
import com.intellij.cce.metric.MetricInfo
|
||||
import com.intellij.cce.report.ijmetric.AiApplicationMetricDto
|
||||
import com.intellij.cce.report.ijmetric.AiPerformanceMetricsDto
|
||||
import com.intellij.cce.util.isUnderTeamCity
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.openapi.util.BuildNumber
|
||||
import com.intellij.tools.ide.metrics.collector.publishing.ApplicationMetricDto
|
||||
import com.intellij.tools.ide.metrics.collector.publishing.CIServerBuildInfo
|
||||
import java.nio.file.Path
|
||||
import java.time.ZonedDateTime
|
||||
@@ -67,9 +67,9 @@ class IntellijPerfJsonReportGenerator(
|
||||
}.create()
|
||||
}
|
||||
|
||||
private fun MetricInfo.toPerfMetric(namePrefix: String = ""): AiApplicationMetricDto {
|
||||
private fun MetricInfo.toPerfMetric(namePrefix: String = ""): ApplicationMetricDto<Double> {
|
||||
val metricName = "${namePrefix}${name}"
|
||||
return AiApplicationMetricDto(metricName, value)
|
||||
return ApplicationMetricDto(metricName, c=value)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,77 +1,5 @@
|
||||
package com.intellij.cce.report.ijmetric
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||
import com.fasterxml.jackson.annotation.JsonInclude
|
||||
import com.intellij.openapi.util.BuildNumber
|
||||
import com.intellij.openapi.util.SystemInfo
|
||||
import com.intellij.tools.ide.metrics.collector.metrics.MetricGroup
|
||||
import com.intellij.tools.ide.metrics.collector.publishing.CIServerBuildInfo
|
||||
import com.intellij.util.system.OS
|
||||
import java.time.ZonedDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
import com.intellij.tools.ide.metrics.collector.publishing.IJPerfMetricsDto
|
||||
|
||||
|
||||
/*
|
||||
copy @com.intellij.tools.ide.metrics.collector.publishing.PerformanceMetricsDto
|
||||
AI metrics requires Double value, but we don't want to change basic types much.
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
data class AiPerformanceMetricsDto(
|
||||
val version: String,
|
||||
val generated: String,
|
||||
val project: String,
|
||||
val projectURL: String,
|
||||
val projectDescription: String,
|
||||
val os: String,
|
||||
val osFamily: String,
|
||||
val runtime: String,
|
||||
val build: String,
|
||||
val buildDate: String,
|
||||
val branch: String,
|
||||
val productCode: String,
|
||||
val methodName: String,
|
||||
val metrics: List<AiApplicationMetricDto>,
|
||||
val systemMetrics: Map<String, List<MetricGroup>>,
|
||||
val tcInfo: CIServerBuildInfo
|
||||
) {
|
||||
companion object {
|
||||
private const val VERSION = "1"
|
||||
|
||||
@JvmStatic
|
||||
fun create(
|
||||
projectName: String,
|
||||
projectURL: String,
|
||||
projectDescription: String,
|
||||
methodName: String,
|
||||
buildNumber: BuildNumber,
|
||||
metrics: List<AiApplicationMetricDto>,
|
||||
buildInfo: CIServerBuildInfo,
|
||||
generated: String = ZonedDateTime.now().format(DateTimeFormatter.RFC_1123_DATE_TIME)
|
||||
) = AiPerformanceMetricsDto(
|
||||
version = VERSION,
|
||||
generated = generated,
|
||||
project = projectName,
|
||||
projectURL = projectURL,
|
||||
os = SystemInfo.getOsNameAndVersion(),
|
||||
osFamily = OS.CURRENT.toString(),
|
||||
runtime = SystemInfo.JAVA_VENDOR + " " + SystemInfo.JAVA_VERSION + " " + SystemInfo.JAVA_RUNTIME_VERSION,
|
||||
build = buildNumber.asStringWithoutProductCode(),
|
||||
branch = buildNumber.asStringWithoutProductCode().substringBeforeLast("."),
|
||||
// the 'buildDate' field is required for https://ij-perf.jetbrains.com; use any value here
|
||||
buildDate = ZonedDateTime.now().format(DateTimeFormatter.RFC_1123_DATE_TIME),
|
||||
productCode = buildNumber.productCode,
|
||||
metrics = metrics,
|
||||
methodName = methodName,
|
||||
systemMetrics = mapOf(),
|
||||
tcInfo = buildInfo,
|
||||
projectDescription = projectDescription
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
data class AiApplicationMetricDto(
|
||||
val n: String,
|
||||
val c: Double,
|
||||
)
|
||||
typealias AiPerformanceMetricsDto = IJPerfMetricsDto<Double>
|
||||
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonInclude
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
data class ApplicationMetricDto(
|
||||
data class ApplicationMetricDto<T : Number>(
|
||||
/**
|
||||
* Metric name.
|
||||
*/
|
||||
@@ -13,13 +13,13 @@ data class ApplicationMetricDto(
|
||||
/**
|
||||
* Used for "duration" metrics.
|
||||
*/
|
||||
val d: Long? = null,
|
||||
val d: T? = null,
|
||||
/**
|
||||
* Used for "counter" metrics.
|
||||
*/
|
||||
val c: Long? = null,
|
||||
val c: T? = null,
|
||||
|
||||
val v: Long? = d ?: c
|
||||
val v: T? = d ?: c
|
||||
) {
|
||||
init {
|
||||
require((d != null) xor (c != null))
|
||||
|
||||
@@ -10,12 +10,14 @@ import com.intellij.util.system.OS
|
||||
import java.time.ZonedDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
||||
|
||||
typealias PerformanceMetricsDto = IJPerfMetricsDto<Long>
|
||||
/**
|
||||
* A JSON schema used to report indexing performance metrics to display on https://ij-perf.jetbrains.com [IDEA-251676].
|
||||
* The generated .json files will be collected by https://github.com/JetBrains/ij-perf-report-aggregator.
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
data class PerformanceMetricsDto(
|
||||
data class IJPerfMetricsDto<T: Number>(
|
||||
val version: String,
|
||||
val generated: String,
|
||||
val project: String,
|
||||
@@ -29,7 +31,7 @@ data class PerformanceMetricsDto(
|
||||
val branch: String,
|
||||
val productCode: String,
|
||||
val methodName: String,
|
||||
val metrics: List<ApplicationMetricDto>,
|
||||
val metrics: List<ApplicationMetricDto<T>>,
|
||||
val systemMetrics: Map<String, List<MetricGroup>>,
|
||||
val tcInfo: CIServerBuildInfo
|
||||
) {
|
||||
@@ -46,7 +48,19 @@ data class PerformanceMetricsDto(
|
||||
metrics: Collection<PerformanceMetrics.Metric>,
|
||||
buildInfo: CIServerBuildInfo,
|
||||
generated: String = ZonedDateTime.now().format(DateTimeFormatter.RFC_1123_DATE_TIME)
|
||||
) = PerformanceMetricsDto(
|
||||
) = create(projectName, projectURL, projectDescription, methodName, buildNumber, metrics.map { it.toJson() }, buildInfo, generated)
|
||||
|
||||
@JvmStatic
|
||||
fun <T: Number> create(
|
||||
projectName: String,
|
||||
projectURL: String,
|
||||
projectDescription: String,
|
||||
methodName: String,
|
||||
buildNumber: BuildNumber,
|
||||
metrics: List<ApplicationMetricDto<T>>,
|
||||
buildInfo: CIServerBuildInfo,
|
||||
generated: String = ZonedDateTime.now().format(DateTimeFormatter.RFC_1123_DATE_TIME)
|
||||
) = IJPerfMetricsDto(
|
||||
version = VERSION,
|
||||
generated = generated,
|
||||
project = projectName,
|
||||
@@ -59,7 +73,7 @@ data class PerformanceMetricsDto(
|
||||
// the 'buildDate' field is required for https://ij-perf.jetbrains.com; use any value here
|
||||
buildDate = ZonedDateTime.now().format(DateTimeFormatter.RFC_1123_DATE_TIME),
|
||||
productCode = buildNumber.productCode,
|
||||
metrics = metrics.map { it.toJson() },
|
||||
metrics = metrics,
|
||||
methodName = methodName,
|
||||
systemMetrics = mapOf(),
|
||||
tcInfo = buildInfo,
|
||||
|
||||
Reference in New Issue
Block a user