Skip to content

Commit

Permalink
Merge branch 'main' into prerelease-otel-v1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias authored Apr 27, 2022
2 parents 263fc96 + 93b5a37 commit f051340
Show file tree
Hide file tree
Showing 19 changed files with 562 additions and 491 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (
"go.opentelemetry.io/contrib/instrumentation/github.com/astaxie/beego/otelbeego/internal"
"go.opentelemetry.io/contrib/propagators/b3"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric/nonrecording"
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/sdk/metric/metrictest"
"go.opentelemetry.io/otel/sdk/trace"
"go.opentelemetry.io/otel/sdk/trace/tracetest"
semconv "go.opentelemetry.io/otel/semconv/v1.10.0"
Expand Down Expand Up @@ -189,7 +189,7 @@ func TestStatic(t *testing.T) {
defer replaceBeego()
sr := tracetest.NewSpanRecorder()
tracerProvider := trace.NewTracerProvider(trace.WithSpanProcessor(sr))
meterProvider := nonrecording.NewNoopMeterProvider()
meterProvider, metricExporter := metrictest.NewTestMeterProvider()
file, err := ioutil.TempFile("", "static-*.html")
require.NoError(t, err)
defer os.Remove(file.Name())
Expand Down Expand Up @@ -220,8 +220,7 @@ func TestStatic(t *testing.T) {
spans := sr.Ended()
require.Len(t, spans, 1)
assertSpan(t, spans[0], tc)
// TODO: Replace with in memory exporter https://github.com/open-telemetry/opentelemetry-go/issues/2722
// assertMetrics(t, meterProvider.MeasurementBatches, tc)
assertMetrics(t, metricExporter.GetRecords(), tc)
}

func TestRender(t *testing.T) {
Expand Down Expand Up @@ -288,7 +287,7 @@ func TestRender(t *testing.T) {
func runTest(t *testing.T, tc *testCase, url string) {
sr := tracetest.NewSpanRecorder()
tracerProvider := trace.NewTracerProvider(trace.WithSpanProcessor(sr))
meterProvider := nonrecording.NewNoopMeterProvider()
meterProvider, metricExporter := metrictest.NewTestMeterProvider()
addTestRoutes(t)
defer replaceBeego()

Expand Down Expand Up @@ -327,8 +326,7 @@ func runTest(t *testing.T, tc *testCase, url string) {
} else {
require.Len(t, spans, 0)
}
// TODO: Replace with in memory exporter https://github.com/open-telemetry/opentelemetry-go/issues/2722
// assertMetrics(t, meterProvider.MeasurementBatches, tc)
assertMetrics(t, metricExporter.GetRecords(), tc)
}

func defaultAttributes() []attribute.KeyValue {
Expand All @@ -347,14 +345,13 @@ func assertSpan(t *testing.T, span trace.ReadOnlySpan, tc *testCase) {
}
}

// TODO: Replace with in memory exporter https://github.com/open-telemetry/opentelemetry-go/issues/2722
// func assertMetrics(t *testing.T, batches []metrictest.Batch, tc *testCase) {
// for _, batch := range batches {
// for _, att := range tc.expectedAttributes {
// require.Contains(t, batch.Labels, att)
// }
// }
// }
func assertMetrics(t *testing.T, records []metrictest.ExportRecord, tc *testCase) {
for _, record := range records {
for _, att := range tc.expectedAttributes {
require.Contains(t, record.Attributes, att)
}
}
}

// ------------------------------------------ Test Cases

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ require (
go.opentelemetry.io/contrib/instrumentation/github.com/astaxie/beego/otelbeego v0.31.0
go.opentelemetry.io/contrib/propagators/b3 v1.6.0
go.opentelemetry.io/otel v1.6.4-0.20220425151224-b8e4241a32f2
go.opentelemetry.io/otel/metric v0.29.0
go.opentelemetry.io/otel/sdk v1.6.3
go.opentelemetry.io/otel/sdk/metric v0.29.1-0.20220425151224-b8e4241a32f2
)

replace (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ github.com/astaxie/beego v1.12.3 h1:SAQkdD2ePye+v8Gn1r4X6IKZM1wd28EyUOVQ3PDSOOQ=
github.com/astaxie/beego v1.12.3/go.mod h1:p3qIm0Ryx7zeBHLljmd7omloyca1s4yu1a8kM1FkpIA=
github.com/beego/goyaml2 v0.0.0-20130207012346-5545475820dd/go.mod h1:1b+Y/CofkYwXMUU0OhQqGvsY2Bvgr4j6jfT699wyZKQ=
github.com/beego/x2j v0.0.0-20131220205130-a0352aadc542/go.mod h1:kSeGC/p1AbBiEp5kat81+DSQrZenVBZXklMLaELspWU=
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
Expand Down Expand Up @@ -154,6 +156,8 @@ go.opentelemetry.io/otel/metric v0.29.0 h1:7unM/I13Dbc1VHw8lTPQ7zfNIgkhcb8BZhujX
go.opentelemetry.io/otel/metric v0.29.0/go.mod h1:HahKFp1OC1RNTsuO/HNMBHHJR+dmHZ7wLARRgGDwjLQ=
go.opentelemetry.io/otel/sdk v1.6.3 h1:prSHYdwCQOX5DrsEzxowH3nLhoAzEBdZhvrR79scfLs=
go.opentelemetry.io/otel/sdk v1.6.3/go.mod h1:A4iWF7HTXa+GWL/AaqESz28VuSBIcZ+0CV+IzJ5NMiQ=
go.opentelemetry.io/otel/sdk/metric v0.29.1-0.20220425151224-b8e4241a32f2 h1:w97SUMLzaACqAmuyNR6S+1N2o90Y3Kcvz6S8xp8uysM=
go.opentelemetry.io/otel/sdk/metric v0.29.1-0.20220425151224-b8e4241a32f2/go.mod h1:IFkFNKI8Gq8zBdqOKdODCL9+LInBZLXaGpqSIKphNuU=
go.opentelemetry.io/otel/trace v1.6.3 h1:IqN4L+5b0mPNjdXIiZ90Ni4Bl5BRkDQywePLWemd9bc=
go.opentelemetry.io/otel/trace v1.6.3/go.mod h1:GNJQusJlUgZl9/TQBPKU/Y/ty+0iVB5fjhKeJGZPGFs=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql/otelgocql v0.31.0
go.opentelemetry.io/otel v1.6.4-0.20220425151224-b8e4241a32f2
go.opentelemetry.io/otel/sdk v1.6.3
go.opentelemetry.io/otel/sdk/metric v0.29.1-0.20220425151224-b8e4241a32f2
go.opentelemetry.io/otel/trace v1.6.3
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932 h1:mXoPYz/Ul5HYEDvkta6I8/rnYM5gSdSV2tJ6XbZuEtY=
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=
Expand Down Expand Up @@ -38,6 +40,8 @@ go.opentelemetry.io/otel/metric v0.29.0 h1:7unM/I13Dbc1VHw8lTPQ7zfNIgkhcb8BZhujX
go.opentelemetry.io/otel/metric v0.29.0/go.mod h1:HahKFp1OC1RNTsuO/HNMBHHJR+dmHZ7wLARRgGDwjLQ=
go.opentelemetry.io/otel/sdk v1.6.3 h1:prSHYdwCQOX5DrsEzxowH3nLhoAzEBdZhvrR79scfLs=
go.opentelemetry.io/otel/sdk v1.6.3/go.mod h1:A4iWF7HTXa+GWL/AaqESz28VuSBIcZ+0CV+IzJ5NMiQ=
go.opentelemetry.io/otel/sdk/metric v0.29.1-0.20220425151224-b8e4241a32f2 h1:w97SUMLzaACqAmuyNR6S+1N2o90Y3Kcvz6S8xp8uysM=
go.opentelemetry.io/otel/sdk/metric v0.29.1-0.20220425151224-b8e4241a32f2/go.mod h1:IFkFNKI8Gq8zBdqOKdODCL9+LInBZLXaGpqSIKphNuU=
go.opentelemetry.io/otel/trace v1.6.3 h1:IqN4L+5b0mPNjdXIiZ90Ni4Bl5BRkDQywePLWemd9bc=
go.opentelemetry.io/otel/trace v1.6.3/go.mod h1:GNJQusJlUgZl9/TQBPKU/Y/ty+0iVB5fjhKeJGZPGFs=
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7 h1:iGu644GcxtEcrInvDsQRCwJjtCIOlT2V7IRt6ah2Whw=
Expand Down
Loading

0 comments on commit f051340

Please sign in to comment.