From b2fdded55c969716849d461fc063f89746f8b9d5 Mon Sep 17 00:00:00 2001 From: "minwoo.jung" Date: Tue, 15 Oct 2024 18:25:20 +0900 Subject: [PATCH] [#10776] Improved API to store stackDetails and samplingInterval values --- .../web/defined/AppMetricDefinition.java | 14 +++++++++-- .../otlp/common/web/defined/StackDetails.java | 23 +++++++++++++++++++ .../OpenTelemetryMetricController.java | 6 ++--- 3 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 otlpmetric/otlpmetric-common/src/main/java/com/navercorp/pinpoint/otlp/common/web/defined/StackDetails.java diff --git a/otlpmetric/otlpmetric-common/src/main/java/com/navercorp/pinpoint/otlp/common/web/defined/AppMetricDefinition.java b/otlpmetric/otlpmetric-common/src/main/java/com/navercorp/pinpoint/otlp/common/web/defined/AppMetricDefinition.java index 81d5cf1013d8..a3411b66fee0 100644 --- a/otlpmetric/otlpmetric-common/src/main/java/com/navercorp/pinpoint/otlp/common/web/defined/AppMetricDefinition.java +++ b/otlpmetric/otlpmetric-common/src/main/java/com/navercorp/pinpoint/otlp/common/web/defined/AppMetricDefinition.java @@ -41,8 +41,10 @@ public class AppMetricDefinition { private final String aggregationFunction; private final Layout layout; private final boolean stack; + private final StackDetails stackDetails; + private final int samplingInterval; - public AppMetricDefinition(String applicationName, String id, String title, String metricGroupName, String metricName, String primaryForFieldAndTagRelation, List fieldNameList, List tagGroupList, String unit, String chartType, Layout layout, boolean stack) { + public AppMetricDefinition(String applicationName, String id, String title, String metricGroupName, String metricName, String primaryForFieldAndTagRelation, List fieldNameList, List tagGroupList, String unit, String chartType, Layout layout, boolean stack, StackDetails stackDetails, int samplingInterval) { this.applicationName = StringPrecondition.requireHasLength(applicationName, "applicationName"); this.id = id; this.title = StringPrecondition.requireHasLength(title, "title"); @@ -58,6 +60,8 @@ public AppMetricDefinition(String applicationName, String id, String title, Stri this.aggregationFunction = StringPrecondition.requireHasLength(chartType, "aggregationFunction"); this.layout = Objects.requireNonNull(layout, "layout"); this.stack = stack; + this.stackDetails = stackDetails; + this.samplingInterval = samplingInterval; } public String getApplicationName() { @@ -104,7 +108,6 @@ public String getAggregationFunction() { return aggregationFunction; } - public int getSchemaVersion() { return SCHEMA_VERSION; } @@ -121,4 +124,11 @@ public String getPrimaryForFieldAndTagRelation() { return primaryForFieldAndTagRelation; } + public StackDetails getStackDetails() { + return stackDetails; + } + + public int getSamplingInterval() { + return samplingInterval; + } } diff --git a/otlpmetric/otlpmetric-common/src/main/java/com/navercorp/pinpoint/otlp/common/web/defined/StackDetails.java b/otlpmetric/otlpmetric-common/src/main/java/com/navercorp/pinpoint/otlp/common/web/defined/StackDetails.java new file mode 100644 index 000000000000..35bea0053705 --- /dev/null +++ b/otlpmetric/otlpmetric-common/src/main/java/com/navercorp/pinpoint/otlp/common/web/defined/StackDetails.java @@ -0,0 +1,23 @@ +/* + * Copyright 2024 NAVER Corp. + * + * 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 + * + * http://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.navercorp.pinpoint.otlp.common.web.defined; + +/** + * @author minwoo-jung + */ +public record StackDetails(boolean showTotal) { +} diff --git a/otlpmetric/otlpmetric-web/src/main/java/com/navercorp/pinpoint/otlp/web/controller/OpenTelemetryMetricController.java b/otlpmetric/otlpmetric-web/src/main/java/com/navercorp/pinpoint/otlp/web/controller/OpenTelemetryMetricController.java index 0f570ed87175..6c3f3027e01b 100644 --- a/otlpmetric/otlpmetric-web/src/main/java/com/navercorp/pinpoint/otlp/web/controller/OpenTelemetryMetricController.java +++ b/otlpmetric/otlpmetric-web/src/main/java/com/navercorp/pinpoint/otlp/web/controller/OpenTelemetryMetricController.java @@ -42,14 +42,13 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import java.util.Arrays; import java.util.List; import java.util.Objects; @RestController @RequestMapping(value = "/api/otlp") public class OpenTelemetryMetricController { - private final TimeWindowSampler DEFAULT_TIME_WINDOW_SAMPLER_30M = new TimeWindowSlotCentricSampler(30000L, 200); + private final TimeWindowSampler DEFAULT_TIME_WINDOW_SAMPLER_30S = new TimeWindowSlotCentricSampler(30000L, 200); private final OtlpMetricWebService otlpMetricWebService; private static final String DEFAULT_SERVICE_ID = "00000000-0000-0000-0000-000000000001"; @NotBlank @@ -61,7 +60,6 @@ public OpenTelemetryMetricController(OtlpMetricWebService otlpMetricWebService, this.rangeValidator = Objects.requireNonNull(rangeValidator, "rangeValidator"); Objects.requireNonNull(tenantProvider, "tenantProvider"); tenantId = tenantProvider.getTenantId(); - } @Deprecated @@ -112,7 +110,7 @@ public MetricDataView getMetricChartDataV3(@Valid @RequestBody MetricDataRequest Range range = Range.between(parameter.getFrom(), parameter.getTo()); rangeValidator.validate(range.getFromInstant(), range.getToInstant()); - TimeWindow timeWindow = new TimeWindow(range, DEFAULT_TIME_WINDOW_SAMPLER_30M); + TimeWindow timeWindow = new TimeWindow(range, DEFAULT_TIME_WINDOW_SAMPLER_30S); MetricData metricData = otlpMetricWebService.getMetricData(tenantId, DEFAULT_SERVICE_ID, parameter.getApplicationName(), parameter.getAgentId(), parameter.getMetricGroupName(), parameter.getMetricName(), primaryForFieldAndTagRelation, tagGroupList, fieldNameList, chartType, aggregationFunction, timeWindow); return new MetricDataView(metricData);