Skip to content

Commit

Permalink
Rename api/standard package to semconv (open-telemetry#1016)
Browse files Browse the repository at this point in the history
* Rename api/standard package to semconv

* Update `api/standard` package dependencies to `semconv`

* Update Changelog

* Add PR number to Changelog
  • Loading branch information
MrAlias committed Aug 4, 2020
1 parent fc1ce6c commit 96a5f8f
Show file tree
Hide file tree
Showing 17 changed files with 158 additions and 154 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions example/http/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions example/http/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions example/otel-collector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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),
)
Expand Down
22 changes: 11 additions & 11 deletions instrumentation/grpctrace/interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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)...)
Expand All @@ -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),
}
}

Expand All @@ -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
}
Loading

0 comments on commit 96a5f8f

Please sign in to comment.