Update dependencies
This commit is contained in:
3
vendor/github.com/aws/smithy-go/.gitignore
generated
vendored
3
vendor/github.com/aws/smithy-go/.gitignore
generated
vendored
@@ -24,3 +24,6 @@ build/
|
||||
# VS Code
|
||||
bin/
|
||||
.vscode/
|
||||
|
||||
# make
|
||||
c.out
|
||||
|
||||
76
vendor/github.com/aws/smithy-go/CHANGELOG.md
generated
vendored
76
vendor/github.com/aws/smithy-go/CHANGELOG.md
generated
vendored
@@ -1,3 +1,79 @@
|
||||
# Release (2025-01-21)
|
||||
|
||||
## General Highlights
|
||||
* **Dependency Update**: Updated to the latest SDK module versions
|
||||
|
||||
## Module Highlights
|
||||
* `github.com/aws/smithy-go`: v1.22.2
|
||||
* **Bug Fix**: Fix HTTP metrics data race.
|
||||
* **Bug Fix**: Replace usages of deprecated ioutil package.
|
||||
|
||||
# Release (2024-11-15)
|
||||
|
||||
## General Highlights
|
||||
* **Dependency Update**: Updated to the latest SDK module versions
|
||||
|
||||
## Module Highlights
|
||||
* `github.com/aws/smithy-go`: v1.22.1
|
||||
* **Bug Fix**: Fix failure to replace URI path segments when their names overlap.
|
||||
|
||||
# Release (2024-10-03)
|
||||
|
||||
## General Highlights
|
||||
* **Dependency Update**: Updated to the latest SDK module versions
|
||||
|
||||
## Module Highlights
|
||||
* `github.com/aws/smithy-go`: v1.22.0
|
||||
* **Feature**: Add HTTP client metrics.
|
||||
|
||||
# Release (2024-09-25)
|
||||
|
||||
## Module Highlights
|
||||
* `github.com/aws/smithy-go/aws-http-auth`: [v1.0.0](aws-http-auth/CHANGELOG.md#v100-2024-09-25)
|
||||
* **Release**: Initial release of module aws-http-auth, which implements generically consumable SigV4 and SigV4a request signing.
|
||||
|
||||
# Release (2024-09-19)
|
||||
|
||||
## General Highlights
|
||||
* **Dependency Update**: Updated to the latest SDK module versions
|
||||
|
||||
## Module Highlights
|
||||
* `github.com/aws/smithy-go`: v1.21.0
|
||||
* **Feature**: Add tracing and metrics APIs, and builtin instrumentation for both, in generated clients.
|
||||
* `github.com/aws/smithy-go/metrics/smithyotelmetrics`: [v1.0.0](metrics/smithyotelmetrics/CHANGELOG.md#v100-2024-09-19)
|
||||
* **Release**: Initial release of `smithyotelmetrics` module, which is used to adapt an OpenTelemetry SDK meter provider to be used with Smithy clients.
|
||||
* `github.com/aws/smithy-go/tracing/smithyoteltracing`: [v1.0.0](tracing/smithyoteltracing/CHANGELOG.md#v100-2024-09-19)
|
||||
* **Release**: Initial release of `smithyoteltracing` module, which is used to adapt an OpenTelemetry SDK tracer provider to be used with Smithy clients.
|
||||
|
||||
# Release (2024-08-14)
|
||||
|
||||
## Module Highlights
|
||||
* `github.com/aws/smithy-go`: v1.20.4
|
||||
* **Dependency Update**: Bump minimum Go version to 1.21.
|
||||
|
||||
# Release (2024-06-27)
|
||||
|
||||
## Module Highlights
|
||||
* `github.com/aws/smithy-go`: v1.20.3
|
||||
* **Bug Fix**: Fix encoding/cbor test overflow on x86.
|
||||
|
||||
# Release (2024-03-29)
|
||||
|
||||
* No change notes available for this release.
|
||||
|
||||
# Release (2024-02-21)
|
||||
|
||||
## Module Highlights
|
||||
* `github.com/aws/smithy-go`: v1.20.1
|
||||
* **Bug Fix**: Remove runtime dependency on go-cmp.
|
||||
|
||||
# Release (2024-02-13)
|
||||
|
||||
## Module Highlights
|
||||
* `github.com/aws/smithy-go`: v1.20.0
|
||||
* **Feature**: Add codegen definition for sigv4a trait.
|
||||
* **Feature**: Bump minimum Go version to 1.20 per our language support policy.
|
||||
|
||||
# Release (2023-12-07)
|
||||
|
||||
## Module Highlights
|
||||
|
||||
31
vendor/github.com/aws/smithy-go/CONTRIBUTING.md
generated
vendored
31
vendor/github.com/aws/smithy-go/CONTRIBUTING.md
generated
vendored
@@ -39,6 +39,37 @@ To send us a pull request, please:
|
||||
GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
|
||||
[creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
|
||||
|
||||
### Changelog Documents
|
||||
|
||||
(You can SKIP this step if you are only changing the code generator, and not the runtime).
|
||||
|
||||
When submitting a pull request please include a changelog file on a folder named `.changelog`.
|
||||
These are used to generate the content `CHANGELOG.md` and Release Notes. The format of the file is as follows:
|
||||
|
||||
```
|
||||
{
|
||||
"id": "12345678-1234-1234-1234-123456789012"
|
||||
"type": "bugfix"
|
||||
"collapse": true
|
||||
"description": "Fix improper use of printf-style functions.",
|
||||
"modules": [
|
||||
"."
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
* id: a UUID. This should also be used for the name of the file, so if your id is `12345678-1234-1234-1234-123456789012` the file should be named `12345678-1234-1234-1234-123456789012.json/`
|
||||
* type: one of the following:
|
||||
* bugfix: Fixing an existing bug
|
||||
* Feature: Adding a new feature to an existing service
|
||||
* Release: Releasing a new module
|
||||
* Dependency: Updating dependencies
|
||||
* Announcement: Making an announcement, like deprecation of a module
|
||||
* collapse: whether this change should appear separately on the release notes on every module listed on `modules` (`"collapse": false`), or if it should show up as a single entry (`"collapse": true`)
|
||||
* For the smithy-go repository this should always be `false`
|
||||
* description: Description of this change. Most of the times is the same as the title of the PR
|
||||
* modules: which Go modules does this change impact. The root module is expressed as "."
|
||||
|
||||
|
||||
## Finding contributions to work on
|
||||
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start.
|
||||
|
||||
14
vendor/github.com/aws/smithy-go/Makefile
generated
vendored
14
vendor/github.com/aws/smithy-go/Makefile
generated
vendored
@@ -33,13 +33,18 @@ smithy-clean:
|
||||
##################
|
||||
# Linting/Verify #
|
||||
##################
|
||||
.PHONY: verify vet
|
||||
.PHONY: verify vet cover
|
||||
|
||||
verify: vet
|
||||
|
||||
vet:
|
||||
go vet ${BUILD_TAGS} --all ./...
|
||||
|
||||
cover:
|
||||
go test ${BUILD_TAGS} -coverprofile c.out ./...
|
||||
@cover=`go tool cover -func c.out | grep '^total:' | awk '{ print $$3+0 }'`; \
|
||||
echo "total (statements): $$cover%";
|
||||
|
||||
################
|
||||
# Unit Testing #
|
||||
################
|
||||
@@ -93,5 +98,12 @@ module-version:
|
||||
##############
|
||||
.PHONY: install-changelog
|
||||
|
||||
external-changelog:
|
||||
mkdir -p .changelog
|
||||
cp changelog-template.json .changelog/00000000-0000-0000-0000-000000000000.json
|
||||
@echo "Generate a new UUID and update the file at .changelog/00000000-0000-0000-0000-000000000000.json"
|
||||
@echo "Make sure to rename the file with your new id, like .changelog/12345678-1234-1234-1234-123456789012.json"
|
||||
@echo "See CONTRIBUTING.md 'Changelog Documents' and an example at https://github.com/aws/smithy-go/pull/543/files"
|
||||
|
||||
install-changelog:
|
||||
go install ${REPOTOOLS_MODULE}/cmd/changelog@${REPOTOOLS_VERSION}
|
||||
|
||||
74
vendor/github.com/aws/smithy-go/README.md
generated
vendored
74
vendor/github.com/aws/smithy-go/README.md
generated
vendored
@@ -1,19 +1,21 @@
|
||||
## Smithy Go
|
||||
# Smithy Go
|
||||
|
||||
[](https://github.com/aws/smithy-go/actions/workflows/go.yml)[](https://github.com/aws/smithy-go/actions/workflows/codegen.yml)
|
||||
|
||||
[Smithy](https://smithy.io/) code generators for Go.
|
||||
[Smithy](https://smithy.io/) code generators for Go and the accompanying smithy-go runtime.
|
||||
|
||||
The smithy-go runtime requires a minimum version of Go 1.20.
|
||||
|
||||
**WARNING: All interfaces are subject to change.**
|
||||
|
||||
## Can I use this?
|
||||
## Can I use the code generators?
|
||||
|
||||
In order to generate a usable smithy client you must provide a [protocol definition](https://github.com/aws/smithy-go/blob/main/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/integration/ProtocolGenerator.java),
|
||||
such as [AWS restJson1](https://smithy.io/2.0/aws/protocols/aws-restjson1-protocol.html),
|
||||
in order to generate transport mechanisms and serialization/deserialization
|
||||
code ("serde") accordingly.
|
||||
|
||||
The code generator does not currently support any protocols out of the box,
|
||||
The code generator does not currently support any protocols out of the box other than the new `smithy.protocols#rpcv2Cbor`,
|
||||
therefore the useability of this project on its own is currently limited.
|
||||
Support for all [AWS protocols](https://smithy.io/2.0/aws/protocols/index.html)
|
||||
exists in [aws-sdk-go-v2](https://github.com/aws/aws-sdk-go-v2). We are
|
||||
@@ -21,6 +23,70 @@ tracking the movement of those out of the SDK into smithy-go in
|
||||
[#458](https://github.com/aws/smithy-go/issues/458), but there's currently no
|
||||
timeline for doing so.
|
||||
|
||||
## Plugins
|
||||
|
||||
This repository implements the following Smithy build plugins:
|
||||
|
||||
| ID | GAV prefix | Description |
|
||||
|----|------------|-------------|
|
||||
| `go-codegen` | `software.amazon.smithy.go:smithy-go-codegen` | Implements Go client code generation for Smithy models. |
|
||||
| `go-server-codegen` | `software.amazon.smithy.go:smithy-go-codegen` | Implements Go server code generation for Smithy models. |
|
||||
|
||||
**NOTE: Build plugins are not currently published to mavenCentral. You must publish to mavenLocal to make the build plugins visible to the Smithy CLI. The artifact version is currently fixed at 0.1.0.**
|
||||
|
||||
## `go-codegen`
|
||||
|
||||
### Configuration
|
||||
|
||||
[`GoSettings`](codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/GoSettings.java)
|
||||
contains all of the settings enabled from `smithy-build.json` and helper
|
||||
methods and types. The up-to-date list of top-level properties enabled for
|
||||
`go-client-codegen` can be found in `GoSettings::from()`.
|
||||
|
||||
| Setting | Type | Required | Description |
|
||||
|-----------------|---------|----------|-----------------------------------------------------------------------------------------------------------------------------|
|
||||
| `service` | string | yes | The Shape ID of the service for which to generate the client. |
|
||||
| `module` | string | yes | Name of the module in `generated.json` (and `go.mod` if `generateGoMod` is enabled) and `doc.go`. |
|
||||
| `generateGoMod` | boolean | | Whether to generate a default `go.mod` file. The default value is `false`. |
|
||||
| `goDirective` | string | | [Go directive](https://go.dev/ref/mod#go-mod-file-go) of the module. The default value is the minimum supported Go version. |
|
||||
|
||||
### Supported protocols
|
||||
|
||||
| Protocol | Notes |
|
||||
|----------|-------|
|
||||
| [`smithy.protocols#rpcv2Cbor`](https://smithy.io/2.0/additional-specs/protocols/smithy-rpc-v2.html) | Event streaming not yet implemented. |
|
||||
|
||||
### Example
|
||||
|
||||
This example applies the `go-codegen` build plugin to the Smithy quickstart
|
||||
example created from `smithy init`:
|
||||
|
||||
```json
|
||||
{
|
||||
"version": "1.0",
|
||||
"sources": [
|
||||
"models"
|
||||
],
|
||||
"maven": {
|
||||
"dependencies": [
|
||||
"software.amazon.smithy.go:smithy-go-codegen:0.1.0"
|
||||
]
|
||||
},
|
||||
"plugins": {
|
||||
"go-codegen": {
|
||||
"service": "example.weather#Weather",
|
||||
"module": "github.com/example/weather",
|
||||
"generateGoMod": true,
|
||||
"goDirective": "1.20"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## `go-server-codegen`
|
||||
|
||||
This plugin is a work-in-progress and is currently undocumented.
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the Apache-2.0 License.
|
||||
|
||||
9
vendor/github.com/aws/smithy-go/changelog-template.json
generated
vendored
Normal file
9
vendor/github.com/aws/smithy-go/changelog-template.json
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"id": "00000000-0000-0000-0000-000000000000",
|
||||
"type": "feature|bugfix|dependency",
|
||||
"description": "Description of your changes",
|
||||
"collapse": false,
|
||||
"modules": [
|
||||
"."
|
||||
]
|
||||
}
|
||||
30
vendor/github.com/aws/smithy-go/encoding/httpbinding/path_replace.go
generated
vendored
30
vendor/github.com/aws/smithy-go/encoding/httpbinding/path_replace.go
generated
vendored
@@ -22,33 +22,33 @@ func bufCap(b []byte, n int) []byte {
|
||||
// replacePathElement replaces a single element in the path []byte.
|
||||
// Escape is used to control whether the value will be escaped using Amazon path escape style.
|
||||
func replacePathElement(path, fieldBuf []byte, key, val string, escape bool) ([]byte, []byte, error) {
|
||||
fieldBuf = bufCap(fieldBuf, len(key)+3) // { <key> [+] }
|
||||
// search for "{<key>}". If not found, search for the greedy version "{<key>+}". If none are found, return error
|
||||
fieldBuf = bufCap(fieldBuf, len(key)+2) // { <key> }
|
||||
fieldBuf = append(fieldBuf, uriTokenStart)
|
||||
fieldBuf = append(fieldBuf, key...)
|
||||
fieldBuf = append(fieldBuf, uriTokenStop)
|
||||
|
||||
start := bytes.Index(path, fieldBuf)
|
||||
end := start + len(fieldBuf)
|
||||
if start < 0 || len(path[end:]) == 0 {
|
||||
// TODO what to do about error?
|
||||
return path, fieldBuf, fmt.Errorf("invalid path index, start=%d,end=%d. %s", start, end, path)
|
||||
}
|
||||
|
||||
encodeSep := true
|
||||
if path[end] == uriTokenSkip {
|
||||
// '+' token means do not escape slashes
|
||||
if start < 0 {
|
||||
fieldBuf = bufCap(fieldBuf, len(key)+3) // { <key> [+] }
|
||||
fieldBuf = append(fieldBuf, uriTokenStart)
|
||||
fieldBuf = append(fieldBuf, key...)
|
||||
fieldBuf = append(fieldBuf, uriTokenSkip)
|
||||
fieldBuf = append(fieldBuf, uriTokenStop)
|
||||
|
||||
start = bytes.Index(path, fieldBuf)
|
||||
if start < 0 {
|
||||
return path, fieldBuf, fmt.Errorf("invalid path index, start=%d. %s", start, path)
|
||||
}
|
||||
encodeSep = false
|
||||
end++
|
||||
}
|
||||
end := start + len(fieldBuf)
|
||||
|
||||
if escape {
|
||||
val = EscapePath(val, encodeSep)
|
||||
}
|
||||
|
||||
if path[end] != uriTokenStop {
|
||||
return path, fieldBuf, fmt.Errorf("invalid path element, does not contain token stop, %s", path)
|
||||
}
|
||||
end++
|
||||
|
||||
fieldBuf = bufCap(fieldBuf, len(val))
|
||||
fieldBuf = append(fieldBuf, val...)
|
||||
|
||||
|
||||
2
vendor/github.com/aws/smithy-go/go_module_metadata.go
generated
vendored
2
vendor/github.com/aws/smithy-go/go_module_metadata.go
generated
vendored
@@ -3,4 +3,4 @@
|
||||
package smithy
|
||||
|
||||
// goModuleVersion is the tagged release for this module
|
||||
const goModuleVersion = "1.19.0"
|
||||
const goModuleVersion = "1.22.2"
|
||||
|
||||
136
vendor/github.com/aws/smithy-go/metrics/metrics.go
generated
vendored
Normal file
136
vendor/github.com/aws/smithy-go/metrics/metrics.go
generated
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
// Package metrics defines the metrics APIs used by Smithy clients.
|
||||
package metrics
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/aws/smithy-go"
|
||||
)
|
||||
|
||||
// MeterProvider is the entry point for creating a Meter.
|
||||
type MeterProvider interface {
|
||||
Meter(scope string, opts ...MeterOption) Meter
|
||||
}
|
||||
|
||||
// MeterOption applies configuration to a Meter.
|
||||
type MeterOption func(o *MeterOptions)
|
||||
|
||||
// MeterOptions represents configuration for a Meter.
|
||||
type MeterOptions struct {
|
||||
Properties smithy.Properties
|
||||
}
|
||||
|
||||
// Meter is the entry point for creation of measurement instruments.
|
||||
type Meter interface {
|
||||
// integer/synchronous
|
||||
Int64Counter(name string, opts ...InstrumentOption) (Int64Counter, error)
|
||||
Int64UpDownCounter(name string, opts ...InstrumentOption) (Int64UpDownCounter, error)
|
||||
Int64Gauge(name string, opts ...InstrumentOption) (Int64Gauge, error)
|
||||
Int64Histogram(name string, opts ...InstrumentOption) (Int64Histogram, error)
|
||||
|
||||
// integer/asynchronous
|
||||
Int64AsyncCounter(name string, callback Int64Callback, opts ...InstrumentOption) (AsyncInstrument, error)
|
||||
Int64AsyncUpDownCounter(name string, callback Int64Callback, opts ...InstrumentOption) (AsyncInstrument, error)
|
||||
Int64AsyncGauge(name string, callback Int64Callback, opts ...InstrumentOption) (AsyncInstrument, error)
|
||||
|
||||
// floating-point/synchronous
|
||||
Float64Counter(name string, opts ...InstrumentOption) (Float64Counter, error)
|
||||
Float64UpDownCounter(name string, opts ...InstrumentOption) (Float64UpDownCounter, error)
|
||||
Float64Gauge(name string, opts ...InstrumentOption) (Float64Gauge, error)
|
||||
Float64Histogram(name string, opts ...InstrumentOption) (Float64Histogram, error)
|
||||
|
||||
// floating-point/asynchronous
|
||||
Float64AsyncCounter(name string, callback Float64Callback, opts ...InstrumentOption) (AsyncInstrument, error)
|
||||
Float64AsyncUpDownCounter(name string, callback Float64Callback, opts ...InstrumentOption) (AsyncInstrument, error)
|
||||
Float64AsyncGauge(name string, callback Float64Callback, opts ...InstrumentOption) (AsyncInstrument, error)
|
||||
}
|
||||
|
||||
// InstrumentOption applies configuration to an instrument.
|
||||
type InstrumentOption func(o *InstrumentOptions)
|
||||
|
||||
// InstrumentOptions represents configuration for an instrument.
|
||||
type InstrumentOptions struct {
|
||||
UnitLabel string
|
||||
Description string
|
||||
}
|
||||
|
||||
// Int64Counter measures a monotonically increasing int64 value.
|
||||
type Int64Counter interface {
|
||||
Add(context.Context, int64, ...RecordMetricOption)
|
||||
}
|
||||
|
||||
// Int64UpDownCounter measures a fluctuating int64 value.
|
||||
type Int64UpDownCounter interface {
|
||||
Add(context.Context, int64, ...RecordMetricOption)
|
||||
}
|
||||
|
||||
// Int64Gauge samples a discrete int64 value.
|
||||
type Int64Gauge interface {
|
||||
Sample(context.Context, int64, ...RecordMetricOption)
|
||||
}
|
||||
|
||||
// Int64Histogram records multiple data points for an int64 value.
|
||||
type Int64Histogram interface {
|
||||
Record(context.Context, int64, ...RecordMetricOption)
|
||||
}
|
||||
|
||||
// Float64Counter measures a monotonically increasing float64 value.
|
||||
type Float64Counter interface {
|
||||
Add(context.Context, float64, ...RecordMetricOption)
|
||||
}
|
||||
|
||||
// Float64UpDownCounter measures a fluctuating float64 value.
|
||||
type Float64UpDownCounter interface {
|
||||
Add(context.Context, float64, ...RecordMetricOption)
|
||||
}
|
||||
|
||||
// Float64Gauge samples a discrete float64 value.
|
||||
type Float64Gauge interface {
|
||||
Sample(context.Context, float64, ...RecordMetricOption)
|
||||
}
|
||||
|
||||
// Float64Histogram records multiple data points for an float64 value.
|
||||
type Float64Histogram interface {
|
||||
Record(context.Context, float64, ...RecordMetricOption)
|
||||
}
|
||||
|
||||
// AsyncInstrument is the universal handle returned for creation of all async
|
||||
// instruments.
|
||||
//
|
||||
// Callers use the Stop() API to unregister the callback passed at instrument
|
||||
// creation.
|
||||
type AsyncInstrument interface {
|
||||
Stop()
|
||||
}
|
||||
|
||||
// Int64Callback describes a function invoked when an async int64 instrument is
|
||||
// read.
|
||||
type Int64Callback func(context.Context, Int64Observer)
|
||||
|
||||
// Int64Observer is the interface passed to async int64 instruments.
|
||||
//
|
||||
// Callers use the Observe() API of this interface to report metrics to the
|
||||
// underlying collector.
|
||||
type Int64Observer interface {
|
||||
Observe(context.Context, int64, ...RecordMetricOption)
|
||||
}
|
||||
|
||||
// Float64Callback describes a function invoked when an async float64
|
||||
// instrument is read.
|
||||
type Float64Callback func(context.Context, Float64Observer)
|
||||
|
||||
// Float64Observer is the interface passed to async int64 instruments.
|
||||
//
|
||||
// Callers use the Observe() API of this interface to report metrics to the
|
||||
// underlying collector.
|
||||
type Float64Observer interface {
|
||||
Observe(context.Context, float64, ...RecordMetricOption)
|
||||
}
|
||||
|
||||
// RecordMetricOption applies configuration to a recorded metric.
|
||||
type RecordMetricOption func(o *RecordMetricOptions)
|
||||
|
||||
// RecordMetricOptions represents configuration for a recorded metric.
|
||||
type RecordMetricOptions struct {
|
||||
Properties smithy.Properties
|
||||
}
|
||||
67
vendor/github.com/aws/smithy-go/metrics/nop.go
generated
vendored
Normal file
67
vendor/github.com/aws/smithy-go/metrics/nop.go
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
package metrics
|
||||
|
||||
import "context"
|
||||
|
||||
// NopMeterProvider is a no-op metrics implementation.
|
||||
type NopMeterProvider struct{}
|
||||
|
||||
var _ MeterProvider = (*NopMeterProvider)(nil)
|
||||
|
||||
// Meter returns a meter which creates no-op instruments.
|
||||
func (NopMeterProvider) Meter(string, ...MeterOption) Meter {
|
||||
return nopMeter{}
|
||||
}
|
||||
|
||||
type nopMeter struct{}
|
||||
|
||||
var _ Meter = (*nopMeter)(nil)
|
||||
|
||||
func (nopMeter) Int64Counter(string, ...InstrumentOption) (Int64Counter, error) {
|
||||
return nopInstrument[int64]{}, nil
|
||||
}
|
||||
func (nopMeter) Int64UpDownCounter(string, ...InstrumentOption) (Int64UpDownCounter, error) {
|
||||
return nopInstrument[int64]{}, nil
|
||||
}
|
||||
func (nopMeter) Int64Gauge(string, ...InstrumentOption) (Int64Gauge, error) {
|
||||
return nopInstrument[int64]{}, nil
|
||||
}
|
||||
func (nopMeter) Int64Histogram(string, ...InstrumentOption) (Int64Histogram, error) {
|
||||
return nopInstrument[int64]{}, nil
|
||||
}
|
||||
func (nopMeter) Int64AsyncCounter(string, Int64Callback, ...InstrumentOption) (AsyncInstrument, error) {
|
||||
return nopInstrument[int64]{}, nil
|
||||
}
|
||||
func (nopMeter) Int64AsyncUpDownCounter(string, Int64Callback, ...InstrumentOption) (AsyncInstrument, error) {
|
||||
return nopInstrument[int64]{}, nil
|
||||
}
|
||||
func (nopMeter) Int64AsyncGauge(string, Int64Callback, ...InstrumentOption) (AsyncInstrument, error) {
|
||||
return nopInstrument[int64]{}, nil
|
||||
}
|
||||
func (nopMeter) Float64Counter(string, ...InstrumentOption) (Float64Counter, error) {
|
||||
return nopInstrument[float64]{}, nil
|
||||
}
|
||||
func (nopMeter) Float64UpDownCounter(string, ...InstrumentOption) (Float64UpDownCounter, error) {
|
||||
return nopInstrument[float64]{}, nil
|
||||
}
|
||||
func (nopMeter) Float64Gauge(string, ...InstrumentOption) (Float64Gauge, error) {
|
||||
return nopInstrument[float64]{}, nil
|
||||
}
|
||||
func (nopMeter) Float64Histogram(string, ...InstrumentOption) (Float64Histogram, error) {
|
||||
return nopInstrument[float64]{}, nil
|
||||
}
|
||||
func (nopMeter) Float64AsyncCounter(string, Float64Callback, ...InstrumentOption) (AsyncInstrument, error) {
|
||||
return nopInstrument[float64]{}, nil
|
||||
}
|
||||
func (nopMeter) Float64AsyncUpDownCounter(string, Float64Callback, ...InstrumentOption) (AsyncInstrument, error) {
|
||||
return nopInstrument[float64]{}, nil
|
||||
}
|
||||
func (nopMeter) Float64AsyncGauge(string, Float64Callback, ...InstrumentOption) (AsyncInstrument, error) {
|
||||
return nopInstrument[float64]{}, nil
|
||||
}
|
||||
|
||||
type nopInstrument[N any] struct{}
|
||||
|
||||
func (nopInstrument[N]) Add(context.Context, N, ...RecordMetricOption) {}
|
||||
func (nopInstrument[N]) Sample(context.Context, N, ...RecordMetricOption) {}
|
||||
func (nopInstrument[N]) Record(context.Context, N, ...RecordMetricOption) {}
|
||||
func (nopInstrument[_]) Stop() {}
|
||||
41
vendor/github.com/aws/smithy-go/middleware/context.go
generated
vendored
Normal file
41
vendor/github.com/aws/smithy-go/middleware/context.go
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
package middleware
|
||||
|
||||
import "context"
|
||||
|
||||
type (
|
||||
serviceIDKey struct{}
|
||||
operationNameKey struct{}
|
||||
)
|
||||
|
||||
// WithServiceID adds a service ID to the context, scoped to middleware stack
|
||||
// values.
|
||||
//
|
||||
// This API is called in the client runtime when bootstrapping an operation and
|
||||
// should not typically be used directly.
|
||||
func WithServiceID(parent context.Context, id string) context.Context {
|
||||
return WithStackValue(parent, serviceIDKey{}, id)
|
||||
}
|
||||
|
||||
// GetServiceID retrieves the service ID from the context. This is typically
|
||||
// the service shape's name from its Smithy model. Service clients for specific
|
||||
// systems (e.g. AWS SDK) may use an alternate designated value.
|
||||
func GetServiceID(ctx context.Context) string {
|
||||
id, _ := GetStackValue(ctx, serviceIDKey{}).(string)
|
||||
return id
|
||||
}
|
||||
|
||||
// WithOperationName adds the operation name to the context, scoped to
|
||||
// middleware stack values.
|
||||
//
|
||||
// This API is called in the client runtime when bootstrapping an operation and
|
||||
// should not typically be used directly.
|
||||
func WithOperationName(parent context.Context, id string) context.Context {
|
||||
return WithStackValue(parent, operationNameKey{}, id)
|
||||
}
|
||||
|
||||
// GetOperationName retrieves the operation name from the context. This is
|
||||
// typically the operation shape's name from its Smithy model.
|
||||
func GetOperationName(ctx context.Context) string {
|
||||
name, _ := GetStackValue(ctx, operationNameKey{}).(string)
|
||||
return name
|
||||
}
|
||||
1
vendor/github.com/aws/smithy-go/modman.toml
generated
vendored
1
vendor/github.com/aws/smithy-go/modman.toml
generated
vendored
@@ -1,5 +1,4 @@
|
||||
[dependencies]
|
||||
"github.com/google/go-cmp" = "v0.5.8"
|
||||
"github.com/jmespath/go-jmespath" = "v0.4.0"
|
||||
|
||||
[modules]
|
||||
|
||||
19
vendor/github.com/aws/smithy-go/properties.go
generated
vendored
19
vendor/github.com/aws/smithy-go/properties.go
generated
vendored
@@ -1,9 +1,11 @@
|
||||
package smithy
|
||||
|
||||
import "maps"
|
||||
|
||||
// PropertiesReader provides an interface for reading metadata from the
|
||||
// underlying metadata container.
|
||||
type PropertiesReader interface {
|
||||
Get(key interface{}) interface{}
|
||||
Get(key any) any
|
||||
}
|
||||
|
||||
// Properties provides storing and reading metadata values. Keys may be any
|
||||
@@ -12,14 +14,14 @@ type PropertiesReader interface {
|
||||
// The zero value for a Properties instance is ready for reads/writes without
|
||||
// any additional initialization.
|
||||
type Properties struct {
|
||||
values map[interface{}]interface{}
|
||||
values map[any]any
|
||||
}
|
||||
|
||||
// Get attempts to retrieve the value the key points to. Returns nil if the
|
||||
// key was not found.
|
||||
//
|
||||
// Panics if key type is not comparable.
|
||||
func (m *Properties) Get(key interface{}) interface{} {
|
||||
func (m *Properties) Get(key any) any {
|
||||
m.lazyInit()
|
||||
return m.values[key]
|
||||
}
|
||||
@@ -28,7 +30,7 @@ func (m *Properties) Get(key interface{}) interface{} {
|
||||
// that key it will be replaced with the new value.
|
||||
//
|
||||
// Panics if the key type is not comparable.
|
||||
func (m *Properties) Set(key, value interface{}) {
|
||||
func (m *Properties) Set(key, value any) {
|
||||
m.lazyInit()
|
||||
m.values[key] = value
|
||||
}
|
||||
@@ -36,7 +38,7 @@ func (m *Properties) Set(key, value interface{}) {
|
||||
// Has returns whether the key exists in the metadata.
|
||||
//
|
||||
// Panics if the key type is not comparable.
|
||||
func (m *Properties) Has(key interface{}) bool {
|
||||
func (m *Properties) Has(key any) bool {
|
||||
m.lazyInit()
|
||||
_, ok := m.values[key]
|
||||
return ok
|
||||
@@ -55,8 +57,13 @@ func (m *Properties) SetAll(other *Properties) {
|
||||
}
|
||||
}
|
||||
|
||||
// Values returns a shallow clone of the property set's values.
|
||||
func (m *Properties) Values() map[any]any {
|
||||
return maps.Clone(m.values)
|
||||
}
|
||||
|
||||
func (m *Properties) lazyInit() {
|
||||
if m.values == nil {
|
||||
m.values = map[interface{}]interface{}{}
|
||||
m.values = map[any]any{}
|
||||
}
|
||||
}
|
||||
|
||||
96
vendor/github.com/aws/smithy-go/tracing/context.go
generated
vendored
Normal file
96
vendor/github.com/aws/smithy-go/tracing/context.go
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
package tracing
|
||||
|
||||
import "context"
|
||||
|
||||
type (
|
||||
operationTracerKey struct{}
|
||||
spanLineageKey struct{}
|
||||
)
|
||||
|
||||
// GetSpan returns the active trace Span on the context.
|
||||
//
|
||||
// The boolean in the return indicates whether a Span was actually in the
|
||||
// context, but a no-op implementation will be returned if not, so callers
|
||||
// can generally disregard the boolean unless they wish to explicitly confirm
|
||||
// presence/absence of a Span.
|
||||
func GetSpan(ctx context.Context) (Span, bool) {
|
||||
lineage := getLineage(ctx)
|
||||
if len(lineage) == 0 {
|
||||
return nopSpan{}, false
|
||||
}
|
||||
|
||||
return lineage[len(lineage)-1], true
|
||||
}
|
||||
|
||||
// WithSpan sets the active trace Span on the context.
|
||||
func WithSpan(parent context.Context, span Span) context.Context {
|
||||
lineage := getLineage(parent)
|
||||
if len(lineage) == 0 {
|
||||
return context.WithValue(parent, spanLineageKey{}, []Span{span})
|
||||
}
|
||||
|
||||
lineage = append(lineage, span)
|
||||
return context.WithValue(parent, spanLineageKey{}, lineage)
|
||||
}
|
||||
|
||||
// PopSpan pops the current Span off the context, setting the active Span on
|
||||
// the returned Context back to its parent and returning the REMOVED one.
|
||||
//
|
||||
// PopSpan on a context with no active Span will return a no-op instance.
|
||||
//
|
||||
// This is mostly necessary for the runtime to manage base trace spans due to
|
||||
// the wrapped-function nature of the middleware stack. End-users of Smithy
|
||||
// clients SHOULD NOT generally be using this API.
|
||||
func PopSpan(parent context.Context) (context.Context, Span) {
|
||||
lineage := getLineage(parent)
|
||||
if len(lineage) == 0 {
|
||||
return parent, nopSpan{}
|
||||
}
|
||||
|
||||
span := lineage[len(lineage)-1]
|
||||
lineage = lineage[:len(lineage)-1]
|
||||
return context.WithValue(parent, spanLineageKey{}, lineage), span
|
||||
}
|
||||
|
||||
func getLineage(ctx context.Context) []Span {
|
||||
v := ctx.Value(spanLineageKey{})
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return v.([]Span)
|
||||
}
|
||||
|
||||
// GetOperationTracer returns the embedded operation-scoped Tracer on a
|
||||
// Context.
|
||||
//
|
||||
// The boolean in the return indicates whether a Tracer was actually in the
|
||||
// context, but a no-op implementation will be returned if not, so callers
|
||||
// can generally disregard the boolean unless they wish to explicitly confirm
|
||||
// presence/absence of a Tracer.
|
||||
func GetOperationTracer(ctx context.Context) (Tracer, bool) {
|
||||
v := ctx.Value(operationTracerKey{})
|
||||
if v == nil {
|
||||
return nopTracer{}, false
|
||||
}
|
||||
|
||||
return v.(Tracer), true
|
||||
}
|
||||
|
||||
// WithOperationTracer returns a child Context embedding the given Tracer.
|
||||
//
|
||||
// The runtime will use this embed a scoped tracer for client operations,
|
||||
// Smithy/SDK client callers DO NOT need to do this explicitly.
|
||||
func WithOperationTracer(parent context.Context, tracer Tracer) context.Context {
|
||||
return context.WithValue(parent, operationTracerKey{}, tracer)
|
||||
}
|
||||
|
||||
// StartSpan is a convenience API for creating tracing Spans from a Context.
|
||||
//
|
||||
// StartSpan uses the operation-scoped Tracer, previously stored using
|
||||
// [WithOperationTracer], to start the Span. If a Tracer has not been embedded
|
||||
// the returned Span will be a no-op implementation.
|
||||
func StartSpan(ctx context.Context, name string, opts ...SpanOption) (context.Context, Span) {
|
||||
tracer, _ := GetOperationTracer(ctx)
|
||||
return tracer.StartSpan(ctx, name, opts...)
|
||||
}
|
||||
32
vendor/github.com/aws/smithy-go/tracing/nop.go
generated
vendored
Normal file
32
vendor/github.com/aws/smithy-go/tracing/nop.go
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
package tracing
|
||||
|
||||
import "context"
|
||||
|
||||
// NopTracerProvider is a no-op tracing implementation.
|
||||
type NopTracerProvider struct{}
|
||||
|
||||
var _ TracerProvider = (*NopTracerProvider)(nil)
|
||||
|
||||
// Tracer returns a tracer which creates no-op spans.
|
||||
func (NopTracerProvider) Tracer(string, ...TracerOption) Tracer {
|
||||
return nopTracer{}
|
||||
}
|
||||
|
||||
type nopTracer struct{}
|
||||
|
||||
var _ Tracer = (*nopTracer)(nil)
|
||||
|
||||
func (nopTracer) StartSpan(ctx context.Context, name string, opts ...SpanOption) (context.Context, Span) {
|
||||
return ctx, nopSpan{}
|
||||
}
|
||||
|
||||
type nopSpan struct{}
|
||||
|
||||
var _ Span = (*nopSpan)(nil)
|
||||
|
||||
func (nopSpan) Name() string { return "" }
|
||||
func (nopSpan) Context() SpanContext { return SpanContext{} }
|
||||
func (nopSpan) AddEvent(string, ...EventOption) {}
|
||||
func (nopSpan) SetProperty(any, any) {}
|
||||
func (nopSpan) SetStatus(SpanStatus) {}
|
||||
func (nopSpan) End() {}
|
||||
95
vendor/github.com/aws/smithy-go/tracing/tracing.go
generated
vendored
Normal file
95
vendor/github.com/aws/smithy-go/tracing/tracing.go
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
// Package tracing defines tracing APIs to be used by Smithy clients.
|
||||
package tracing
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/aws/smithy-go"
|
||||
)
|
||||
|
||||
// SpanStatus records the "success" state of an observed span.
|
||||
type SpanStatus int
|
||||
|
||||
// Enumeration of SpanStatus.
|
||||
const (
|
||||
SpanStatusUnset SpanStatus = iota
|
||||
SpanStatusOK
|
||||
SpanStatusError
|
||||
)
|
||||
|
||||
// SpanKind indicates the nature of the work being performed.
|
||||
type SpanKind int
|
||||
|
||||
// Enumeration of SpanKind.
|
||||
const (
|
||||
SpanKindInternal SpanKind = iota
|
||||
SpanKindClient
|
||||
SpanKindServer
|
||||
SpanKindProducer
|
||||
SpanKindConsumer
|
||||
)
|
||||
|
||||
// TracerProvider is the entry point for creating client traces.
|
||||
type TracerProvider interface {
|
||||
Tracer(scope string, opts ...TracerOption) Tracer
|
||||
}
|
||||
|
||||
// TracerOption applies configuration to a tracer.
|
||||
type TracerOption func(o *TracerOptions)
|
||||
|
||||
// TracerOptions represent configuration for tracers.
|
||||
type TracerOptions struct {
|
||||
Properties smithy.Properties
|
||||
}
|
||||
|
||||
// Tracer is the entry point for creating observed client Spans.
|
||||
//
|
||||
// Spans created by tracers propagate by existing on the Context. Consumers of
|
||||
// the API can use [GetSpan] to pull the active Span from a Context.
|
||||
//
|
||||
// Creation of child Spans is implicit through Context persistence. If
|
||||
// CreateSpan is called with a Context that holds a Span, the result will be a
|
||||
// child of that Span.
|
||||
type Tracer interface {
|
||||
StartSpan(ctx context.Context, name string, opts ...SpanOption) (context.Context, Span)
|
||||
}
|
||||
|
||||
// SpanOption applies configuration to a span.
|
||||
type SpanOption func(o *SpanOptions)
|
||||
|
||||
// SpanOptions represent configuration for span events.
|
||||
type SpanOptions struct {
|
||||
Kind SpanKind
|
||||
Properties smithy.Properties
|
||||
}
|
||||
|
||||
// Span records a conceptually individual unit of work that takes place in a
|
||||
// Smithy client operation.
|
||||
type Span interface {
|
||||
Name() string
|
||||
Context() SpanContext
|
||||
AddEvent(name string, opts ...EventOption)
|
||||
SetStatus(status SpanStatus)
|
||||
SetProperty(k, v any)
|
||||
End()
|
||||
}
|
||||
|
||||
// EventOption applies configuration to a span event.
|
||||
type EventOption func(o *EventOptions)
|
||||
|
||||
// EventOptions represent configuration for span events.
|
||||
type EventOptions struct {
|
||||
Properties smithy.Properties
|
||||
}
|
||||
|
||||
// SpanContext uniquely identifies a Span.
|
||||
type SpanContext struct {
|
||||
TraceID string
|
||||
SpanID string
|
||||
IsRemote bool
|
||||
}
|
||||
|
||||
// IsValid is true when a span has nonzero trace and span IDs.
|
||||
func (ctx *SpanContext) IsValid() bool {
|
||||
return len(ctx.TraceID) != 0 && len(ctx.SpanID) != 0
|
||||
}
|
||||
45
vendor/github.com/aws/smithy-go/transport/http/client.go
generated
vendored
45
vendor/github.com/aws/smithy-go/transport/http/client.go
generated
vendored
@@ -6,7 +6,9 @@ import (
|
||||
"net/http"
|
||||
|
||||
smithy "github.com/aws/smithy-go"
|
||||
"github.com/aws/smithy-go/metrics"
|
||||
"github.com/aws/smithy-go/middleware"
|
||||
"github.com/aws/smithy-go/tracing"
|
||||
)
|
||||
|
||||
// ClientDo provides the interface for custom HTTP client implementations.
|
||||
@@ -27,13 +29,30 @@ func (fn ClientDoFunc) Do(r *http.Request) (*http.Response, error) {
|
||||
// implementation is http.Client.
|
||||
type ClientHandler struct {
|
||||
client ClientDo
|
||||
|
||||
Meter metrics.Meter // For HTTP client metrics.
|
||||
}
|
||||
|
||||
// NewClientHandler returns an initialized middleware handler for the client.
|
||||
//
|
||||
// Deprecated: Use [NewClientHandlerWithOptions].
|
||||
func NewClientHandler(client ClientDo) ClientHandler {
|
||||
return ClientHandler{
|
||||
return NewClientHandlerWithOptions(client)
|
||||
}
|
||||
|
||||
// NewClientHandlerWithOptions returns an initialized middleware handler for the client
|
||||
// with applied options.
|
||||
func NewClientHandlerWithOptions(client ClientDo, opts ...func(*ClientHandler)) ClientHandler {
|
||||
h := ClientHandler{
|
||||
client: client,
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(&h)
|
||||
}
|
||||
if h.Meter == nil {
|
||||
h.Meter = metrics.NopMeterProvider{}.Meter("")
|
||||
}
|
||||
return h
|
||||
}
|
||||
|
||||
// Handle implements the middleware Handler interface, that will invoke the
|
||||
@@ -42,6 +61,14 @@ func NewClientHandler(client ClientDo) ClientHandler {
|
||||
func (c ClientHandler) Handle(ctx context.Context, input interface{}) (
|
||||
out interface{}, metadata middleware.Metadata, err error,
|
||||
) {
|
||||
ctx, span := tracing.StartSpan(ctx, "DoHTTPRequest")
|
||||
defer span.End()
|
||||
|
||||
ctx, client, err := withMetrics(ctx, c.client, c.Meter)
|
||||
if err != nil {
|
||||
return nil, metadata, fmt.Errorf("instrument with HTTP metrics: %w", err)
|
||||
}
|
||||
|
||||
req, ok := input.(*Request)
|
||||
if !ok {
|
||||
return nil, metadata, fmt.Errorf("expect Smithy http.Request value as input, got unsupported type %T", input)
|
||||
@@ -52,7 +79,17 @@ func (c ClientHandler) Handle(ctx context.Context, input interface{}) (
|
||||
return nil, metadata, err
|
||||
}
|
||||
|
||||
resp, err := c.client.Do(builtRequest)
|
||||
span.SetProperty("http.method", req.Method)
|
||||
span.SetProperty("http.request_content_length", -1) // at least indicate unknown
|
||||
length, ok, err := req.StreamLength()
|
||||
if err != nil {
|
||||
return nil, metadata, err
|
||||
}
|
||||
if ok {
|
||||
span.SetProperty("http.request_content_length", length)
|
||||
}
|
||||
|
||||
resp, err := client.Do(builtRequest)
|
||||
if resp == nil {
|
||||
// Ensure a http response value is always present to prevent unexpected
|
||||
// panics.
|
||||
@@ -79,6 +116,10 @@ func (c ClientHandler) Handle(ctx context.Context, input interface{}) (
|
||||
_ = builtRequest.Body.Close()
|
||||
}
|
||||
|
||||
span.SetProperty("net.protocol.version", fmt.Sprintf("%d.%d", resp.ProtoMajor, resp.ProtoMinor))
|
||||
span.SetProperty("http.status_code", resp.StatusCode)
|
||||
span.SetProperty("http.response_content_length", resp.ContentLength)
|
||||
|
||||
return &Response{Response: resp}, metadata, err
|
||||
}
|
||||
|
||||
|
||||
2
vendor/github.com/aws/smithy-go/transport/http/host.go
generated
vendored
2
vendor/github.com/aws/smithy-go/transport/http/host.go
generated
vendored
@@ -69,7 +69,7 @@ func ValidPortNumber(port string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// ValidHostLabel returns whether the label is a valid RFC 3986 host abel.
|
||||
// ValidHostLabel returns whether the label is a valid RFC 3986 host label.
|
||||
func ValidHostLabel(label string) bool {
|
||||
if l := len(label); l == 0 || l > 63 {
|
||||
return false
|
||||
|
||||
198
vendor/github.com/aws/smithy-go/transport/http/metrics.go
generated
vendored
Normal file
198
vendor/github.com/aws/smithy-go/transport/http/metrics.go
generated
vendored
Normal file
@@ -0,0 +1,198 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"net/http"
|
||||
"net/http/httptrace"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/aws/smithy-go/metrics"
|
||||
)
|
||||
|
||||
var now = time.Now
|
||||
|
||||
// withMetrics instruments an HTTP client and context to collect HTTP metrics.
|
||||
func withMetrics(parent context.Context, client ClientDo, meter metrics.Meter) (
|
||||
context.Context, ClientDo, error,
|
||||
) {
|
||||
hm, err := newHTTPMetrics(meter)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
ctx := httptrace.WithClientTrace(parent, &httptrace.ClientTrace{
|
||||
DNSStart: hm.DNSStart,
|
||||
ConnectStart: hm.ConnectStart,
|
||||
TLSHandshakeStart: hm.TLSHandshakeStart,
|
||||
|
||||
GotConn: hm.GotConn(parent),
|
||||
PutIdleConn: hm.PutIdleConn(parent),
|
||||
ConnectDone: hm.ConnectDone(parent),
|
||||
DNSDone: hm.DNSDone(parent),
|
||||
TLSHandshakeDone: hm.TLSHandshakeDone(parent),
|
||||
GotFirstResponseByte: hm.GotFirstResponseByte(parent),
|
||||
})
|
||||
return ctx, &timedClientDo{client, hm}, nil
|
||||
}
|
||||
|
||||
type timedClientDo struct {
|
||||
ClientDo
|
||||
hm *httpMetrics
|
||||
}
|
||||
|
||||
func (c *timedClientDo) Do(r *http.Request) (*http.Response, error) {
|
||||
c.hm.doStart.Store(now())
|
||||
resp, err := c.ClientDo.Do(r)
|
||||
|
||||
c.hm.DoRequestDuration.Record(r.Context(), c.hm.doStart.Elapsed())
|
||||
return resp, err
|
||||
}
|
||||
|
||||
type httpMetrics struct {
|
||||
DNSLookupDuration metrics.Float64Histogram // client.http.connections.dns_lookup_duration
|
||||
ConnectDuration metrics.Float64Histogram // client.http.connections.acquire_duration
|
||||
TLSHandshakeDuration metrics.Float64Histogram // client.http.connections.tls_handshake_duration
|
||||
ConnectionUsage metrics.Int64UpDownCounter // client.http.connections.usage
|
||||
|
||||
DoRequestDuration metrics.Float64Histogram // client.http.do_request_duration
|
||||
TimeToFirstByte metrics.Float64Histogram // client.http.time_to_first_byte
|
||||
|
||||
doStart safeTime
|
||||
dnsStart safeTime
|
||||
connectStart safeTime
|
||||
tlsStart safeTime
|
||||
}
|
||||
|
||||
func newHTTPMetrics(meter metrics.Meter) (*httpMetrics, error) {
|
||||
hm := &httpMetrics{}
|
||||
|
||||
var err error
|
||||
hm.DNSLookupDuration, err = meter.Float64Histogram("client.http.connections.dns_lookup_duration", func(o *metrics.InstrumentOptions) {
|
||||
o.UnitLabel = "s"
|
||||
o.Description = "The time it takes a request to perform DNS lookup."
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
hm.ConnectDuration, err = meter.Float64Histogram("client.http.connections.acquire_duration", func(o *metrics.InstrumentOptions) {
|
||||
o.UnitLabel = "s"
|
||||
o.Description = "The time it takes a request to acquire a connection."
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
hm.TLSHandshakeDuration, err = meter.Float64Histogram("client.http.connections.tls_handshake_duration", func(o *metrics.InstrumentOptions) {
|
||||
o.UnitLabel = "s"
|
||||
o.Description = "The time it takes an HTTP request to perform the TLS handshake."
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
hm.ConnectionUsage, err = meter.Int64UpDownCounter("client.http.connections.usage", func(o *metrics.InstrumentOptions) {
|
||||
o.UnitLabel = "{connection}"
|
||||
o.Description = "Current state of connections pool."
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
hm.DoRequestDuration, err = meter.Float64Histogram("client.http.do_request_duration", func(o *metrics.InstrumentOptions) {
|
||||
o.UnitLabel = "s"
|
||||
o.Description = "Time spent performing an entire HTTP transaction."
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
hm.TimeToFirstByte, err = meter.Float64Histogram("client.http.time_to_first_byte", func(o *metrics.InstrumentOptions) {
|
||||
o.UnitLabel = "s"
|
||||
o.Description = "Time from start of transaction to when the first response byte is available."
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return hm, nil
|
||||
}
|
||||
|
||||
func (m *httpMetrics) DNSStart(httptrace.DNSStartInfo) {
|
||||
m.dnsStart.Store(now())
|
||||
}
|
||||
|
||||
func (m *httpMetrics) ConnectStart(string, string) {
|
||||
m.connectStart.Store(now())
|
||||
}
|
||||
|
||||
func (m *httpMetrics) TLSHandshakeStart() {
|
||||
m.tlsStart.Store(now())
|
||||
}
|
||||
|
||||
func (m *httpMetrics) GotConn(ctx context.Context) func(httptrace.GotConnInfo) {
|
||||
return func(httptrace.GotConnInfo) {
|
||||
m.addConnAcquired(ctx, 1)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *httpMetrics) PutIdleConn(ctx context.Context) func(error) {
|
||||
return func(error) {
|
||||
m.addConnAcquired(ctx, -1)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *httpMetrics) DNSDone(ctx context.Context) func(httptrace.DNSDoneInfo) {
|
||||
return func(httptrace.DNSDoneInfo) {
|
||||
m.DNSLookupDuration.Record(ctx, m.dnsStart.Elapsed())
|
||||
}
|
||||
}
|
||||
|
||||
func (m *httpMetrics) ConnectDone(ctx context.Context) func(string, string, error) {
|
||||
return func(string, string, error) {
|
||||
m.ConnectDuration.Record(ctx, m.connectStart.Elapsed())
|
||||
}
|
||||
}
|
||||
|
||||
func (m *httpMetrics) TLSHandshakeDone(ctx context.Context) func(tls.ConnectionState, error) {
|
||||
return func(tls.ConnectionState, error) {
|
||||
m.TLSHandshakeDuration.Record(ctx, m.tlsStart.Elapsed())
|
||||
}
|
||||
}
|
||||
|
||||
func (m *httpMetrics) GotFirstResponseByte(ctx context.Context) func() {
|
||||
return func() {
|
||||
m.TimeToFirstByte.Record(ctx, m.doStart.Elapsed())
|
||||
}
|
||||
}
|
||||
|
||||
func (m *httpMetrics) addConnAcquired(ctx context.Context, incr int64) {
|
||||
m.ConnectionUsage.Add(ctx, incr, func(o *metrics.RecordMetricOptions) {
|
||||
o.Properties.Set("state", "acquired")
|
||||
})
|
||||
}
|
||||
|
||||
// Not used: it is recommended to track acquired vs idle conn, but we can't
|
||||
// determine when something is truly idle with the current HTTP client hooks
|
||||
// available to us.
|
||||
func (m *httpMetrics) addConnIdle(ctx context.Context, incr int64) {
|
||||
m.ConnectionUsage.Add(ctx, incr, func(o *metrics.RecordMetricOptions) {
|
||||
o.Properties.Set("state", "idle")
|
||||
})
|
||||
}
|
||||
|
||||
type safeTime struct {
|
||||
atomic.Value // time.Time
|
||||
}
|
||||
|
||||
func (st *safeTime) Store(v time.Time) {
|
||||
st.Value.Store(v)
|
||||
}
|
||||
|
||||
func (st *safeTime) Load() time.Time {
|
||||
t, _ := st.Value.Load().(time.Time)
|
||||
return t
|
||||
}
|
||||
|
||||
func (st *safeTime) Elapsed() float64 {
|
||||
end := now()
|
||||
elapsed := end.Sub(st.Load())
|
||||
return float64(elapsed) / 1e9
|
||||
}
|
||||
8
vendor/github.com/aws/smithy-go/transport/http/middleware_close_response_body.go
generated
vendored
8
vendor/github.com/aws/smithy-go/transport/http/middleware_close_response_body.go
generated
vendored
@@ -2,10 +2,10 @@ package http
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
|
||||
"github.com/aws/smithy-go/logging"
|
||||
"github.com/aws/smithy-go/middleware"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
// AddErrorCloseResponseBodyMiddleware adds the middleware to automatically
|
||||
@@ -30,7 +30,7 @@ func (m *errorCloseResponseBodyMiddleware) HandleDeserialize(
|
||||
if err != nil {
|
||||
if resp, ok := out.RawResponse.(*Response); ok && resp != nil && resp.Body != nil {
|
||||
// Consume the full body to prevent TCP connection resets on some platforms
|
||||
_, _ = io.Copy(ioutil.Discard, resp.Body)
|
||||
_, _ = io.Copy(io.Discard, resp.Body)
|
||||
// Do not validate that the response closes successfully.
|
||||
resp.Body.Close()
|
||||
}
|
||||
@@ -64,7 +64,7 @@ func (m *closeResponseBody) HandleDeserialize(
|
||||
|
||||
if resp, ok := out.RawResponse.(*Response); ok {
|
||||
// Consume the full body to prevent TCP connection resets on some platforms
|
||||
_, copyErr := io.Copy(ioutil.Discard, resp.Body)
|
||||
_, copyErr := io.Copy(io.Discard, resp.Body)
|
||||
if copyErr != nil {
|
||||
middleware.GetLogger(ctx).Logf(logging.Warn, "failed to discard remaining HTTP response body, this may affect connection reuse")
|
||||
}
|
||||
|
||||
5
vendor/github.com/aws/smithy-go/transport/http/request.go
generated
vendored
5
vendor/github.com/aws/smithy-go/transport/http/request.go
generated
vendored
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
@@ -167,7 +166,7 @@ func (r *Request) Build(ctx context.Context) *http.Request {
|
||||
|
||||
switch stream := r.stream.(type) {
|
||||
case *io.PipeReader:
|
||||
req.Body = ioutil.NopCloser(stream)
|
||||
req.Body = io.NopCloser(stream)
|
||||
req.ContentLength = -1
|
||||
default:
|
||||
// HTTP Client Request must only have a non-nil body if the
|
||||
@@ -175,7 +174,7 @@ func (r *Request) Build(ctx context.Context) *http.Request {
|
||||
// Client will interpret a non-nil body and ContentLength 0 as
|
||||
// "unknown". This is unwanted behavior.
|
||||
if req.ContentLength != 0 && r.stream != nil {
|
||||
req.Body = iointernal.NewSafeReadCloser(ioutil.NopCloser(stream))
|
||||
req.Body = iointernal.NewSafeReadCloser(io.NopCloser(stream))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user