-
Notifications
You must be signed in to change notification settings - Fork 626
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extend metrics with retry-related instruments
- Loading branch information
Showing
13 changed files
with
649 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package retry | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/aws/smithy-go/metrics" | ||
"github.com/aws/smithy-go/middleware" | ||
) | ||
|
||
type attemptMetrics struct { | ||
Attempts metrics.Int64Counter | ||
Errors metrics.Int64Counter | ||
|
||
AttemptDuration metrics.Float64Histogram | ||
} | ||
|
||
func newAttemptMetrics(meter metrics.Meter) (*attemptMetrics, error) { | ||
m := &attemptMetrics{} | ||
var err error | ||
|
||
m.Attempts, err = meter.Int64Counter("client.call.attempts", func(o *metrics.InstrumentOptions) { | ||
o.UnitLabel = "{attempt}" | ||
o.Description = "The number of attempts for an individual operation" | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
m.Errors, err = meter.Int64Counter("client.call.errors", func(o *metrics.InstrumentOptions) { | ||
o.UnitLabel = "{error}" | ||
o.Description = "The number of errors for an operation" | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
m.AttemptDuration, err = meter.Float64Histogram("client.call.attempt_duration", func(o *metrics.InstrumentOptions) { | ||
o.UnitLabel = "s" | ||
o.Description = "The time it takes to connect to the service, send the request, and get back HTTP status code and headers (including time queued waiting to be sent)" | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return m, nil | ||
} | ||
|
||
func withOperationMetadata(ctx context.Context) metrics.RecordMetricOption { | ||
return func(o *metrics.RecordMetricOptions) { | ||
o.Properties.Set("rpc.service", middleware.GetServiceID(ctx)) | ||
o.Properties.Set("rpc.method", middleware.GetOperationName(ctx)) | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.