updated etcd to v3.5.5 and newer otel libraries as well

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This commit is contained in:
Davanum Srinivas
2022-09-17 14:04:16 -04:00
parent 23a4920d83
commit 5be80c05c4
439 changed files with 28673 additions and 20196 deletions

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package otelrestful
package otelrestful // import "go.opentelemetry.io/contrib/instrumentation/github.com/emicklei/go-restful/otelrestful"
import (
"go.opentelemetry.io/otel/propagation"
@@ -25,22 +25,34 @@ type config struct {
Propagators propagation.TextMapPropagator
}
// Option specifies instrumentation configuration options.
type Option func(*config)
// Option applies a configuration value.
type Option interface {
apply(*config)
}
type optionFunc func(*config)
func (o optionFunc) apply(c *config) {
o(c)
}
// WithPropagators specifies propagators to use for extracting
// information from the HTTP requests. If none are specified, global
// ones will be used.
func WithPropagators(propagators propagation.TextMapPropagator) Option {
return func(cfg *config) {
cfg.Propagators = propagators
}
return optionFunc(func(cfg *config) {
if propagators != nil {
cfg.Propagators = propagators
}
})
}
// WithTracerProvider specifies a tracer provider to use for creating a tracer.
// If none is specified, the global provider is used.
func WithTracerProvider(provider oteltrace.TracerProvider) Option {
return func(cfg *config) {
cfg.TracerProvider = provider
}
return optionFunc(func(cfg *config) {
if provider != nil {
cfg.TracerProvider = provider
}
})
}

View File

@@ -19,7 +19,7 @@
//
// Instrumentation of an incoming request is achieved via a go-restful
// FilterFunc called `OTelFilterFunc` which may be applied at any one of
// * the container level
// * webservice level
// * route level
// - the container level
// - webservice level
// - route level
package otelrestful // import "go.opentelemetry.io/contrib/instrumentation/github.com/emicklei/go-restful/otelrestful"

View File

@@ -12,15 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package otelrestful
package otelrestful // import "go.opentelemetry.io/contrib/instrumentation/github.com/emicklei/go-restful/otelrestful"
import (
"github.com/emicklei/go-restful/v3"
"go.opentelemetry.io/contrib"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/semconv"
semconv "go.opentelemetry.io/otel/semconv/v1.12.0"
oteltrace "go.opentelemetry.io/otel/trace"
)
@@ -34,14 +33,14 @@ const tracerName = "go.opentelemetry.io/contrib/instrumentation/github.com/emick
func OTelFilter(service string, opts ...Option) restful.FilterFunction {
cfg := config{}
for _, opt := range opts {
opt(&cfg)
opt.apply(&cfg)
}
if cfg.TracerProvider == nil {
cfg.TracerProvider = otel.GetTracerProvider()
}
tracer := cfg.TracerProvider.Tracer(
tracerName,
oteltrace.WithInstrumentationVersion(contrib.SemVersion()),
oteltrace.WithInstrumentationVersion(SemVersion()),
)
if cfg.Propagators == nil {
cfg.Propagators = otel.GetTextMapPropagator()
@@ -52,13 +51,12 @@ func OTelFilter(service string, opts ...Option) restful.FilterFunction {
route := req.SelectedRoutePath()
spanName := route
opts := []oteltrace.SpanOption{
ctx, span := tracer.Start(ctx, spanName,
oteltrace.WithAttributes(semconv.NetAttributesFromHTTPRequest("tcp", r)...),
oteltrace.WithAttributes(semconv.EndUserAttributesFromHTTPRequest(r)...),
oteltrace.WithAttributes(semconv.HTTPServerAttributesFromHTTPRequest(service, route, r)...),
oteltrace.WithSpanKind(oteltrace.SpanKindServer),
}
ctx, span := tracer.Start(ctx, spanName, opts...)
)
defer span.End()
// pass the span through the request context
@@ -67,7 +65,7 @@ func OTelFilter(service string, opts ...Option) restful.FilterFunction {
chain.ProcessFilter(req, resp)
attrs := semconv.HTTPAttributesFromHTTPStatusCode(resp.StatusCode())
spanStatus, spanMessage := semconv.SpanStatusFromHTTPStatusCode(resp.StatusCode())
spanStatus, spanMessage := semconv.SpanStatusFromHTTPStatusCodeAndSpanKind(resp.StatusCode(), oteltrace.SpanKindServer)
span.SetAttributes(attrs...)
span.SetStatus(spanStatus, spanMessage)
}

View File

@@ -0,0 +1,26 @@
// Copyright The OpenTelemetry 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 otelrestful // import "go.opentelemetry.io/contrib/instrumentation/github.com/emicklei/go-restful/otelrestful"
// Version is the current release version of the go-restful instrumentation.
func Version() string {
return "0.35.0"
// This string is updated by the pre_release.sh script during release
}
// SemVersion is the semantic version to be supplied to tracer/meter creation.
func SemVersion() string {
return "semver:" + Version()
}