-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature-14138][Metrics] Add metrics for api server (#14177)
- Loading branch information
1 parent
0ab2447
commit 5c4ba41
Showing
8 changed files
with
762 additions
and
7 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
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
112 changes: 112 additions & 0 deletions
112
...scheduler-api/src/main/java/org/apache/dolphinscheduler/api/metrics/ApiServerMetrics.java
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,112 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 org.apache.dolphinscheduler.api.metrics; | ||
|
||
import lombok.experimental.UtilityClass; | ||
import io.micrometer.core.instrument.Counter; | ||
import io.micrometer.core.instrument.DistributionSummary; | ||
import io.micrometer.core.instrument.Metrics; | ||
|
||
@UtilityClass | ||
public class ApiServerMetrics { | ||
|
||
private final Counter apiRequestCounter = | ||
Counter.builder("ds.api.request.count") | ||
.description("Api request count") | ||
.register(Metrics.globalRegistry); | ||
|
||
private final Counter apiResponse2xxCounter = | ||
Counter.builder("ds.api.response.count") | ||
.tag("code", "2xx") | ||
.description("Api 2xx response count") | ||
.register(Metrics.globalRegistry); | ||
|
||
private final Counter apiResponse3xxCounter = | ||
Counter.builder("ds.api.response.count") | ||
.tag("code", "3xx") | ||
.description("Api 3xx response count") | ||
.register(Metrics.globalRegistry); | ||
|
||
private final Counter apiResponse4xxCounter = | ||
Counter.builder("ds.api.response.count") | ||
.tag("code", "4xx") | ||
.description("Api 4xx response count") | ||
.register(Metrics.globalRegistry); | ||
|
||
private final Counter apiResponse5xxCounter = | ||
Counter.builder("ds.api.response.count") | ||
.tag("code", "5xx") | ||
.description("Api 5xx response count") | ||
.register(Metrics.globalRegistry); | ||
|
||
private final DistributionSummary apiResourceUploadSizeDistribution = | ||
DistributionSummary.builder("ds.api.resource.upload.size") | ||
.baseUnit("bytes") | ||
.publishPercentiles(0.5, 0.75, 0.95, 0.99) | ||
.publishPercentileHistogram() | ||
.description("size of upload resource files on api") | ||
.register(Metrics.globalRegistry); | ||
|
||
private final DistributionSummary apiResourceDownloadSizeDistribution = | ||
DistributionSummary.builder("ds.api.resource.download.size") | ||
.baseUnit("bytes") | ||
.publishPercentiles(0.5, 0.75, 0.95, 0.99) | ||
.publishPercentileHistogram() | ||
.description("size of download resource files on api") | ||
.register(Metrics.globalRegistry); | ||
|
||
private final DistributionSummary apiResponseTimeDistribution = | ||
DistributionSummary.builder("ds.api.response.time") | ||
.baseUnit("milliseconds") | ||
.publishPercentiles(0.5, 0.75, 0.95, 0.99) | ||
.publishPercentileHistogram() | ||
.description("response time on api") | ||
.register(Metrics.globalRegistry); | ||
|
||
public void incApiRequestCount() { | ||
apiRequestCounter.increment(); | ||
} | ||
|
||
public void incApiResponse2xxCount() { | ||
apiResponse2xxCounter.increment(); | ||
} | ||
|
||
public void incApiResponse3xxCount() { | ||
apiResponse3xxCounter.increment(); | ||
} | ||
|
||
public void incApiResponse4xxCount() { | ||
apiResponse4xxCounter.increment(); | ||
} | ||
|
||
public void incApiResponse5xxCount() { | ||
apiResponse5xxCounter.increment(); | ||
} | ||
|
||
public void recordApiResourceUploadSize(final long size) { | ||
apiResourceUploadSizeDistribution.record(size); | ||
} | ||
|
||
public void recordApiResourceDownloadSize(final long size) { | ||
apiResourceDownloadSizeDistribution.record(size); | ||
} | ||
|
||
public void recordApiResponseTime(final long milliseconds) { | ||
apiResponseTimeDistribution.record(milliseconds); | ||
} | ||
} |
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.