Skip to content

Commit

Permalink
Bump go.opentelemetry.io/otel to v0.5.0. (#18)
Browse files Browse the repository at this point in the history
* Bump go.opentelemetry.io/otel to v0.4.3.

* Fix outdated package references in example.

* Bump go.opentelemetry.io/otel to v0.5.0.

I've only made sufficient changes to get this compiling, there may be
further changes to support new features.
  • Loading branch information
charleskorn committed May 14, 2020
1 parent aa81cfc commit 966afdc
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 28 deletions.
4 changes: 2 additions & 2 deletions example/trace/http/client/client.go
Expand Up @@ -29,7 +29,7 @@ import (
texporter "github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace"
"go.opentelemetry.io/otel/api/correlation"
"go.opentelemetry.io/otel/api/global"
"go.opentelemetry.io/otel/api/key"
"go.opentelemetry.io/otel/api/kv"
"go.opentelemetry.io/otel/api/trace"
"go.opentelemetry.io/otel/plugin/httptrace"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
Expand Down Expand Up @@ -63,7 +63,7 @@ func main() {

client := http.DefaultClient
ctx := correlation.NewContext(context.Background(),
key.String("username", "donuts"),
kv.String("username", "donuts"),
)

var body []byte
Expand Down
2 changes: 1 addition & 1 deletion example/trace/http/go.mod
Expand Up @@ -6,6 +6,6 @@ replace github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trac

require (
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v0.1.0
go.opentelemetry.io/otel v0.3.0
go.opentelemetry.io/otel v0.5.0
google.golang.org/grpc v1.27.1
)
4 changes: 2 additions & 2 deletions example/trace/http/go.sum
Expand Up @@ -91,8 +91,8 @@ go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3 h1:8sGtKOrtQqkN1bp2AtX+misvLIlOmsEsNd+9NIcPEm8=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opentelemetry.io/otel v0.3.0 h1:x3i+dwRyD5ADPdGGF6uf8KnqxC5b3vpyvo7b2YLocEc=
go.opentelemetry.io/otel v0.3.0/go.mod h1:OgNpQOjrlt33Ew6Ds0mGjmcTQg/rhUctsbkRdk/g1fw=
go.opentelemetry.io/otel v0.5.0 h1:tdIR1veg/z+VRJaw/6SIxz+QX3l+m+BDleYLTs+GC1g=
go.opentelemetry.io/otel v0.5.0/go.mod h1:jzBIgIzK43Iu1BpDAXwqOd6UPsSAk+ewVZ5ofSXw4Ek=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
Expand Down
10 changes: 5 additions & 5 deletions exporter/trace/cloudtrace.go
Expand Up @@ -25,7 +25,7 @@ import (
"golang.org/x/oauth2/google"
"google.golang.org/api/option"

"go.opentelemetry.io/otel/api/key"
"go.opentelemetry.io/otel/api/kv"
export "go.opentelemetry.io/otel/sdk/export/trace"
)

Expand Down Expand Up @@ -224,13 +224,13 @@ func (e *Exporter) sdWithDefaultTraceAttributes(sd *export.SpanData) *export.Spa
for k, v := range e.traceExporter.o.DefaultTraceAttributes {
switch val := v.(type) {
case bool:
newSD.Attributes = append(newSD.Attributes, key.New(k).Bool(val))
newSD.Attributes = append(newSD.Attributes, kv.Bool(k, val))
case int64:
newSD.Attributes = append(newSD.Attributes, key.New(k).Int64(val))
newSD.Attributes = append(newSD.Attributes, kv.Int64(k, val))
case float64:
newSD.Attributes = append(newSD.Attributes, key.New(k).Float64(val))
newSD.Attributes = append(newSD.Attributes, kv.Float64(k, val))
case string:
newSD.Attributes = append(newSD.Attributes, key.New(k).String(val))
newSD.Attributes = append(newSD.Attributes, kv.String(k, val))
}
}
newSD.Attributes = append(newSD.Attributes, sd.Attributes...)
Expand Down
2 changes: 1 addition & 1 deletion exporter/trace/go.mod
Expand Up @@ -6,7 +6,7 @@ require (
cloud.google.com/go v0.53.0
github.com/golang/protobuf v1.3.4
github.com/stretchr/testify v1.4.0
go.opentelemetry.io/otel v0.3.0
go.opentelemetry.io/otel v0.5.0
golang.org/x/net v0.0.0-20200301022130-244492dfa37a // indirect
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 // indirect
Expand Down
4 changes: 2 additions & 2 deletions exporter/trace/go.sum
Expand Up @@ -95,8 +95,8 @@ go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3 h1:8sGtKOrtQqkN1bp2AtX+misvLIlOmsEsNd+9NIcPEm8=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opentelemetry.io/otel v0.3.0 h1:x3i+dwRyD5ADPdGGF6uf8KnqxC5b3vpyvo7b2YLocEc=
go.opentelemetry.io/otel v0.3.0/go.mod h1:OgNpQOjrlt33Ew6Ds0mGjmcTQg/rhUctsbkRdk/g1fw=
go.opentelemetry.io/otel v0.5.0 h1:tdIR1veg/z+VRJaw/6SIxz+QX3l+m+BDleYLTs+GC1g=
go.opentelemetry.io/otel v0.5.0/go.mod h1:jzBIgIzK43Iu1BpDAXwqOd6UPsSAk+ewVZ5ofSXw4Ek=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
Expand Down
31 changes: 16 additions & 15 deletions exporter/trace/trace_proto.go
Expand Up @@ -27,7 +27,8 @@ import (
statuspb "google.golang.org/genproto/googleapis/rpc/status"
"google.golang.org/grpc/codes"

"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/api/kv"
"go.opentelemetry.io/otel/api/kv/value"
opentelemetry "go.opentelemetry.io/otel/sdk"
export "go.opentelemetry.io/otel/sdk/export/trace"
)
Expand Down Expand Up @@ -64,8 +65,8 @@ func protoFromSpanData(s *export.SpanData, projectID string) *tracepb.Span {
return nil
}

traceIDString := s.SpanContext.TraceIDString()
spanIDString := s.SpanContext.SpanIDString()
traceIDString := s.SpanContext.TraceID.String()
spanIDString := s.SpanContext.SpanID.String()

name := s.Name
switch s.SpanKind {
Expand Down Expand Up @@ -154,7 +155,7 @@ func timestampProto(t time.Time) *timestamppb.Timestamp {

// copyAttributes copies a map of attributes to a proto map field.
// It creates the map if it is nil.
func copyAttributes(out **tracepb.Span_Attributes, in []core.KeyValue) {
func copyAttributes(out **tracepb.Span_Attributes, in []kv.KeyValue) {
if len(in) == 0 {
return
}
Expand Down Expand Up @@ -192,27 +193,27 @@ func copyAttributes(out **tracepb.Span_Attributes, in []core.KeyValue) {
(*out).DroppedAttributesCount = dropped
}

func attributeValue(kv core.KeyValue) *tracepb.AttributeValue {
value := kv.Value
switch value.Type() {
case core.BOOL:
func attributeValue(kv kv.KeyValue) *tracepb.AttributeValue {
v := kv.Value
switch v.Type() {
case value.BOOL:
return &tracepb.AttributeValue{
Value: &tracepb.AttributeValue_BoolValue{BoolValue: value.AsBool()},
Value: &tracepb.AttributeValue_BoolValue{BoolValue: v.AsBool()},
}
case core.INT64:
case value.INT64:
return &tracepb.AttributeValue{
Value: &tracepb.AttributeValue_IntValue{IntValue: value.AsInt64()},
Value: &tracepb.AttributeValue_IntValue{IntValue: v.AsInt64()},
}
case core.FLOAT64:
case value.FLOAT64:
// TODO: set double value if Google Cloud Trace support it in the future.
return &tracepb.AttributeValue{
Value: &tracepb.AttributeValue_StringValue{
StringValue: trunc(strconv.FormatFloat(value.AsFloat64(), 'f', -1, 64),
StringValue: trunc(strconv.FormatFloat(v.AsFloat64(), 'f', -1, 64),
maxAttributeStringValue)},
}
case core.STRING:
case value.STRING:
return &tracepb.AttributeValue{
Value: &tracepb.AttributeValue_StringValue{StringValue: trunc(value.AsString(), maxAttributeStringValue)},
Value: &tracepb.AttributeValue_StringValue{StringValue: trunc(v.AsString(), maxAttributeStringValue)},
}
}
return nil
Expand Down

0 comments on commit 966afdc

Please sign in to comment.