mirror of https://github.com/grpc/grpc-go.git
Fixed the review changes
This commit is contained in:
parent
06f350c283
commit
b944353a34
|
|
@ -885,6 +885,14 @@ func (s) TestMetricsAndTracesOptionEnabled(t *testing.T) {
|
||||||
Key: "FailFast",
|
Key: "FailFast",
|
||||||
Value: attribute.BoolValue(false),
|
Value: attribute.BoolValue(false),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Key: "previous-rpc-attempts",
|
||||||
|
Value: attribute.IntValue(0),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Key: "transparent-retry",
|
||||||
|
Value: attribute.BoolValue(false),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
events: []trace.Event{
|
events: []trace.Event{
|
||||||
{
|
{
|
||||||
|
|
@ -999,6 +1007,14 @@ func (s) TestMetricsAndTracesOptionEnabled(t *testing.T) {
|
||||||
Key: "FailFast",
|
Key: "FailFast",
|
||||||
Value: attribute.BoolValue(false),
|
Value: attribute.BoolValue(false),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Key: "previous-rpc-attempts",
|
||||||
|
Value: attribute.IntValue(0),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Key: "transparent-retry",
|
||||||
|
Value: attribute.BoolValue(false),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
events: nil,
|
events: nil,
|
||||||
},
|
},
|
||||||
|
|
@ -1093,6 +1109,14 @@ func (s) TestSpan(t *testing.T) {
|
||||||
Key: "FailFast",
|
Key: "FailFast",
|
||||||
Value: attribute.BoolValue(false),
|
Value: attribute.BoolValue(false),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Key: "previous-rpc-attempts",
|
||||||
|
Value: attribute.IntValue(0),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Key: "transparent-retry",
|
||||||
|
Value: attribute.BoolValue(false),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
events: []trace.Event{
|
events: []trace.Event{
|
||||||
{
|
{
|
||||||
|
|
@ -1191,6 +1215,14 @@ func (s) TestSpan(t *testing.T) {
|
||||||
Key: "FailFast",
|
Key: "FailFast",
|
||||||
Value: attribute.BoolValue(false),
|
Value: attribute.BoolValue(false),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Key: "previous-rpc-attempts",
|
||||||
|
Value: attribute.IntValue(0),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Key: "transparent-retry",
|
||||||
|
Value: attribute.BoolValue(false),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
events: nil,
|
events: nil,
|
||||||
},
|
},
|
||||||
|
|
@ -1287,6 +1319,14 @@ func (s) TestSpan_WithW3CContextPropagator(t *testing.T) {
|
||||||
Key: "FailFast",
|
Key: "FailFast",
|
||||||
Value: attribute.BoolValue(false),
|
Value: attribute.BoolValue(false),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Key: "previous-rpc-attempts",
|
||||||
|
Value: attribute.IntValue(0),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Key: "transparent-retry",
|
||||||
|
Value: attribute.BoolValue(false),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
events: []trace.Event{
|
events: []trace.Event{
|
||||||
{
|
{
|
||||||
|
|
@ -1385,6 +1425,14 @@ func (s) TestSpan_WithW3CContextPropagator(t *testing.T) {
|
||||||
Key: "FailFast",
|
Key: "FailFast",
|
||||||
Value: attribute.BoolValue(false),
|
Value: attribute.BoolValue(false),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Key: "previous-rpc-attempts",
|
||||||
|
Value: attribute.IntValue(0),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Key: "transparent-retry",
|
||||||
|
Value: attribute.BoolValue(false),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
events: nil,
|
events: nil,
|
||||||
},
|
},
|
||||||
|
|
@ -1554,6 +1602,8 @@ func (s) TestTraceSpan_WithRetriesAndNameResolutionDelay(t *testing.T) {
|
||||||
attributes: []attribute.KeyValue{
|
attributes: []attribute.KeyValue{
|
||||||
attribute.Bool("Client", false),
|
attribute.Bool("Client", false),
|
||||||
attribute.Bool("FailFast", false),
|
attribute.Bool("FailFast", false),
|
||||||
|
attribute.Int("previous-rpc-attempts", 0),
|
||||||
|
attribute.Bool("transparent-retry", false),
|
||||||
},
|
},
|
||||||
events: []trace.Event{
|
events: []trace.Event{
|
||||||
{
|
{
|
||||||
|
|
@ -1593,6 +1643,8 @@ func (s) TestTraceSpan_WithRetriesAndNameResolutionDelay(t *testing.T) {
|
||||||
attributes: []attribute.KeyValue{
|
attributes: []attribute.KeyValue{
|
||||||
attribute.Bool("Client", false),
|
attribute.Bool("Client", false),
|
||||||
attribute.Bool("FailFast", false),
|
attribute.Bool("FailFast", false),
|
||||||
|
attribute.Int("previous-rpc-attempts", 0),
|
||||||
|
attribute.Bool("transparent-retry", false),
|
||||||
},
|
},
|
||||||
events: []trace.Event{
|
events: []trace.Event{
|
||||||
{
|
{
|
||||||
|
|
@ -1632,6 +1684,8 @@ func (s) TestTraceSpan_WithRetriesAndNameResolutionDelay(t *testing.T) {
|
||||||
attributes: []attribute.KeyValue{
|
attributes: []attribute.KeyValue{
|
||||||
attribute.Bool("Client", false),
|
attribute.Bool("Client", false),
|
||||||
attribute.Bool("FailFast", false),
|
attribute.Bool("FailFast", false),
|
||||||
|
attribute.Int("previous-rpc-attempts", 0),
|
||||||
|
attribute.Bool("transparent-retry", false),
|
||||||
},
|
},
|
||||||
events: []trace.Event{
|
events: []trace.Event{
|
||||||
{
|
{
|
||||||
|
|
@ -1685,6 +1739,8 @@ func (s) TestTraceSpan_WithRetriesAndNameResolutionDelay(t *testing.T) {
|
||||||
attributes: []attribute.KeyValue{
|
attributes: []attribute.KeyValue{
|
||||||
attribute.Bool("Client", false),
|
attribute.Bool("Client", false),
|
||||||
attribute.Bool("FailFast", false),
|
attribute.Bool("FailFast", false),
|
||||||
|
attribute.Int("previous-rpc-attempts", 0),
|
||||||
|
attribute.Bool("transparent-retry", false),
|
||||||
},
|
},
|
||||||
events: []trace.Event{
|
events: []trace.Event{
|
||||||
{
|
{
|
||||||
|
|
@ -1766,6 +1822,8 @@ func (s) TestTraceSpan_WithRetriesAndNameResolutionDelay(t *testing.T) {
|
||||||
attributes: []attribute.KeyValue{
|
attributes: []attribute.KeyValue{
|
||||||
attribute.Bool("Client", false),
|
attribute.Bool("Client", false),
|
||||||
attribute.Bool("FailFast", false),
|
attribute.Bool("FailFast", false),
|
||||||
|
attribute.Int("previous-rpc-attempts", 0),
|
||||||
|
attribute.Bool("transparent-retry", false),
|
||||||
},
|
},
|
||||||
events: nil,
|
events: nil,
|
||||||
},
|
},
|
||||||
|
|
@ -1797,6 +1855,8 @@ func (s) TestTraceSpan_WithRetriesAndNameResolutionDelay(t *testing.T) {
|
||||||
attributes: []attribute.KeyValue{
|
attributes: []attribute.KeyValue{
|
||||||
attribute.Bool("Client", false),
|
attribute.Bool("Client", false),
|
||||||
attribute.Bool("FailFast", false),
|
attribute.Bool("FailFast", false),
|
||||||
|
attribute.Int("previous-rpc-attempts", 0),
|
||||||
|
attribute.Bool("transparent-retry", false),
|
||||||
},
|
},
|
||||||
events: nil,
|
events: nil,
|
||||||
},
|
},
|
||||||
|
|
@ -1828,6 +1888,8 @@ func (s) TestTraceSpan_WithRetriesAndNameResolutionDelay(t *testing.T) {
|
||||||
attributes: []attribute.KeyValue{
|
attributes: []attribute.KeyValue{
|
||||||
attribute.Bool("Client", false),
|
attribute.Bool("Client", false),
|
||||||
attribute.Bool("FailFast", false),
|
attribute.Bool("FailFast", false),
|
||||||
|
attribute.Int("previous-rpc-attempts", 0),
|
||||||
|
attribute.Bool("transparent-retry", false),
|
||||||
},
|
},
|
||||||
events: []trace.Event{
|
events: []trace.Event{
|
||||||
{
|
{
|
||||||
|
|
@ -1867,6 +1929,8 @@ func (s) TestTraceSpan_WithRetriesAndNameResolutionDelay(t *testing.T) {
|
||||||
attributes: []attribute.KeyValue{
|
attributes: []attribute.KeyValue{
|
||||||
attribute.Bool("Client", false),
|
attribute.Bool("Client", false),
|
||||||
attribute.Bool("FailFast", false),
|
attribute.Bool("FailFast", false),
|
||||||
|
attribute.Int("previous-rpc-attempts", 0),
|
||||||
|
attribute.Bool("transparent-retry", false),
|
||||||
},
|
},
|
||||||
events: []trace.Event{
|
events: []trace.Event{
|
||||||
{
|
{
|
||||||
|
|
@ -2028,6 +2092,8 @@ func (s) TestStreamingRPC_TraceSequenceNumbers(t *testing.T) {
|
||||||
attributes: []attribute.KeyValue{
|
attributes: []attribute.KeyValue{
|
||||||
attribute.Bool("Client", false),
|
attribute.Bool("Client", false),
|
||||||
attribute.Bool("FailFast", false),
|
attribute.Bool("FailFast", false),
|
||||||
|
attribute.Int("previous-rpc-attempts", 0),
|
||||||
|
attribute.Bool("transparent-retry", false),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -42,20 +42,26 @@ func populateSpan(rs stats.RPCStats, ai *attemptInfo) {
|
||||||
// Note: Go always added Client and FailFast attributes even though they are not
|
// Note: Go always added Client and FailFast attributes even though they are not
|
||||||
// defined by the OpenCensus gRPC spec. Thus, they are unimportant for
|
// defined by the OpenCensus gRPC spec. Thus, they are unimportant for
|
||||||
// correctness.
|
// correctness.
|
||||||
attrs := []attribute.KeyValue{
|
// previousRPCAttempts tracks the number of previous RPC attempts.
|
||||||
|
// If ai.previousRPCAttempts is nil (which can occur on the server path),
|
||||||
|
// prevAttempts defaults to 0 to avoid a nil pointer dereference.
|
||||||
|
previousRPCAttempts := int64(0)
|
||||||
|
if ai.previousRPCAttempts != nil {
|
||||||
|
previousRPCAttempts = int64(ai.previousRPCAttempts.Load())
|
||||||
|
}
|
||||||
|
span.SetAttributes(
|
||||||
attribute.Bool("Client", rs.Client),
|
attribute.Bool("Client", rs.Client),
|
||||||
attribute.Bool("FailFast", rs.FailFast),
|
attribute.Bool("FailFast", rs.FailFast),
|
||||||
}
|
// TODO: Remove "previous-rpc-attempts" and "transparent-retry"
|
||||||
if rs.Client {
|
// attributes from server spans. These attributes are only relevant
|
||||||
attrs = append(attrs,
|
// to client spans.
|
||||||
attribute.Int64("previous-rpc-attempts", int64(ai.previousRPCAttempts.Load())),
|
attribute.Int64("previous-rpc-attempts", previousRPCAttempts),
|
||||||
attribute.Bool("transparent-retry", rs.IsTransparentRetryAttempt),
|
attribute.Bool("transparent-retry", rs.IsTransparentRetryAttempt),
|
||||||
)
|
)
|
||||||
}
|
|
||||||
span.SetAttributes(attrs...)
|
|
||||||
// Increment retry count for the next attempt if not a transparent
|
// Increment retry count for the next attempt if not a transparent
|
||||||
// retry.
|
// retry. Added nil check to avoid panic on server path where
|
||||||
if !rs.IsTransparentRetryAttempt && rs.Client {
|
// previousRPCAttempts is not set.
|
||||||
|
if !rs.IsTransparentRetryAttempt && ai.previousRPCAttempts != nil {
|
||||||
ai.previousRPCAttempts.Add(1)
|
ai.previousRPCAttempts.Add(1)
|
||||||
}
|
}
|
||||||
case *stats.PickerUpdated:
|
case *stats.PickerUpdated:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue