Skip to content

Commit

Permalink
[#10776] Improved API to store stackDetails and samplingInterval values
Browse files Browse the repository at this point in the history
  • Loading branch information
minwoo-jung committed Oct 15, 2024
1 parent eb07dd9 commit b2fdded
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> fieldNameList, List<String> tagGroupList, String unit, String chartType, Layout layout, boolean stack) {
public AppMetricDefinition(String applicationName, String id, String title, String metricGroupName, String metricName, String primaryForFieldAndTagRelation, List<String> fieldNameList, List<String> 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");
Expand All @@ -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() {
Expand Down Expand Up @@ -104,7 +108,6 @@ public String getAggregationFunction() {
return aggregationFunction;
}


public int getSchemaVersion() {
return SCHEMA_VERSION;
}
Expand All @@ -121,4 +124,11 @@ public String getPrimaryForFieldAndTagRelation() {
return primaryForFieldAndTagRelation;
}

public StackDetails getStackDetails() {
return stackDetails;
}

public int getSamplingInterval() {
return samplingInterval;
}
}
Original file line number Diff line number Diff line change
@@ -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) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -61,7 +60,6 @@ public OpenTelemetryMetricController(OtlpMetricWebService otlpMetricWebService,
this.rangeValidator = Objects.requireNonNull(rangeValidator, "rangeValidator");
Objects.requireNonNull(tenantProvider, "tenantProvider");
tenantId = tenantProvider.getTenantId();

}

@Deprecated
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit b2fdded

Please sign in to comment.