-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stats/opencensus: Add OpenCensus metrics support #5923
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8860455
Added speced opencensus instrumentation views that were already present
zasweq bc6f8d4
Unspeced functionality which is perhaps useful
zasweq 5b79a6f
Responded to Doug's comments
zasweq e734716
Responded to Doug's comments and offline discussion
zasweq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
/* | ||
* Copyright 2022 gRPC 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 opencensus | ||
|
||
import ( | ||
"go.opencensus.io/stats" | ||
"go.opencensus.io/stats/view" | ||
"go.opencensus.io/tag" | ||
) | ||
|
||
var ( | ||
keyClientMethod = tag.MustNewKey("grpc_client_method") | ||
keyClientStatus = tag.MustNewKey("grpc_client_status") | ||
) | ||
|
||
// Measures, which are recorded by client stats handler: Note that due to the | ||
// nature of how stats handlers are called on gRPC's client side, the per rpc | ||
// unit is actually per attempt throughout this definition file. | ||
var ( | ||
clientSentMessagesPerRPC = stats.Int64("grpc.io/client/sent_messages_per_rpc", "Number of messages sent in the RPC (always 1 for non-streaming RPCs).", stats.UnitDimensionless) | ||
clientSentBytesPerRPC = stats.Int64("grpc.io/client/sent_bytes_per_rpc", "Total bytes sent across all request messages per RPC.", stats.UnitBytes) | ||
clientReceivedMessagesPerRPC = stats.Int64("grpc.io/client/received_messages_per_rpc", "Number of response messages received per RPC (always 1 for non-streaming RPCs).", stats.UnitDimensionless) | ||
clientReceivedBytesPerRPC = stats.Int64("grpc.io/client/received_bytes_per_rpc", "Total bytes received across all response messages per RPC.", stats.UnitBytes) | ||
clientRoundtripLatency = stats.Float64("grpc.io/client/roundtrip_latency", "Time between first byte of request sent to last byte of response received, or terminal error.", stats.UnitMilliseconds) | ||
clientStartedRPCs = stats.Int64("grpc.io/client/started_rpcs", "The total number of client RPCs ever opened, including those that have not completed.", stats.UnitDimensionless) | ||
clientServerLatency = stats.Float64("grpc.io/client/server_latency", `Propagated from the server and should have the same value as "grpc.io/server/latency".`, stats.UnitMilliseconds) | ||
) | ||
|
||
var ( | ||
// ClientSentMessagesPerRPCView is the distribution of sent messages per | ||
// RPC, keyed on method. | ||
ClientSentMessagesPerRPCView = &view.View{ | ||
Measure: clientSentMessagesPerRPC, | ||
Name: "grpc.io/client/sent_messages_per_rpc", | ||
Description: "Distribution of sent messages per RPC, by method.", | ||
TagKeys: []tag.Key{keyClientMethod}, | ||
Aggregation: countDistribution, | ||
} | ||
// ClientReceivedMessagesPerRPCView is the distribution of received messages | ||
// per RPC, keyed on method. | ||
ClientReceivedMessagesPerRPCView = &view.View{ | ||
Measure: clientReceivedMessagesPerRPC, | ||
Name: "grpc.io/client/received_messages_per_rpc", | ||
Description: "Distribution of received messages per RPC, by method.", | ||
TagKeys: []tag.Key{keyClientMethod}, | ||
Aggregation: countDistribution, | ||
} | ||
// ClientSentBytesPerRPCView is the distribution of sent bytes per RPC, | ||
// keyed on method. | ||
ClientSentBytesPerRPCView = &view.View{ | ||
Measure: clientSentBytesPerRPC, | ||
Name: "grpc.io/client/sent_bytes_per_rpc", | ||
Description: "Distribution of sent bytes per RPC, by method.", | ||
TagKeys: []tag.Key{keyClientMethod}, | ||
Aggregation: bytesDistribution, | ||
} | ||
// ClientReceivedBytesPerRPCView is the distribution of received bytes per | ||
// RPC, keyed on method. | ||
ClientReceivedBytesPerRPCView = &view.View{ | ||
Measure: clientReceivedBytesPerRPC, | ||
Name: "grpc.io/client/received_bytes_per_rpc", | ||
Description: "Distribution of received bytes per RPC, by method.", | ||
TagKeys: []tag.Key{keyClientMethod}, | ||
Aggregation: bytesDistribution, | ||
} | ||
// ClientStartedRPCsView is the count of opened RPCs, keyed on method. | ||
ClientStartedRPCsView = &view.View{ | ||
Measure: clientStartedRPCs, | ||
Name: "grpc.io/client/started_rpcs", | ||
Description: "Number of opened client RPCs, by method.", | ||
TagKeys: []tag.Key{keyClientMethod}, | ||
Aggregation: view.Count(), | ||
} | ||
// ClientCompletedRPCsView is the count of completed RPCs, keyed on method | ||
// and status. | ||
ClientCompletedRPCsView = &view.View{ | ||
Measure: clientRoundtripLatency, | ||
Name: "grpc.io/client/completed_rpcs", | ||
Description: "Number of completed RPCs by method and status.", | ||
TagKeys: []tag.Key{keyClientMethod, keyClientStatus}, | ||
Aggregation: view.Count(), | ||
} | ||
// ClientRoundtripLatencyView is the distribution of round-trip latency in | ||
// milliseconds per RPC, keyed on method. | ||
ClientRoundtripLatencyView = &view.View{ | ||
Measure: clientRoundtripLatency, | ||
Name: "grpc.io/client/roundtrip_latency", | ||
Description: "Distribution of round-trip latency, by method.", | ||
TagKeys: []tag.Key{keyClientMethod}, | ||
Aggregation: millisecondsDistribution, | ||
} | ||
) | ||
|
||
// DefaultClientViews is the set of client views which are considered the | ||
// minimum required to monitor client side performance. | ||
var DefaultClientViews = []*view.View{ | ||
ClientSentBytesPerRPCView, | ||
ClientReceivedBytesPerRPCView, | ||
ClientRoundtripLatencyView, | ||
ClientCompletedRPCsView, | ||
ClientStartedRPCsView, | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather not export this as a map, and make it a permanent part of our API.
Options? One easy one is putting it in
internal
instead. (Sadly we decided to output a Go-looking name fromString()
, and changing it to report the canonical name instead would probably break too many tests.)Maybe a
CanonicalString
method?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Plumbed through internal with a CanonicalString method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please delete this now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Whoops forgot to delete sorry.