mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-04-11 11:21:59 +02:00
Rename api/standard package to semconv (#1016)
* Rename api/standard package to semconv * Update `api/standard` package dependencies to `semconv` * Update Changelog * Add PR number to Changelog
This commit is contained in:
parent
fc1ce6cb8f
commit
96a5f8ff46
@ -8,6 +8,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Changed
|
||||
|
||||
- Renamed `go.opentelemetry.io/otel/api/standard` package to `go.opentelemetry.io/otel/semconv` to avoid the ambiguous and generic name `standard` and better describe the package as containing OpenTelemetry semantic conventions. (#1016)
|
||||
|
||||
## [0.10.0] - 2020-07-29
|
||||
|
||||
This release migrates the default OpenTelemetry SDK into its own Go module, decoupling the SDK from the API and reducing dependencies for instrumentation packages.
|
||||
|
@ -22,8 +22,8 @@ import (
|
||||
"log"
|
||||
|
||||
"go.opentelemetry.io/otel/api/kv"
|
||||
"go.opentelemetry.io/otel/api/standard"
|
||||
"go.opentelemetry.io/otel/api/trace"
|
||||
"go.opentelemetry.io/otel/semconv"
|
||||
|
||||
"net/http"
|
||||
"time"
|
||||
@ -83,7 +83,7 @@ func main() {
|
||||
|
||||
return err
|
||||
},
|
||||
trace.WithAttributes(standard.PeerServiceKey.String("ExampleService")))
|
||||
trace.WithAttributes(semconv.PeerServiceKey.String("ExampleService")))
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -21,12 +21,12 @@ import (
|
||||
|
||||
"go.opentelemetry.io/otel/api/correlation"
|
||||
"go.opentelemetry.io/otel/api/global"
|
||||
"go.opentelemetry.io/otel/api/standard"
|
||||
"go.opentelemetry.io/otel/api/trace"
|
||||
"go.opentelemetry.io/otel/exporters/stdout"
|
||||
"go.opentelemetry.io/otel/instrumentation/httptrace"
|
||||
"go.opentelemetry.io/otel/sdk/resource"
|
||||
sdktrace "go.opentelemetry.io/otel/sdk/trace"
|
||||
"go.opentelemetry.io/otel/semconv"
|
||||
)
|
||||
|
||||
func initTracer() {
|
||||
@ -41,7 +41,7 @@ func initTracer() {
|
||||
// In a production application, use sdktrace.ProbabilitySampler with a desired probability.
|
||||
tp, err := sdktrace.NewProvider(sdktrace.WithConfig(sdktrace.Config{DefaultSampler: sdktrace.AlwaysSample()}),
|
||||
sdktrace.WithSyncer(exporter),
|
||||
sdktrace.WithResource(resource.New(standard.ServiceNameKey.String("ExampleService"))))
|
||||
sdktrace.WithResource(resource.New(semconv.ServiceNameKey.String("ExampleService"))))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -28,13 +28,13 @@ import (
|
||||
"go.opentelemetry.io/otel/api/global"
|
||||
"go.opentelemetry.io/otel/api/kv"
|
||||
"go.opentelemetry.io/otel/api/metric"
|
||||
"go.opentelemetry.io/otel/api/standard"
|
||||
apitrace "go.opentelemetry.io/otel/api/trace"
|
||||
"go.opentelemetry.io/otel/exporters/otlp"
|
||||
"go.opentelemetry.io/otel/sdk/metric/controller/push"
|
||||
"go.opentelemetry.io/otel/sdk/metric/selector/simple"
|
||||
"go.opentelemetry.io/otel/sdk/resource"
|
||||
sdktrace "go.opentelemetry.io/otel/sdk/trace"
|
||||
"go.opentelemetry.io/otel/semconv"
|
||||
)
|
||||
|
||||
// Initializes an OTLP exporter, and configures the corresponding trace and
|
||||
@ -57,7 +57,7 @@ func initProvider() (*otlp.Exporter, *push.Controller) {
|
||||
sdktrace.WithConfig(sdktrace.Config{DefaultSampler: sdktrace.AlwaysSample()}),
|
||||
sdktrace.WithResource(resource.New(
|
||||
// the service name used to display traces in backends
|
||||
kv.Key(standard.ServiceNameKey).String("test-service"),
|
||||
kv.Key(semconv.ServiceNameKey).String("test-service"),
|
||||
)),
|
||||
sdktrace.WithSyncer(exp),
|
||||
)
|
||||
|
@ -22,7 +22,7 @@ import (
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"go.opentelemetry.io/otel/api/standard"
|
||||
"go.opentelemetry.io/otel/semconv"
|
||||
|
||||
"github.com/golang/protobuf/proto" //nolint:staticcheck
|
||||
|
||||
@ -45,20 +45,20 @@ func (m messageType) Event(ctx context.Context, id int, message interface{}) {
|
||||
if p, ok := message.(proto.Message); ok {
|
||||
span.AddEvent(ctx, "message",
|
||||
kv.KeyValue(m),
|
||||
standard.RPCMessageIDKey.Int(id),
|
||||
standard.RPCMessageUncompressedSizeKey.Int(proto.Size(p)),
|
||||
semconv.RPCMessageIDKey.Int(id),
|
||||
semconv.RPCMessageUncompressedSizeKey.Int(proto.Size(p)),
|
||||
)
|
||||
} else {
|
||||
span.AddEvent(ctx, "message",
|
||||
kv.KeyValue(m),
|
||||
standard.RPCMessageIDKey.Int(id),
|
||||
semconv.RPCMessageIDKey.Int(id),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
messageSent = messageType(standard.RPCMessageTypeSent)
|
||||
messageReceived = messageType(standard.RPCMessageTypeReceived)
|
||||
messageSent = messageType(semconv.RPCMessageTypeSent)
|
||||
messageReceived = messageType(semconv.RPCMessageTypeReceived)
|
||||
)
|
||||
|
||||
// UnaryClientInterceptor returns a grpc.UnaryClientInterceptor suitable
|
||||
@ -404,7 +404,7 @@ func StreamServerInterceptor(tracer trace.Tracer, opts ...Option) grpc.StreamSer
|
||||
// spanInfo returns a span name and all appropriate attributes from the gRPC
|
||||
// method and peer address.
|
||||
func spanInfo(fullMethod, peerAddress string) (string, []kv.KeyValue) {
|
||||
attrs := []kv.KeyValue{standard.RPCSystemGRPC}
|
||||
attrs := []kv.KeyValue{semconv.RPCSystemGRPC}
|
||||
name, mAttrs := parseFullMethod(fullMethod)
|
||||
attrs = append(attrs, mAttrs...)
|
||||
attrs = append(attrs, peerAttr(peerAddress)...)
|
||||
@ -423,8 +423,8 @@ func peerAttr(addr string) []kv.KeyValue {
|
||||
}
|
||||
|
||||
return []kv.KeyValue{
|
||||
standard.NetPeerIPKey.String(host),
|
||||
standard.NetPeerPortKey.String(port),
|
||||
semconv.NetPeerIPKey.String(host),
|
||||
semconv.NetPeerPortKey.String(port),
|
||||
}
|
||||
}
|
||||
|
||||
@ -450,10 +450,10 @@ func parseFullMethod(fullMethod string) (string, []kv.KeyValue) {
|
||||
|
||||
var attrs []kv.KeyValue
|
||||
if service := parts[0]; service != "" {
|
||||
attrs = append(attrs, standard.RPCServiceKey.String(service))
|
||||
attrs = append(attrs, semconv.RPCServiceKey.String(service))
|
||||
}
|
||||
if method := parts[1]; method != "" {
|
||||
attrs = append(attrs, standard.RPCMethodKey.String(method))
|
||||
attrs = append(attrs, semconv.RPCMethodKey.String(method))
|
||||
}
|
||||
return name, attrs
|
||||
}
|
||||
|
@ -19,8 +19,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/api/standard"
|
||||
"go.opentelemetry.io/otel/api/trace/testtrace"
|
||||
"go.opentelemetry.io/otel/semconv"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@ -105,22 +105,22 @@ func TestUnaryClientInterceptor(t *testing.T) {
|
||||
method: "/github.com.serviceName/bar",
|
||||
name: "github.com.serviceName/bar",
|
||||
expectedAttr: map[kv.Key]kv.Value{
|
||||
standard.RPCSystemKey: kv.StringValue("grpc"),
|
||||
standard.RPCServiceKey: kv.StringValue("github.com.serviceName"),
|
||||
standard.RPCMethodKey: kv.StringValue("bar"),
|
||||
standard.NetPeerIPKey: kv.StringValue("fake"),
|
||||
standard.NetPeerPortKey: kv.StringValue("connection"),
|
||||
semconv.RPCSystemKey: kv.StringValue("grpc"),
|
||||
semconv.RPCServiceKey: kv.StringValue("github.com.serviceName"),
|
||||
semconv.RPCMethodKey: kv.StringValue("bar"),
|
||||
semconv.NetPeerIPKey: kv.StringValue("fake"),
|
||||
semconv.NetPeerPortKey: kv.StringValue("connection"),
|
||||
},
|
||||
eventsAttr: []map[kv.Key]kv.Value{
|
||||
{
|
||||
standard.RPCMessageTypeKey: kv.StringValue("SENT"),
|
||||
standard.RPCMessageIDKey: kv.IntValue(1),
|
||||
standard.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(req))),
|
||||
semconv.RPCMessageTypeKey: kv.StringValue("SENT"),
|
||||
semconv.RPCMessageIDKey: kv.IntValue(1),
|
||||
semconv.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(req))),
|
||||
},
|
||||
{
|
||||
standard.RPCMessageTypeKey: kv.StringValue("RECEIVED"),
|
||||
standard.RPCMessageIDKey: kv.IntValue(1),
|
||||
standard.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(reply))),
|
||||
semconv.RPCMessageTypeKey: kv.StringValue("RECEIVED"),
|
||||
semconv.RPCMessageIDKey: kv.IntValue(1),
|
||||
semconv.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(reply))),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -128,22 +128,22 @@ func TestUnaryClientInterceptor(t *testing.T) {
|
||||
method: "/serviceName/bar",
|
||||
name: "serviceName/bar",
|
||||
expectedAttr: map[kv.Key]kv.Value{
|
||||
standard.RPCSystemKey: kv.StringValue("grpc"),
|
||||
standard.RPCServiceKey: kv.StringValue("serviceName"),
|
||||
standard.RPCMethodKey: kv.StringValue("bar"),
|
||||
standard.NetPeerIPKey: kv.StringValue("fake"),
|
||||
standard.NetPeerPortKey: kv.StringValue("connection"),
|
||||
semconv.RPCSystemKey: kv.StringValue("grpc"),
|
||||
semconv.RPCServiceKey: kv.StringValue("serviceName"),
|
||||
semconv.RPCMethodKey: kv.StringValue("bar"),
|
||||
semconv.NetPeerIPKey: kv.StringValue("fake"),
|
||||
semconv.NetPeerPortKey: kv.StringValue("connection"),
|
||||
},
|
||||
eventsAttr: []map[kv.Key]kv.Value{
|
||||
{
|
||||
standard.RPCMessageTypeKey: kv.StringValue("SENT"),
|
||||
standard.RPCMessageIDKey: kv.IntValue(1),
|
||||
standard.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(req))),
|
||||
semconv.RPCMessageTypeKey: kv.StringValue("SENT"),
|
||||
semconv.RPCMessageIDKey: kv.IntValue(1),
|
||||
semconv.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(req))),
|
||||
},
|
||||
{
|
||||
standard.RPCMessageTypeKey: kv.StringValue("RECEIVED"),
|
||||
standard.RPCMessageIDKey: kv.IntValue(1),
|
||||
standard.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(reply))),
|
||||
semconv.RPCMessageTypeKey: kv.StringValue("RECEIVED"),
|
||||
semconv.RPCMessageIDKey: kv.IntValue(1),
|
||||
semconv.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(reply))),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -151,22 +151,22 @@ func TestUnaryClientInterceptor(t *testing.T) {
|
||||
method: "serviceName/bar",
|
||||
name: "serviceName/bar",
|
||||
expectedAttr: map[kv.Key]kv.Value{
|
||||
standard.RPCSystemKey: kv.StringValue("grpc"),
|
||||
standard.RPCServiceKey: kv.StringValue("serviceName"),
|
||||
standard.RPCMethodKey: kv.StringValue("bar"),
|
||||
standard.NetPeerIPKey: kv.StringValue("fake"),
|
||||
standard.NetPeerPortKey: kv.StringValue("connection"),
|
||||
semconv.RPCSystemKey: kv.StringValue("grpc"),
|
||||
semconv.RPCServiceKey: kv.StringValue("serviceName"),
|
||||
semconv.RPCMethodKey: kv.StringValue("bar"),
|
||||
semconv.NetPeerIPKey: kv.StringValue("fake"),
|
||||
semconv.NetPeerPortKey: kv.StringValue("connection"),
|
||||
},
|
||||
eventsAttr: []map[kv.Key]kv.Value{
|
||||
{
|
||||
standard.RPCMessageTypeKey: kv.StringValue("SENT"),
|
||||
standard.RPCMessageIDKey: kv.IntValue(1),
|
||||
standard.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(req))),
|
||||
semconv.RPCMessageTypeKey: kv.StringValue("SENT"),
|
||||
semconv.RPCMessageIDKey: kv.IntValue(1),
|
||||
semconv.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(req))),
|
||||
},
|
||||
{
|
||||
standard.RPCMessageTypeKey: kv.StringValue("RECEIVED"),
|
||||
standard.RPCMessageIDKey: kv.IntValue(1),
|
||||
standard.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(reply))),
|
||||
semconv.RPCMessageTypeKey: kv.StringValue("RECEIVED"),
|
||||
semconv.RPCMessageIDKey: kv.IntValue(1),
|
||||
semconv.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(reply))),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -174,20 +174,20 @@ func TestUnaryClientInterceptor(t *testing.T) {
|
||||
method: "invalidName",
|
||||
name: "invalidName",
|
||||
expectedAttr: map[kv.Key]kv.Value{
|
||||
standard.RPCSystemKey: kv.StringValue("grpc"),
|
||||
standard.NetPeerIPKey: kv.StringValue("fake"),
|
||||
standard.NetPeerPortKey: kv.StringValue("connection"),
|
||||
semconv.RPCSystemKey: kv.StringValue("grpc"),
|
||||
semconv.NetPeerIPKey: kv.StringValue("fake"),
|
||||
semconv.NetPeerPortKey: kv.StringValue("connection"),
|
||||
},
|
||||
eventsAttr: []map[kv.Key]kv.Value{
|
||||
{
|
||||
standard.RPCMessageTypeKey: kv.StringValue("SENT"),
|
||||
standard.RPCMessageIDKey: kv.IntValue(1),
|
||||
standard.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(req))),
|
||||
semconv.RPCMessageTypeKey: kv.StringValue("SENT"),
|
||||
semconv.RPCMessageIDKey: kv.IntValue(1),
|
||||
semconv.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(req))),
|
||||
},
|
||||
{
|
||||
standard.RPCMessageTypeKey: kv.StringValue("RECEIVED"),
|
||||
standard.RPCMessageIDKey: kv.IntValue(1),
|
||||
standard.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(reply))),
|
||||
semconv.RPCMessageTypeKey: kv.StringValue("RECEIVED"),
|
||||
semconv.RPCMessageIDKey: kv.IntValue(1),
|
||||
semconv.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(reply))),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -195,22 +195,22 @@ func TestUnaryClientInterceptor(t *testing.T) {
|
||||
method: "/github.com.foo.serviceName_123/method",
|
||||
name: "github.com.foo.serviceName_123/method",
|
||||
expectedAttr: map[kv.Key]kv.Value{
|
||||
standard.RPCSystemKey: kv.StringValue("grpc"),
|
||||
standard.RPCServiceKey: kv.StringValue("github.com.foo.serviceName_123"),
|
||||
standard.RPCMethodKey: kv.StringValue("method"),
|
||||
standard.NetPeerIPKey: kv.StringValue("fake"),
|
||||
standard.NetPeerPortKey: kv.StringValue("connection"),
|
||||
semconv.RPCSystemKey: kv.StringValue("grpc"),
|
||||
semconv.RPCServiceKey: kv.StringValue("github.com.foo.serviceName_123"),
|
||||
semconv.RPCMethodKey: kv.StringValue("method"),
|
||||
semconv.NetPeerIPKey: kv.StringValue("fake"),
|
||||
semconv.NetPeerPortKey: kv.StringValue("connection"),
|
||||
},
|
||||
eventsAttr: []map[kv.Key]kv.Value{
|
||||
{
|
||||
standard.RPCMessageTypeKey: kv.StringValue("SENT"),
|
||||
standard.RPCMessageIDKey: kv.IntValue(1),
|
||||
standard.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(req))),
|
||||
semconv.RPCMessageTypeKey: kv.StringValue("SENT"),
|
||||
semconv.RPCMessageIDKey: kv.IntValue(1),
|
||||
semconv.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(req))),
|
||||
},
|
||||
{
|
||||
standard.RPCMessageTypeKey: kv.StringValue("RECEIVED"),
|
||||
standard.RPCMessageIDKey: kv.IntValue(1),
|
||||
standard.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(reply))),
|
||||
semconv.RPCMessageTypeKey: kv.StringValue("RECEIVED"),
|
||||
semconv.RPCMessageIDKey: kv.IntValue(1),
|
||||
semconv.RPCMessageUncompressedSizeKey: kv.IntValue(proto.Size(proto.Message(reply))),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -309,11 +309,11 @@ func TestStreamClientInterceptor(t *testing.T) {
|
||||
require.True(t, ok, "missing span %s", name)
|
||||
|
||||
expectedAttr := map[kv.Key]kv.Value{
|
||||
standard.RPCSystemKey: kv.StringValue("grpc"),
|
||||
standard.RPCServiceKey: kv.StringValue("github.com.serviceName"),
|
||||
standard.RPCMethodKey: kv.StringValue("bar"),
|
||||
standard.NetPeerIPKey: kv.StringValue("fake"),
|
||||
standard.NetPeerPortKey: kv.StringValue("connection"),
|
||||
semconv.RPCSystemKey: kv.StringValue("grpc"),
|
||||
semconv.RPCServiceKey: kv.StringValue("github.com.serviceName"),
|
||||
semconv.RPCMethodKey: kv.StringValue("bar"),
|
||||
semconv.NetPeerIPKey: kv.StringValue("fake"),
|
||||
semconv.NetPeerPortKey: kv.StringValue("connection"),
|
||||
}
|
||||
assert.Equal(t, expectedAttr, span.Attributes())
|
||||
|
||||
@ -323,10 +323,10 @@ func TestStreamClientInterceptor(t *testing.T) {
|
||||
msgID := i/2 + 1
|
||||
validate := func(eventName string, attrs map[kv.Key]kv.Value) {
|
||||
for k, v := range attrs {
|
||||
if k == standard.RPCMessageTypeKey && v.AsString() != eventName {
|
||||
if k == semconv.RPCMessageTypeKey && v.AsString() != eventName {
|
||||
t.Errorf("invalid event on index: %d expecting %s event, receive %s event", i, eventName, v.AsString())
|
||||
}
|
||||
if k == standard.RPCMessageIDKey && v != kv.IntValue(msgID) {
|
||||
if k == semconv.RPCMessageIDKey && v != kv.IntValue(msgID) {
|
||||
t.Errorf("invalid id for message event expected %d received %d", msgID, v.AsInt32())
|
||||
}
|
||||
}
|
||||
@ -376,36 +376,36 @@ func TestParseFullMethod(t *testing.T) {
|
||||
fullMethod: "/grpc.test.EchoService/Echo",
|
||||
name: "grpc.test.EchoService/Echo",
|
||||
attr: []kv.KeyValue{
|
||||
standard.RPCServiceKey.String("grpc.test.EchoService"),
|
||||
standard.RPCMethodKey.String("Echo"),
|
||||
semconv.RPCServiceKey.String("grpc.test.EchoService"),
|
||||
semconv.RPCMethodKey.String("Echo"),
|
||||
},
|
||||
}, {
|
||||
fullMethod: "/com.example.ExampleRmiService/exampleMethod",
|
||||
name: "com.example.ExampleRmiService/exampleMethod",
|
||||
attr: []kv.KeyValue{
|
||||
standard.RPCServiceKey.String("com.example.ExampleRmiService"),
|
||||
standard.RPCMethodKey.String("exampleMethod"),
|
||||
semconv.RPCServiceKey.String("com.example.ExampleRmiService"),
|
||||
semconv.RPCMethodKey.String("exampleMethod"),
|
||||
},
|
||||
}, {
|
||||
fullMethod: "/MyCalcService.Calculator/Add",
|
||||
name: "MyCalcService.Calculator/Add",
|
||||
attr: []kv.KeyValue{
|
||||
standard.RPCServiceKey.String("MyCalcService.Calculator"),
|
||||
standard.RPCMethodKey.String("Add"),
|
||||
semconv.RPCServiceKey.String("MyCalcService.Calculator"),
|
||||
semconv.RPCMethodKey.String("Add"),
|
||||
},
|
||||
}, {
|
||||
fullMethod: "/MyServiceReference.ICalculator/Add",
|
||||
name: "MyServiceReference.ICalculator/Add",
|
||||
attr: []kv.KeyValue{
|
||||
standard.RPCServiceKey.String("MyServiceReference.ICalculator"),
|
||||
standard.RPCMethodKey.String("Add"),
|
||||
semconv.RPCServiceKey.String("MyServiceReference.ICalculator"),
|
||||
semconv.RPCMethodKey.String("Add"),
|
||||
},
|
||||
}, {
|
||||
fullMethod: "/MyServiceWithNoPackage/theMethod",
|
||||
name: "MyServiceWithNoPackage/theMethod",
|
||||
attr: []kv.KeyValue{
|
||||
standard.RPCServiceKey.String("MyServiceWithNoPackage"),
|
||||
standard.RPCMethodKey.String("theMethod"),
|
||||
semconv.RPCServiceKey.String("MyServiceWithNoPackage"),
|
||||
semconv.RPCMethodKey.String("theMethod"),
|
||||
},
|
||||
}, {
|
||||
fullMethod: "/pkg.srv",
|
||||
@ -415,7 +415,7 @@ func TestParseFullMethod(t *testing.T) {
|
||||
fullMethod: "/pkg.srv/",
|
||||
name: "pkg.srv/",
|
||||
attr: []kv.KeyValue{
|
||||
standard.RPCServiceKey.String("pkg.srv"),
|
||||
semconv.RPCServiceKey.String("pkg.srv"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"go.opentelemetry.io/otel/api/standard"
|
||||
"go.opentelemetry.io/otel/semconv"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
|
||||
@ -152,7 +152,7 @@ func (ct *clientTracer) span(hook string) trace.Span {
|
||||
}
|
||||
|
||||
func (ct *clientTracer) getConn(host string) {
|
||||
ct.start("http.getconn", "http.getconn", standard.HTTPHostKey.String(host))
|
||||
ct.start("http.getconn", "http.getconn", semconv.HTTPHostKey.String(host))
|
||||
}
|
||||
|
||||
func (ct *clientTracer) gotConn(info httptrace.GotConnInfo) {
|
||||
@ -172,7 +172,7 @@ func (ct *clientTracer) gotFirstResponseByte() {
|
||||
}
|
||||
|
||||
func (ct *clientTracer) dnsStart(info httptrace.DNSStartInfo) {
|
||||
ct.start("http.dns", "http.dns", standard.HTTPHostKey.String(info.Host))
|
||||
ct.start("http.dns", "http.dns", semconv.HTTPHostKey.String(info.Host))
|
||||
}
|
||||
|
||||
func (ct *clientTracer) dnsDone(info httptrace.DNSDoneInfo) {
|
||||
|
@ -22,8 +22,8 @@ import (
|
||||
"go.opentelemetry.io/otel/api/global"
|
||||
"go.opentelemetry.io/otel/api/kv"
|
||||
"go.opentelemetry.io/otel/api/propagation"
|
||||
"go.opentelemetry.io/otel/api/standard"
|
||||
"go.opentelemetry.io/otel/api/trace"
|
||||
"go.opentelemetry.io/otel/semconv"
|
||||
)
|
||||
|
||||
// Option is a function that allows configuration of the httptrace Extract()
|
||||
@ -55,8 +55,8 @@ func Extract(ctx context.Context, req *http.Request, opts ...Option) ([]kv.KeyVa
|
||||
ctx = propagation.ExtractHTTP(ctx, c.propagators, req.Header)
|
||||
|
||||
attrs := append(
|
||||
standard.HTTPServerAttributesFromHTTPRequest("", "", req),
|
||||
standard.NetAttributesFromHTTPRequest("tcp", req)...,
|
||||
semconv.HTTPServerAttributesFromHTTPRequest("", "", req),
|
||||
semconv.NetAttributesFromHTTPRequest("tcp", req)...,
|
||||
)
|
||||
|
||||
var correlationCtxKVs []kv.KeyValue
|
||||
|
@ -26,9 +26,9 @@ import (
|
||||
"go.opentelemetry.io/otel/api/correlation"
|
||||
"go.opentelemetry.io/otel/api/kv"
|
||||
"go.opentelemetry.io/otel/api/propagation"
|
||||
"go.opentelemetry.io/otel/api/standard"
|
||||
"go.opentelemetry.io/otel/api/trace/testtrace"
|
||||
"go.opentelemetry.io/otel/instrumentation/httptrace"
|
||||
"go.opentelemetry.io/otel/semconv"
|
||||
)
|
||||
|
||||
func TestRoundtrip(t *testing.T) {
|
||||
@ -44,7 +44,7 @@ func TestRoundtrip(t *testing.T) {
|
||||
|
||||
actualAttrs := make(map[kv.Key]string)
|
||||
for _, attr := range attrs {
|
||||
if attr.Key == standard.NetPeerPortKey {
|
||||
if attr.Key == semconv.NetPeerPortKey {
|
||||
// Peer port will be non-deterministic
|
||||
continue
|
||||
}
|
||||
@ -79,17 +79,17 @@ func TestRoundtrip(t *testing.T) {
|
||||
address := ts.Listener.Addr()
|
||||
hp := strings.Split(address.String(), ":")
|
||||
expectedAttrs = map[kv.Key]string{
|
||||
standard.HTTPFlavorKey: "1.1",
|
||||
standard.HTTPHostKey: address.String(),
|
||||
standard.HTTPMethodKey: "GET",
|
||||
standard.HTTPSchemeKey: "http",
|
||||
standard.HTTPTargetKey: "/",
|
||||
standard.HTTPUserAgentKey: "Go-http-client/1.1",
|
||||
standard.HTTPRequestContentLengthKey: "3",
|
||||
standard.NetHostIPKey: hp[0],
|
||||
standard.NetHostPortKey: hp[1],
|
||||
standard.NetPeerIPKey: "127.0.0.1",
|
||||
standard.NetTransportKey: "IP.TCP",
|
||||
semconv.HTTPFlavorKey: "1.1",
|
||||
semconv.HTTPHostKey: address.String(),
|
||||
semconv.HTTPMethodKey: "GET",
|
||||
semconv.HTTPSchemeKey: "http",
|
||||
semconv.HTTPTargetKey: "/",
|
||||
semconv.HTTPUserAgentKey: "Go-http-client/1.1",
|
||||
semconv.HTTPRequestContentLengthKey: "3",
|
||||
semconv.NetHostIPKey: hp[0],
|
||||
semconv.NetHostPortKey: hp[1],
|
||||
semconv.NetPeerIPKey: "127.0.0.1",
|
||||
semconv.NetTransportKey: "IP.TCP",
|
||||
}
|
||||
|
||||
client := ts.Client()
|
||||
|
@ -25,8 +25,8 @@ import (
|
||||
"go.opentelemetry.io/otel/api/kv"
|
||||
"go.opentelemetry.io/otel/api/metric"
|
||||
"go.opentelemetry.io/otel/api/propagation"
|
||||
"go.opentelemetry.io/otel/api/standard"
|
||||
"go.opentelemetry.io/otel/api/trace"
|
||||
"go.opentelemetry.io/otel/semconv"
|
||||
)
|
||||
|
||||
var _ http.Handler = &Handler{}
|
||||
@ -127,9 +127,9 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
opts := append([]trace.StartOption{
|
||||
trace.WithAttributes(standard.NetAttributesFromHTTPRequest("tcp", r)...),
|
||||
trace.WithAttributes(standard.EndUserAttributesFromHTTPRequest(r)...),
|
||||
trace.WithAttributes(standard.HTTPServerAttributesFromHTTPRequest(h.operation, "", r)...),
|
||||
trace.WithAttributes(semconv.NetAttributesFromHTTPRequest("tcp", r)...),
|
||||
trace.WithAttributes(semconv.EndUserAttributesFromHTTPRequest(r)...),
|
||||
trace.WithAttributes(semconv.HTTPServerAttributesFromHTTPRequest(h.operation, "", r)...),
|
||||
}, h.spanStartOptions...) // start with the configured options
|
||||
|
||||
ctx := propagation.ExtractHTTP(r.Context(), h.propagators, r.Header)
|
||||
@ -176,7 +176,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// Add request metrics
|
||||
|
||||
labels := standard.HTTPServerMetricAttributesFromHTTPRequest(h.operation, r)
|
||||
labels := semconv.HTTPServerMetricAttributesFromHTTPRequest(h.operation, r)
|
||||
|
||||
h.counters[RequestContentLength].Add(ctx, bw.read, labels...)
|
||||
h.counters[ResponseContentLength].Add(ctx, rww.written, labels...)
|
||||
@ -201,8 +201,8 @@ func setAfterServeAttributes(span trace.Span, read, wrote int64, statusCode int,
|
||||
kv = append(kv, WroteBytesKey.Int64(wrote))
|
||||
}
|
||||
if statusCode > 0 {
|
||||
kv = append(kv, standard.HTTPAttributesFromHTTPStatusCode(statusCode)...)
|
||||
span.SetStatus(standard.SpanStatusFromHTTPStatusCode(statusCode))
|
||||
kv = append(kv, semconv.HTTPAttributesFromHTTPStatusCode(statusCode)...)
|
||||
span.SetStatus(semconv.SpanStatusFromHTTPStatusCode(statusCode))
|
||||
}
|
||||
if werr != nil && werr != io.EOF {
|
||||
kv = append(kv, WriteErrorKey.String(werr.Error()))
|
||||
@ -215,7 +215,7 @@ func setAfterServeAttributes(span trace.Span, read, wrote int64, statusCode int,
|
||||
func WithRouteTag(route string, h http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
span := trace.SpanFromContext(r.Context())
|
||||
span.SetAttributes(standard.HTTPRouteKey.String(route))
|
||||
span.SetAttributes(semconv.HTTPRouteKey.String(route))
|
||||
h.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
|
@ -26,10 +26,10 @@ import (
|
||||
"google.golang.org/grpc/codes"
|
||||
|
||||
"go.opentelemetry.io/otel/api/kv"
|
||||
"go.opentelemetry.io/otel/api/standard"
|
||||
"go.opentelemetry.io/otel/api/trace"
|
||||
mockmeter "go.opentelemetry.io/otel/internal/metric"
|
||||
mocktrace "go.opentelemetry.io/otel/internal/trace"
|
||||
"go.opentelemetry.io/otel/semconv"
|
||||
)
|
||||
|
||||
func assertMetricLabels(t *testing.T, expectedLabels []kv.KeyValue, measurementBatches []mockmeter.Batch) {
|
||||
@ -68,11 +68,11 @@ func TestHandlerBasics(t *testing.T) {
|
||||
}
|
||||
|
||||
labelsToVerify := []kv.KeyValue{
|
||||
standard.HTTPServerNameKey.String(operation),
|
||||
standard.HTTPSchemeHTTP,
|
||||
standard.HTTPHostKey.String(r.Host),
|
||||
standard.HTTPFlavorKey.String(fmt.Sprintf("1.%d", r.ProtoMinor)),
|
||||
standard.HTTPRequestContentLengthKey.Int64(3),
|
||||
semconv.HTTPServerNameKey.String(operation),
|
||||
semconv.HTTPSchemeHTTP,
|
||||
semconv.HTTPHostKey.String(r.Host),
|
||||
semconv.HTTPFlavorKey.String(fmt.Sprintf("1.%d", r.ProtoMinor)),
|
||||
semconv.HTTPRequestContentLengthKey.Int64(3),
|
||||
}
|
||||
|
||||
assertMetricLabels(t, labelsToVerify, meterimpl.MeasurementBatches)
|
||||
|
@ -21,8 +21,8 @@ import (
|
||||
|
||||
"go.opentelemetry.io/otel/api/global"
|
||||
"go.opentelemetry.io/otel/api/propagation"
|
||||
"go.opentelemetry.io/otel/api/standard"
|
||||
"go.opentelemetry.io/otel/api/trace"
|
||||
"go.opentelemetry.io/otel/semconv"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
)
|
||||
@ -89,7 +89,7 @@ func (t *Transport) RoundTrip(r *http.Request) (*http.Response, error) {
|
||||
ctx, span := t.tracer.Start(r.Context(), t.spanNameFormatter("", r), opts...)
|
||||
|
||||
r = r.WithContext(ctx)
|
||||
span.SetAttributes(standard.HTTPClientAttributesFromHTTPRequest(r)...)
|
||||
span.SetAttributes(semconv.HTTPClientAttributesFromHTTPRequest(r)...)
|
||||
propagation.InjectHTTP(ctx, t.propagators, r.Header)
|
||||
|
||||
res, err := t.rt.RoundTrip(r)
|
||||
@ -99,8 +99,8 @@ func (t *Transport) RoundTrip(r *http.Request) (*http.Response, error) {
|
||||
return res, err
|
||||
}
|
||||
|
||||
span.SetAttributes(standard.HTTPAttributesFromHTTPStatusCode(res.StatusCode)...)
|
||||
span.SetStatus(standard.SpanStatusFromHTTPStatusCode(res.StatusCode))
|
||||
span.SetAttributes(semconv.HTTPAttributesFromHTTPStatusCode(res.StatusCode)...)
|
||||
span.SetStatus(semconv.SpanStatusFromHTTPStatusCode(res.StatusCode))
|
||||
res.Body = &wrappedBody{ctx: ctx, span: span, body: res.Body}
|
||||
|
||||
return res, err
|
||||
|
@ -12,11 +12,9 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Package standard contains keys and values that have been standardized for
|
||||
// use in OpenTelemetry. These standardizations are specified in the
|
||||
// OpenTelemetry specification:
|
||||
// Package semconv implements OpenTelemetry semantic conventions.
|
||||
//
|
||||
// - https://github.com/open-telemetry/opentelemetry-specification/tree/v0.6.0/specification/resource/semantic_conventions
|
||||
// - https://github.com/open-telemetry/opentelemetry-specification/tree/v0.6.0/specification/trace/semantic_conventions
|
||||
// - https://github.com/open-telemetry/opentelemetry-specification/tree/v0.6.0/specification/metrics/semantic_conventions
|
||||
package standard
|
||||
// OpenTelemetry semantic conventions are agreed standardized naming
|
||||
// patterns for OpenTelemetry things. This package aims to be the
|
||||
// centralized place to interact with these conventions.
|
||||
package semconv // import "go.opentelemetry.io/otel/semconv"
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package standard
|
||||
package semconv
|
||||
|
||||
import (
|
||||
"fmt"
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package standard
|
||||
package semconv
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
@ -12,11 +12,11 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package standard // import "go.opentelemetry.io/otel/api/standard"
|
||||
package semconv
|
||||
|
||||
import "go.opentelemetry.io/otel/api/kv"
|
||||
|
||||
// Standard service resource attribute keys.
|
||||
// Semantic conventions for service resource attribute keys.
|
||||
const (
|
||||
// Name of the service.
|
||||
ServiceNameKey = kv.Key("service.name")
|
||||
@ -35,7 +35,7 @@ const (
|
||||
ServiceVersionKey = kv.Key("service.version")
|
||||
)
|
||||
|
||||
// Standard telemetry SDK resource attribute keys.
|
||||
// Semantic conventions for telemetry SDK resource attribute keys.
|
||||
const (
|
||||
// The name of the telemetry SDK.
|
||||
//
|
||||
@ -56,12 +56,12 @@ const (
|
||||
TelemetrySDKVersionKey = kv.Key("telemetry.sdk.version")
|
||||
)
|
||||
|
||||
// Standard telemetry SDK resource attributes.
|
||||
// Semantic conventions for telemetry SDK resource attributes.
|
||||
var (
|
||||
TelemetrySDKLanguageGo = TelemetrySDKLanguageKey.String("go")
|
||||
)
|
||||
|
||||
// Standard container resource attribute keys.
|
||||
// Semantic conventions for container resource attribute keys.
|
||||
const (
|
||||
// A uniquely identifying name for the Container.
|
||||
ContainerNameKey = kv.Key("container.name")
|
||||
@ -77,7 +77,7 @@ const (
|
||||
ContainerImageTagKey = kv.Key("container.image.tag")
|
||||
)
|
||||
|
||||
// Standard Function-as-a-Service resource attribute keys.
|
||||
// Semantic conventions for Function-as-a-Service resource attribute keys.
|
||||
const (
|
||||
// A uniquely identifying name for the FaaS.
|
||||
FaaSNameKey = kv.Key("faas.name")
|
||||
@ -92,7 +92,7 @@ const (
|
||||
FaaSInstanceKey = kv.Key("faas.instance")
|
||||
)
|
||||
|
||||
// Standard operating system process resource attribute keys.
|
||||
// Semantic conventions for operating system process resource attribute keys.
|
||||
const (
|
||||
// Process identifier (PID).
|
||||
ProcessPIDKey = kv.Key("process.pid")
|
||||
@ -120,7 +120,7 @@ const (
|
||||
ProcessOwnerKey = kv.Key("process.owner")
|
||||
)
|
||||
|
||||
// Standard Kubernetes resource attribute keys.
|
||||
// Semantic conventions for Kubernetes resource attribute keys.
|
||||
const (
|
||||
// A uniquely identifying name for the Kubernetes cluster. Kubernetes
|
||||
// does not have cluster names as an internal concept so this may be
|
||||
@ -138,7 +138,7 @@ const (
|
||||
K8SDeploymentNameKey = kv.Key("k8s.deployment.name")
|
||||
)
|
||||
|
||||
// Standard host resource attribute keys.
|
||||
// Semantic conventions for host resource attribute keys.
|
||||
const (
|
||||
// A uniquely identifying name for the host.
|
||||
HostNameKey = kv.Key("host.name")
|
||||
@ -162,7 +162,7 @@ const (
|
||||
HostImageVersionKey = kv.Key("host.image.version")
|
||||
)
|
||||
|
||||
// Standard cloud environment resource attribute keys.
|
||||
// Semantic conventions for cloud environment resource attribute keys.
|
||||
const (
|
||||
// Name of the cloud provider.
|
||||
CloudProviderKey = kv.Key("cloud.provider")
|
@ -12,11 +12,12 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package standard
|
||||
package semconv
|
||||
|
||||
import "go.opentelemetry.io/otel/api/kv"
|
||||
|
||||
// Standard attribute keys used for network related operations.
|
||||
// Semantic conventions for attribute keys used for network related
|
||||
// operations.
|
||||
const (
|
||||
// Transport protocol used.
|
||||
NetTransportKey = kv.Key("net.transport")
|
||||
@ -57,7 +58,8 @@ const (
|
||||
PeerServiceKey = kv.Key("peer.service")
|
||||
)
|
||||
|
||||
// Standard attribute keys used to identify an authorized enduser.
|
||||
// Semantic conventions for attribute keys used to identify an authorized
|
||||
// user.
|
||||
const (
|
||||
// Username or the client identifier extracted from the access token or
|
||||
// authorization header in the inbound request from outside the system.
|
||||
@ -70,7 +72,7 @@ const (
|
||||
EnduserScopeKey = kv.Key("enduser.scope")
|
||||
)
|
||||
|
||||
// Standard attribute keys for HTTP.
|
||||
// Semantic conventions for attribute keys for HTTP.
|
||||
const (
|
||||
// HTTP request method.
|
||||
HTTPMethodKey = kv.Key("http.method")
|
||||
@ -138,7 +140,7 @@ var (
|
||||
HTTPFlavorQUIC = HTTPFlavorKey.String("QUIC")
|
||||
)
|
||||
|
||||
// Standard attribute keys for database connections.
|
||||
// Semantic conventions for attribute keys for database connections.
|
||||
const (
|
||||
// Identifier for the database system (DBMS) being used.
|
||||
DBSystemKey = kv.Key("db.system")
|
||||
@ -173,7 +175,7 @@ var (
|
||||
DBSystemRedis = DBSystemKey.String("redis") // Redis
|
||||
)
|
||||
|
||||
// Standard attribute keys for database calls.
|
||||
// Semantic conventions for attribute keys for database calls.
|
||||
const (
|
||||
// Database instance name.
|
||||
DBNameKey = kv.Key("db.name")
|
||||
@ -200,7 +202,7 @@ const (
|
||||
DBMongoDBCollectionKey = kv.Key("db.mongodb.collection")
|
||||
)
|
||||
|
||||
// Standard attribute keys for RPC.
|
||||
// Semantic conventions for attribute keys for RPC.
|
||||
const (
|
||||
// A string identifying the remoting system.
|
||||
RPCSystemKey = kv.Key("rpc.system")
|
||||
@ -237,7 +239,7 @@ var (
|
||||
RPCMessageTypeReceived = RPCMessageTypeKey.String("RECEIVED")
|
||||
)
|
||||
|
||||
// Standard attribute keys for messaging systems.
|
||||
// Semantic conventions for attribute keys for messaging systems.
|
||||
const (
|
||||
// A unique identifier describing the messaging system. For example,
|
||||
// kafka, rabbitmq or activemq.
|
||||
@ -291,7 +293,7 @@ var (
|
||||
MessagingOperationProcess = MessagingOperationKey.String("process")
|
||||
)
|
||||
|
||||
// Standard attribute keys for FaaS systems.
|
||||
// Semantic conventions for attribute keys for FaaS systems.
|
||||
const (
|
||||
|
||||
// Type of the trigger on which the function is executed.
|
Loading…
x
Reference in New Issue
Block a user