-
Notifications
You must be signed in to change notification settings - Fork 839
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add gRPC client attempt metrics (#1037)
* add client attempt and client call metrics
- Loading branch information
Showing
8 changed files
with
995 additions
and
81 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
106 changes: 106 additions & 0 deletions
106
...ot-autoconfigure/src/main/java/net/devh/boot/grpc/client/metrics/MetricsClientMeters.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,106 @@ | ||
/* | ||
* Copyright (c) 2016-2023 The gRPC-Spring 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 | ||
* | ||
* 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 net.devh.boot.grpc.client.metrics; | ||
|
||
import io.micrometer.core.instrument.Counter; | ||
import io.micrometer.core.instrument.DistributionSummary; | ||
import io.micrometer.core.instrument.Meter.MeterProvider; | ||
import io.micrometer.core.instrument.Timer; | ||
|
||
/* | ||
* Collection of client metrics meters. | ||
*/ | ||
public class MetricsClientMeters { | ||
|
||
private MeterProvider<Counter> attemptCounter; | ||
private MeterProvider<DistributionSummary> sentMessageSizeDistribution; | ||
private MeterProvider<DistributionSummary> receivedMessageSizeDistribution; | ||
private MeterProvider<Timer> clientAttemptDuration; | ||
private MeterProvider<Timer> clientCallDuration; | ||
|
||
private MetricsClientMeters(Builder builder) { | ||
this.attemptCounter = builder.attemptCounter; | ||
this.sentMessageSizeDistribution = builder.sentMessageSizeDistribution; | ||
this.receivedMessageSizeDistribution = builder.receivedMessageSizeDistribution; | ||
this.clientAttemptDuration = builder.clientAttemptDuration; | ||
this.clientCallDuration = builder.clientCallDuration; | ||
} | ||
|
||
public MeterProvider<Counter> getAttemptCounter() { | ||
return this.attemptCounter; | ||
} | ||
|
||
public MeterProvider<DistributionSummary> getSentMessageSizeDistribution() { | ||
return this.sentMessageSizeDistribution; | ||
} | ||
|
||
public MeterProvider<DistributionSummary> getReceivedMessageSizeDistribution() { | ||
return this.receivedMessageSizeDistribution; | ||
} | ||
|
||
public MeterProvider<Timer> getClientAttemptDuration() { | ||
return this.clientAttemptDuration; | ||
} | ||
|
||
public MeterProvider<Timer> getClientCallDuration() { | ||
return this.clientCallDuration; | ||
} | ||
|
||
public static Builder newBuilder() { | ||
return new Builder(); | ||
} | ||
|
||
static class Builder { | ||
|
||
private MeterProvider<Counter> attemptCounter; | ||
private MeterProvider<DistributionSummary> sentMessageSizeDistribution; | ||
private MeterProvider<DistributionSummary> receivedMessageSizeDistribution; | ||
private MeterProvider<Timer> clientAttemptDuration; | ||
private MeterProvider<Timer> clientCallDuration; | ||
|
||
private Builder() {} | ||
|
||
public Builder setAttemptCounter(MeterProvider<Counter> counter) { | ||
this.attemptCounter = counter; | ||
return this; | ||
} | ||
|
||
public Builder setSentMessageSizeDistribution(MeterProvider<DistributionSummary> distribution) { | ||
this.sentMessageSizeDistribution = distribution; | ||
return this; | ||
} | ||
|
||
public Builder setReceivedMessageSizeDistribution(MeterProvider<DistributionSummary> distribution) { | ||
this.receivedMessageSizeDistribution = distribution; | ||
return this; | ||
} | ||
|
||
public Builder setClientAttemptDuration(MeterProvider<Timer> timer) { | ||
this.clientAttemptDuration = timer; | ||
return this; | ||
} | ||
|
||
public Builder setClientCallDuration(MeterProvider<Timer> timer) { | ||
this.clientCallDuration = timer; | ||
return this; | ||
} | ||
|
||
public MetricsClientMeters build() { | ||
return new MetricsClientMeters(this); | ||
} | ||
} | ||
} |
Oops, something went wrong.