Switch to go modules
This commit is contained in:
parent
461954facb
commit
1720059244
763 changed files with 24896 additions and 177398 deletions
2
vendor/go.opencensus.io/plugin/ochttp/client_stats.go
generated
vendored
2
vendor/go.opencensus.io/plugin/ochttp/client_stats.go
generated
vendored
|
|
@ -68,7 +68,7 @@ func (t statsTransport) RoundTrip(req *http.Request) (*http.Response, error) {
|
|||
track.end()
|
||||
} else {
|
||||
track.body = resp.Body
|
||||
resp.Body = track
|
||||
resp.Body = wrappedBody(track, resp.Body)
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
|
|
|
|||
17
vendor/go.opencensus.io/plugin/ochttp/trace.go
generated
vendored
17
vendor/go.opencensus.io/plugin/ochttp/trace.go
generated
vendored
|
|
@ -34,6 +34,7 @@ const (
|
|||
HostAttribute = "http.host"
|
||||
MethodAttribute = "http.method"
|
||||
PathAttribute = "http.path"
|
||||
URLAttribute = "http.url"
|
||||
UserAgentAttribute = "http.user_agent"
|
||||
StatusCodeAttribute = "http.status_code"
|
||||
)
|
||||
|
|
@ -93,7 +94,8 @@ func (t *traceTransport) RoundTrip(req *http.Request) (*http.Response, error) {
|
|||
// span.End() will be invoked after
|
||||
// a read from resp.Body returns io.EOF or when
|
||||
// resp.Body.Close() is invoked.
|
||||
resp.Body = &bodyTracker{rc: resp.Body, span: span}
|
||||
bt := &bodyTracker{rc: resp.Body, span: span}
|
||||
resp.Body = wrappedBody(bt, resp.Body)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
|
|
@ -149,12 +151,21 @@ func spanNameFromURL(req *http.Request) string {
|
|||
}
|
||||
|
||||
func requestAttrs(r *http.Request) []trace.Attribute {
|
||||
return []trace.Attribute{
|
||||
userAgent := r.UserAgent()
|
||||
|
||||
attrs := make([]trace.Attribute, 0, 5)
|
||||
attrs = append(attrs,
|
||||
trace.StringAttribute(PathAttribute, r.URL.Path),
|
||||
trace.StringAttribute(URLAttribute, r.URL.String()),
|
||||
trace.StringAttribute(HostAttribute, r.Host),
|
||||
trace.StringAttribute(MethodAttribute, r.Method),
|
||||
trace.StringAttribute(UserAgentAttribute, r.UserAgent()),
|
||||
)
|
||||
|
||||
if userAgent != "" {
|
||||
attrs = append(attrs, trace.StringAttribute(UserAgentAttribute, userAgent))
|
||||
}
|
||||
|
||||
return attrs
|
||||
}
|
||||
|
||||
func responseAttrs(resp *http.Response) []trace.Attribute {
|
||||
|
|
|
|||
44
vendor/go.opencensus.io/plugin/ochttp/wrapped_body.go
generated
vendored
Normal file
44
vendor/go.opencensus.io/plugin/ochttp/wrapped_body.go
generated
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
// Copyright 2019, OpenCensus 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 ochttp
|
||||
|
||||
import (
|
||||
"io"
|
||||
)
|
||||
|
||||
// wrappedBody returns a wrapped version of the original
|
||||
// Body and only implements the same combination of additional
|
||||
// interfaces as the original.
|
||||
func wrappedBody(wrapper io.ReadCloser, body io.ReadCloser) io.ReadCloser {
|
||||
var (
|
||||
wr, i0 = body.(io.Writer)
|
||||
)
|
||||
switch {
|
||||
case !i0:
|
||||
return struct {
|
||||
io.ReadCloser
|
||||
}{wrapper}
|
||||
|
||||
case i0:
|
||||
return struct {
|
||||
io.ReadCloser
|
||||
io.Writer
|
||||
}{wrapper, wr}
|
||||
default:
|
||||
return struct {
|
||||
io.ReadCloser
|
||||
}{wrapper}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue