diff --git a/instrumentation/github.com/astaxie/beego/otelbeego/test/beego_test.go b/instrumentation/github.com/astaxie/beego/otelbeego/test/beego_test.go index 4ca50cb7ca1..f6453ac5656 100644 --- a/instrumentation/github.com/astaxie/beego/otelbeego/test/beego_test.go +++ b/instrumentation/github.com/astaxie/beego/otelbeego/test/beego_test.go @@ -30,7 +30,6 @@ import ( "go.opentelemetry.io/contrib/propagators/b3" "go.opentelemetry.io/otel/attribute" "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.12.0" @@ -41,6 +40,11 @@ import ( "github.com/stretchr/testify/require" ) +// TODO(#2762): Add metric integration tests for the instrumentation. These +// tests depend on +// https://github.com/open-telemetry/opentelemetry-go/issues/3031 being +// resolved. + // ------------------------------------------ Test Controller const defaultReply = "hello world" @@ -189,7 +193,6 @@ func TestStatic(t *testing.T) { defer replaceBeego() sr := tracetest.NewSpanRecorder() tracerProvider := trace.NewTracerProvider(trace.WithSpanProcessor(sr)) - meterProvider, metricExporter := metrictest.NewTestMeterProvider() file, err := os.CreateTemp("", "static-*.html") require.NoError(t, err) defer file.Close() @@ -202,7 +205,6 @@ func TestStatic(t *testing.T) { mw := otelbeego.NewOTelBeegoMiddleWare(middleWareName, otelbeego.WithTracerProvider(tracerProvider), - otelbeego.WithMeterProvider(meterProvider), ) rr := httptest.NewRecorder() @@ -221,7 +223,6 @@ func TestStatic(t *testing.T) { spans := sr.Ended() require.Len(t, spans, 1) assertSpan(t, spans[0], tc) - assertMetrics(t, metricExporter.GetRecords(), tc) } func TestRender(t *testing.T) { @@ -287,7 +288,6 @@ func TestRender(t *testing.T) { func runTest(t *testing.T, tc *testCase, url string) { sr := tracetest.NewSpanRecorder() tracerProvider := trace.NewTracerProvider(trace.WithSpanProcessor(sr)) - meterProvider, metricExporter := metrictest.NewTestMeterProvider() addTestRoutes(t) defer replaceBeego() @@ -306,7 +306,6 @@ func runTest(t *testing.T, tc *testCase, url string) { append( tc.options, otelbeego.WithTracerProvider(tracerProvider), - otelbeego.WithMeterProvider(meterProvider), )..., ) @@ -326,7 +325,6 @@ func runTest(t *testing.T, tc *testCase, url string) { } else { require.Len(t, spans, 0) } - assertMetrics(t, metricExporter.GetRecords(), tc) } func defaultAttributes() []attribute.KeyValue { @@ -345,14 +343,6 @@ func assertSpan(t *testing.T, span trace.ReadOnlySpan, tc *testCase) { } } -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 const middleWareName = "test-router" diff --git a/instrumentation/github.com/astaxie/beego/otelbeego/test/go.mod b/instrumentation/github.com/astaxie/beego/otelbeego/test/go.mod index 65fed9dc9e6..a3dfddd3b42 100644 --- a/instrumentation/github.com/astaxie/beego/otelbeego/test/go.mod +++ b/instrumentation/github.com/astaxie/beego/otelbeego/test/go.mod @@ -9,7 +9,6 @@ require ( go.opentelemetry.io/contrib/propagators/b3 v1.10.0 go.opentelemetry.io/otel v1.10.0 go.opentelemetry.io/otel/sdk v1.10.0 - go.opentelemetry.io/otel/sdk/metric v0.31.0 ) require ( @@ -29,7 +28,7 @@ require ( github.com/prometheus/procfs v0.1.3 // indirect github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.35.0 // indirect - go.opentelemetry.io/otel/metric v0.31.0 // indirect + go.opentelemetry.io/otel/metric v0.31.1-0.20220916150821-e1a1f07e44e9 // indirect go.opentelemetry.io/otel/trace v1.10.0 // indirect golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect golang.org/x/net v0.0.0-20200707034311-ab3426394381 // indirect diff --git a/instrumentation/github.com/astaxie/beego/otelbeego/test/go.sum b/instrumentation/github.com/astaxie/beego/otelbeego/test/go.sum index 95dffe81c95..fc601fc664c 100644 --- a/instrumentation/github.com/astaxie/beego/otelbeego/test/go.sum +++ b/instrumentation/github.com/astaxie/beego/otelbeego/test/go.sum @@ -11,7 +11,6 @@ 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/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= @@ -151,12 +150,10 @@ github.com/wendal/errors v0.0.0-20130201093226-f66c77a7882b/go.mod h1:Q12BUT7DqI github.com/yuin/gopher-lua v0.0.0-20171031051903-609c9cd26973/go.mod h1:aEV29XrmTYFr3CiRxZeGHpkvbwq+prZduBqMaascyCU= go.opentelemetry.io/otel v1.10.0 h1:Y7DTJMR6zs1xkS/upamJYk0SxxN4C9AqRd77jmZnyY4= go.opentelemetry.io/otel v1.10.0/go.mod h1:NbvWjCthWHKBEUMpf0/v8ZRZlni86PpGFEMA9pnQSnQ= -go.opentelemetry.io/otel/metric v0.31.0 h1:6SiklT+gfWAwWUR0meEMxQBtihpiEs4c+vL9spDTqUs= -go.opentelemetry.io/otel/metric v0.31.0/go.mod h1:ohmwj9KTSIeBnDBm/ZwH2PSZxZzoOaG2xZeekTRzL5A= +go.opentelemetry.io/otel/metric v0.31.1-0.20220916150821-e1a1f07e44e9 h1:Ks2fKHtMzWUGr/faEwyAHfeU0J5uHzDpysl6x2hmRRw= +go.opentelemetry.io/otel/metric v0.31.1-0.20220916150821-e1a1f07e44e9/go.mod h1:PVDNTt297p8ehm949jsIzd+Z2bIZJYQQG/uuHTeWFHY= go.opentelemetry.io/otel/sdk v1.10.0 h1:jZ6K7sVn04kk/3DNUdJ4mqRlGDiXAVuIG+MMENpTNdY= go.opentelemetry.io/otel/sdk v1.10.0/go.mod h1:vO06iKzD5baltJz1zarxMCNHFpUlUiOy4s65ECtn6kE= -go.opentelemetry.io/otel/sdk/metric v0.31.0 h1:2sZx4R43ZMhJdteKAlKoHvRgrMp53V1aRxvEf5lCq8Q= -go.opentelemetry.io/otel/sdk/metric v0.31.0/go.mod h1:fl0SmNnX9mN9xgU6OLYLMBMrNAsaZQi7qBwprwO3abk= go.opentelemetry.io/otel/trace v1.10.0 h1:npQMbR8o7mum8uF95yFbOEJffhs1sbCOfDh8zAJiH5E= go.opentelemetry.io/otel/trace v1.10.0/go.mod h1:Sij3YYczqAdz+EhmGhE6TpTxUO5/F/AzrK+kxfGqySM= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= diff --git a/instrumentation/github.com/gocql/gocql/otelgocql/example/client.go b/instrumentation/github.com/gocql/gocql/otelgocql/example/client.go index 683d3c84ecc..7d3be5708e9 100644 --- a/instrumentation/github.com/gocql/gocql/otelgocql/example/client.go +++ b/instrumentation/github.com/gocql/gocql/otelgocql/example/client.go @@ -12,6 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build go1.18 +// +build go1.18 + +package main + // This example will create the keyspace // "gocql_integration_example" and a single table // with the following schema: @@ -24,8 +29,6 @@ // The example will insert fictional books into the database and // then truncate the table. -package main - import ( "context" "fmt" @@ -37,16 +40,16 @@ import ( "time" "github.com/gocql/gocql" + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/promhttp" "go.opentelemetry.io/otel" - "go.opentelemetry.io/otel/exporters/prometheus" - zipkintrace "go.opentelemetry.io/otel/exporters/zipkin" + otelprom "go.opentelemetry.io/otel/exporters/prometheus" + "go.opentelemetry.io/otel/exporters/zipkin" "go.opentelemetry.io/otel/metric/global" - "go.opentelemetry.io/otel/sdk/metric/aggregator/histogram" - controller "go.opentelemetry.io/otel/sdk/metric/controller/basic" - "go.opentelemetry.io/otel/sdk/metric/export/aggregation" - processor "go.opentelemetry.io/otel/sdk/metric/processor/basic" - "go.opentelemetry.io/otel/sdk/metric/selector/simple" + "go.opentelemetry.io/otel/sdk/metric" + "go.opentelemetry.io/otel/sdk/metric/aggregation" + "go.opentelemetry.io/otel/sdk/metric/view" "go.opentelemetry.io/otel/sdk/trace" "go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql/otelgocql" @@ -124,51 +127,103 @@ func main() { wg.Wait() } -func initMetrics() error { - // Start prometheus - cont := controller.New( - processor.NewFactory( - simple.NewWithHistogramDistribution( - histogram.WithExplicitBoundaries([]float64{0.001, 0.01, 0.1, 0.5, 1, 2, 5, 10}), - ), - aggregation.CumulativeTemporalitySelector(), - processor.WithMemory(true), - ), +func views() ([]view.View, error) { + var vs []view.View + // TODO: Remove renames when the Prometheus exporter natively supports + // metric instrument name sanitation + // (https://github.com/open-telemetry/opentelemetry-go/issues/3183). + v, err := view.New( + view.MatchInstrumentName("db.cassandra.queries"), + view.WithRename("db_cassandra_queries"), + ) + if err != nil { + return nil, err + } + vs = append(vs, v) + + v, err = view.New( + view.MatchInstrumentName("db.cassandra.rows"), + view.WithRename("db_cassandra_rows"), + view.WithSetAggregation(aggregation.ExplicitBucketHistogram{ + Boundaries: []float64{0.001, 0.01, 0.1, 0.5, 1, 2, 5, 10}, + }), + ) + if err != nil { + return nil, err + } + vs = append(vs, v) + + v, err = view.New( + view.MatchInstrumentName("db.cassandra.batch.queries"), + view.WithRename("db_cassandra_batch_queries"), + ) + if err != nil { + return nil, err + } + vs = append(vs, v) + + v, err = view.New( + view.MatchInstrumentName("db.cassandra.connections"), + view.WithRename("db_cassandra_connections"), ) - metricExporter, err := prometheus.New(prometheus.Config{}, cont) + if err != nil { + return nil, err + } + vs = append(vs, v) + + v, err = view.New( + view.MatchInstrumentName("db.cassandra.latency"), + view.WithRename("db_cassandra_latency"), + view.WithSetAggregation(aggregation.ExplicitBucketHistogram{ + Boundaries: []float64{0.001, 0.01, 0.1, 0.5, 1, 2, 5, 10}, + }), + ) + if err != nil { + return nil, err + } + vs = append(vs, v) + + return vs, nil +} + +func initMetrics() error { + vs, err := views() if err != nil { return err } - global.SetMeterProvider(metricExporter.MeterProvider()) - server := http.Server{Addr: ":2222"} - http.HandleFunc("/", metricExporter.ServeHTTP) + exporter := otelprom.New() + provider := metric.NewMeterProvider(metric.WithReader(exporter, vs...)) + global.SetMeterProvider(provider) + + err = prometheus.Register(exporter.Collector) + if err != nil { + return err + } + http.Handle("/", promhttp.Handler()) + log.Print("Serving metrics at :2222/") go func() { - defer wg.Done() - wg.Add(1) - log.Print(server.ListenAndServe()) + err := http.ListenAndServe(":2222", nil) + if err != nil { + log.Print(err) + } }() - // ctrl+c will stop the server gracefully - shutdown := make(chan os.Signal, 1) - signal.Notify(shutdown, os.Interrupt) + ctx, _ := signal.NotifyContext(context.Background(), os.Interrupt) + wg.Add(1) go func() { - <-shutdown - if err := server.Shutdown(context.Background()); err != nil { - log.Printf("problem shutting down server, %v", err) - } else { - log.Print("gracefully shutting down server") - } - err := cont.Stop(context.Background()) + defer wg.Done() + <-ctx.Done() + err := provider.Shutdown(context.Background()) if err != nil { - log.Printf("error stopping metric controller: %s", err) + log.Printf("error stopping MeterProvider: %s", err) } }() return nil } func initTracer() (*trace.TracerProvider, error) { - exporter, err := zipkintrace.New("http://localhost:9411/api/v2/spans") + exporter, err := zipkin.New("http://localhost:9411/api/v2/spans") if err != nil { return nil, err } diff --git a/instrumentation/github.com/gocql/gocql/otelgocql/example/doc.go b/instrumentation/github.com/gocql/gocql/otelgocql/example/doc.go new file mode 100644 index 00000000000..558f5bee2df --- /dev/null +++ b/instrumentation/github.com/gocql/gocql/otelgocql/example/doc.go @@ -0,0 +1,16 @@ +// 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 main provides an example use of the otelgocql instrumentation. +package main diff --git a/instrumentation/github.com/gocql/gocql/otelgocql/example/go.mod b/instrumentation/github.com/gocql/gocql/otelgocql/example/go.mod index 21c50579d9a..d886191c21d 100644 --- a/instrumentation/github.com/gocql/gocql/otelgocql/example/go.mod +++ b/instrumentation/github.com/gocql/gocql/otelgocql/example/go.mod @@ -1,18 +1,19 @@ module go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql/otelgocql/example -go 1.17 +go 1.18 replace go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql/otelgocql => ../ require ( github.com/gocql/gocql v0.0.0-20200624222514-34081eda590e + github.com/prometheus/client_golang v1.13.0 go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql/otelgocql v0.35.0 go.opentelemetry.io/otel v1.10.0 - go.opentelemetry.io/otel/exporters/prometheus v0.31.0 + go.opentelemetry.io/otel/exporters/prometheus v0.31.1-0.20220916150821-e1a1f07e44e9 go.opentelemetry.io/otel/exporters/zipkin v1.10.0 - go.opentelemetry.io/otel/metric v0.31.0 + go.opentelemetry.io/otel/metric v0.31.1-0.20220916150821-e1a1f07e44e9 go.opentelemetry.io/otel/sdk v1.10.0 - go.opentelemetry.io/otel/sdk/metric v0.31.0 + go.opentelemetry.io/otel/sdk/metric v0.31.1-0.20220916150821-e1a1f07e44e9 ) require ( @@ -25,12 +26,11 @@ require ( github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/openzipkin/zipkin-go v0.4.0 // indirect - github.com/prometheus/client_golang v1.12.2 // indirect github.com/prometheus/client_model v0.2.0 // indirect - github.com/prometheus/common v0.32.1 // indirect - github.com/prometheus/procfs v0.7.3 // indirect + github.com/prometheus/common v0.37.0 // indirect + github.com/prometheus/procfs v0.8.0 // indirect go.opentelemetry.io/otel/trace v1.10.0 // indirect - golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 // indirect - google.golang.org/protobuf v1.27.1 // indirect + golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect + google.golang.org/protobuf v1.28.1 // indirect gopkg.in/inf.v0 v0.9.1 // indirect ) diff --git a/instrumentation/github.com/gocql/gocql/otelgocql/example/go.sum b/instrumentation/github.com/gocql/gocql/otelgocql/example/go.sum index d37fc353ef5..24c538c0e04 100644 --- a/instrumentation/github.com/gocql/gocql/otelgocql/example/go.sum +++ b/instrumentation/github.com/gocql/gocql/otelgocql/example/go.sum @@ -41,7 +41,6 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= 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= @@ -86,9 +85,11 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2 github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -224,8 +225,9 @@ github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXP github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.12.2 h1:51L9cDoUHVrXx4zWYlcLQIZ+d+VXHgqnYKkIuq4g/34= -github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= +github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= +github.com/prometheus/client_golang v1.13.0 h1:b71QUfeo5M8gq2+evJdTPfZhYMAU0uKPkyPJ7TPsloU= +github.com/prometheus/client_golang v1.13.0/go.mod h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -234,14 +236,16 @@ github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6T github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= -github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8pXE= +github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= +github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= github.com/rabbitmq/amqp091-go v1.1.0/go.mod h1:ogQDLSOACsLPsIq0NpbtiifNZi2YOz0VTJ0kHRghqbM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= @@ -276,16 +280,16 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opentelemetry.io/otel v1.10.0 h1:Y7DTJMR6zs1xkS/upamJYk0SxxN4C9AqRd77jmZnyY4= go.opentelemetry.io/otel v1.10.0/go.mod h1:NbvWjCthWHKBEUMpf0/v8ZRZlni86PpGFEMA9pnQSnQ= -go.opentelemetry.io/otel/exporters/prometheus v0.31.0 h1:jwtnOGBM8dIty5AVZ+9ZCzZexCea3aVKmUfZAQcHqxs= -go.opentelemetry.io/otel/exporters/prometheus v0.31.0/go.mod h1:QarXIB8L79IwIPoNgG3A6zNvBgVmcppeFogV1d8612s= +go.opentelemetry.io/otel/exporters/prometheus v0.31.1-0.20220916150821-e1a1f07e44e9 h1:C7ytt0EiYwlBJJa+4JK1toKxK6IBeVYPoiuG/pidbVo= +go.opentelemetry.io/otel/exporters/prometheus v0.31.1-0.20220916150821-e1a1f07e44e9/go.mod h1:7EOQy/1LHVlTrJ1ZFV4tgKcvkMyApy9QiE/unrv6TE8= go.opentelemetry.io/otel/exporters/zipkin v1.10.0 h1:HcPAFsFpEBKF+G5NIOA+gBsxifd3Ej+wb+KsdBLa15E= go.opentelemetry.io/otel/exporters/zipkin v1.10.0/go.mod h1:HdfvgwcOoCB0+zzrTHycW6btjK0zNpkz2oTGO815SCI= -go.opentelemetry.io/otel/metric v0.31.0 h1:6SiklT+gfWAwWUR0meEMxQBtihpiEs4c+vL9spDTqUs= -go.opentelemetry.io/otel/metric v0.31.0/go.mod h1:ohmwj9KTSIeBnDBm/ZwH2PSZxZzoOaG2xZeekTRzL5A= +go.opentelemetry.io/otel/metric v0.31.1-0.20220916150821-e1a1f07e44e9 h1:Ks2fKHtMzWUGr/faEwyAHfeU0J5uHzDpysl6x2hmRRw= +go.opentelemetry.io/otel/metric v0.31.1-0.20220916150821-e1a1f07e44e9/go.mod h1:PVDNTt297p8ehm949jsIzd+Z2bIZJYQQG/uuHTeWFHY= go.opentelemetry.io/otel/sdk v1.10.0 h1:jZ6K7sVn04kk/3DNUdJ4mqRlGDiXAVuIG+MMENpTNdY= go.opentelemetry.io/otel/sdk v1.10.0/go.mod h1:vO06iKzD5baltJz1zarxMCNHFpUlUiOy4s65ECtn6kE= -go.opentelemetry.io/otel/sdk/metric v0.31.0 h1:2sZx4R43ZMhJdteKAlKoHvRgrMp53V1aRxvEf5lCq8Q= -go.opentelemetry.io/otel/sdk/metric v0.31.0/go.mod h1:fl0SmNnX9mN9xgU6OLYLMBMrNAsaZQi7qBwprwO3abk= +go.opentelemetry.io/otel/sdk/metric v0.31.1-0.20220916150821-e1a1f07e44e9 h1:lRizsZtGep2WADmJbLf5vlJnWRb5u4RVd1XlqVH6Zwk= +go.opentelemetry.io/otel/sdk/metric v0.31.1-0.20220916150821-e1a1f07e44e9/go.mod h1:2HFTEYxjMuc9WeAVZJ8VELbXn0YqcH/qZl4RkVXRfj4= go.opentelemetry.io/otel/trace v1.10.0 h1:npQMbR8o7mum8uF95yFbOEJffhs1sbCOfDh8zAJiH5E= go.opentelemetry.io/otel/trace v1.10.0/go.mod h1:Sij3YYczqAdz+EhmGhE6TpTxUO5/F/AzrK+kxfGqySM= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= @@ -362,12 +366,15 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -421,10 +428,12 @@ golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 h1:OH54vjqzRWmbJ62fjuhxy7AxFFgoHN0/DPc/UrL8cAs= -golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -560,8 +569,9 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/instrumentation/github.com/gocql/gocql/otelgocql/go.mod b/instrumentation/github.com/gocql/gocql/otelgocql/go.mod index fe2435c6bd4..dd074297931 100644 --- a/instrumentation/github.com/gocql/gocql/otelgocql/go.mod +++ b/instrumentation/github.com/gocql/gocql/otelgocql/go.mod @@ -6,7 +6,7 @@ require ( github.com/gocql/gocql v0.0.0-20200624222514-34081eda590e github.com/stretchr/testify v1.8.0 go.opentelemetry.io/otel v1.10.0 - go.opentelemetry.io/otel/metric v0.31.0 + go.opentelemetry.io/otel/metric v0.31.1-0.20220916150821-e1a1f07e44e9 go.opentelemetry.io/otel/trace v1.10.0 ) diff --git a/instrumentation/github.com/gocql/gocql/otelgocql/go.sum b/instrumentation/github.com/gocql/gocql/otelgocql/go.sum index 9c469bf83c5..ab980f73670 100644 --- a/instrumentation/github.com/gocql/gocql/otelgocql/go.sum +++ b/instrumentation/github.com/gocql/gocql/otelgocql/go.sum @@ -33,8 +33,8 @@ github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PK github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= go.opentelemetry.io/otel v1.10.0 h1:Y7DTJMR6zs1xkS/upamJYk0SxxN4C9AqRd77jmZnyY4= go.opentelemetry.io/otel v1.10.0/go.mod h1:NbvWjCthWHKBEUMpf0/v8ZRZlni86PpGFEMA9pnQSnQ= -go.opentelemetry.io/otel/metric v0.31.0 h1:6SiklT+gfWAwWUR0meEMxQBtihpiEs4c+vL9spDTqUs= -go.opentelemetry.io/otel/metric v0.31.0/go.mod h1:ohmwj9KTSIeBnDBm/ZwH2PSZxZzoOaG2xZeekTRzL5A= +go.opentelemetry.io/otel/metric v0.31.1-0.20220916150821-e1a1f07e44e9 h1:Ks2fKHtMzWUGr/faEwyAHfeU0J5uHzDpysl6x2hmRRw= +go.opentelemetry.io/otel/metric v0.31.1-0.20220916150821-e1a1f07e44e9/go.mod h1:PVDNTt297p8ehm949jsIzd+Z2bIZJYQQG/uuHTeWFHY= go.opentelemetry.io/otel/trace v1.10.0 h1:npQMbR8o7mum8uF95yFbOEJffhs1sbCOfDh8zAJiH5E= go.opentelemetry.io/otel/trace v1.10.0/go.mod h1:Sij3YYczqAdz+EhmGhE6TpTxUO5/F/AzrK+kxfGqySM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= diff --git a/instrumentation/github.com/gocql/gocql/otelgocql/test/go.mod b/instrumentation/github.com/gocql/gocql/otelgocql/test/go.mod index 065b164fadd..a373d943be4 100644 --- a/instrumentation/github.com/gocql/gocql/otelgocql/test/go.mod +++ b/instrumentation/github.com/gocql/gocql/otelgocql/test/go.mod @@ -9,7 +9,6 @@ require ( go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql/otelgocql v0.35.0 go.opentelemetry.io/otel v1.10.0 go.opentelemetry.io/otel/sdk v1.10.0 - go.opentelemetry.io/otel/sdk/metric v0.31.0 go.opentelemetry.io/otel/trace v1.10.0 ) @@ -20,7 +19,7 @@ require ( github.com/golang/snappy v0.0.3 // indirect github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - go.opentelemetry.io/otel/metric v0.31.0 // indirect + go.opentelemetry.io/otel/metric v0.31.1-0.20220916150821-e1a1f07e44e9 // indirect golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/instrumentation/github.com/gocql/gocql/otelgocql/test/go.sum b/instrumentation/github.com/gocql/gocql/otelgocql/test/go.sum index 34b794d44c0..6c401b7079e 100644 --- a/instrumentation/github.com/gocql/gocql/otelgocql/test/go.sum +++ b/instrumentation/github.com/gocql/gocql/otelgocql/test/go.sum @@ -1,4 +1,3 @@ -github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= 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= @@ -33,12 +32,10 @@ github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PK github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= go.opentelemetry.io/otel v1.10.0 h1:Y7DTJMR6zs1xkS/upamJYk0SxxN4C9AqRd77jmZnyY4= go.opentelemetry.io/otel v1.10.0/go.mod h1:NbvWjCthWHKBEUMpf0/v8ZRZlni86PpGFEMA9pnQSnQ= -go.opentelemetry.io/otel/metric v0.31.0 h1:6SiklT+gfWAwWUR0meEMxQBtihpiEs4c+vL9spDTqUs= -go.opentelemetry.io/otel/metric v0.31.0/go.mod h1:ohmwj9KTSIeBnDBm/ZwH2PSZxZzoOaG2xZeekTRzL5A= +go.opentelemetry.io/otel/metric v0.31.1-0.20220916150821-e1a1f07e44e9 h1:Ks2fKHtMzWUGr/faEwyAHfeU0J5uHzDpysl6x2hmRRw= +go.opentelemetry.io/otel/metric v0.31.1-0.20220916150821-e1a1f07e44e9/go.mod h1:PVDNTt297p8ehm949jsIzd+Z2bIZJYQQG/uuHTeWFHY= go.opentelemetry.io/otel/sdk v1.10.0 h1:jZ6K7sVn04kk/3DNUdJ4mqRlGDiXAVuIG+MMENpTNdY= go.opentelemetry.io/otel/sdk v1.10.0/go.mod h1:vO06iKzD5baltJz1zarxMCNHFpUlUiOy4s65ECtn6kE= -go.opentelemetry.io/otel/sdk/metric v0.31.0 h1:2sZx4R43ZMhJdteKAlKoHvRgrMp53V1aRxvEf5lCq8Q= -go.opentelemetry.io/otel/sdk/metric v0.31.0/go.mod h1:fl0SmNnX9mN9xgU6OLYLMBMrNAsaZQi7qBwprwO3abk= go.opentelemetry.io/otel/trace v1.10.0 h1:npQMbR8o7mum8uF95yFbOEJffhs1sbCOfDh8zAJiH5E= go.opentelemetry.io/otel/trace v1.10.0/go.mod h1:Sij3YYczqAdz+EhmGhE6TpTxUO5/F/AzrK+kxfGqySM= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7 h1:iGu644GcxtEcrInvDsQRCwJjtCIOlT2V7IRt6ah2Whw= diff --git a/instrumentation/github.com/gocql/gocql/otelgocql/test/gocql_test.go b/instrumentation/github.com/gocql/gocql/otelgocql/test/gocql_test.go index 1af8fae5699..49aad0e4003 100644 --- a/instrumentation/github.com/gocql/gocql/otelgocql/test/gocql_test.go +++ b/instrumentation/github.com/gocql/gocql/otelgocql/test/gocql_test.go @@ -30,15 +30,17 @@ import ( "go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql/otelgocql/internal" "go.opentelemetry.io/contrib/internal/util" "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/sdk/metric/export/aggregation" - "go.opentelemetry.io/otel/sdk/metric/metrictest" - "go.opentelemetry.io/otel/sdk/metric/number" sdktrace "go.opentelemetry.io/otel/sdk/trace" "go.opentelemetry.io/otel/sdk/trace/tracetest" semconv "go.opentelemetry.io/otel/semconv/v1.12.0" "go.opentelemetry.io/otel/trace" ) +// TODO(#2761): Add metric integration tests for the instrumentation. These +// tests depend on +// https://github.com/open-telemetry/opentelemetry-go/issues/3031 being +// resolved. + const ( keyspace string = "gotest" tableName string = "test_table" @@ -52,20 +54,11 @@ func (m *mockConnectObserver) ObserveConnect(observedConnect gocql.ObservedConne m.callCount++ } -type testRecord struct { - name string - meterName string - attributes []attribute.KeyValue - number number.Number - numberKind number.Kind -} - func TestQuery(t *testing.T) { defer afterEach(t) cluster := getCluster() sr := tracetest.NewSpanRecorder() tracerProvider := sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(sr)) - meterProvider, metricExporter := metrictest.NewTestMeterProvider() ctx, parentSpan := tracerProvider.Tracer(internal.InstrumentationName).Start(context.Background(), "gocql-test") @@ -73,7 +66,6 @@ func TestQuery(t *testing.T) { ctx, cluster, otelgocql.WithTracerProvider(tracerProvider), - otelgocql.WithMeterProvider(meterProvider), otelgocql.WithConnectInstrumentation(false), ) require.NoError(t, err) @@ -109,72 +101,6 @@ func TestQuery(t *testing.T) { } assertConnectionLevelAttributes(t, span) } - - // Check metrics - require.NoError(t, metricExporter.Collect(context.Background())) - actual := obtainTestRecords(metricExporter.GetRecords()) - require.Len(t, actual, 3) - expected := []testRecord{ - { - name: "db.cassandra.queries", - meterName: internal.InstrumentationName, - attributes: []attribute.KeyValue{ - internal.CassDBSystem(), - internal.CassPeerIP("127.0.0.1"), - internal.CassPeerPort(9042), - internal.CassVersion("3"), - internal.CassHostID("test-id"), - internal.CassHostState("UP"), - internal.CassKeyspace(keyspace), - internal.CassStatement(insertStmt), - }, - number: 1, - }, - { - name: "db.cassandra.rows", - meterName: internal.InstrumentationName, - attributes: []attribute.KeyValue{ - internal.CassDBSystem(), - internal.CassPeerIP("127.0.0.1"), - internal.CassPeerPort(9042), - internal.CassVersion("3"), - internal.CassHostID("test-id"), - internal.CassHostState("UP"), - internal.CassKeyspace(keyspace), - }, - number: 0, - }, - { - name: "db.cassandra.latency", - meterName: internal.InstrumentationName, - attributes: []attribute.KeyValue{ - internal.CassDBSystem(), - internal.CassPeerIP("127.0.0.1"), - internal.CassPeerPort(9042), - internal.CassVersion("3"), - internal.CassHostID("test-id"), - internal.CassHostState("UP"), - internal.CassKeyspace(keyspace), - }, - }, - } - - for _, record := range actual { - switch record.name { - case "db.cassandra.queries": - recordEqual(t, expected[0], record) - assert.Equal(t, expected[0].number, record.number) - case "db.cassandra.rows": - recordEqual(t, expected[1], record) - assert.Equal(t, expected[1].number, record.number) - case "db.cassandra.latency": - recordEqual(t, expected[2], record) - // The latency will vary, so just check that it exists - assert.True(t, !record.number.IsZero(record.numberKind)) - default: - t.Fatalf("wrong metric %s", record.name) - } - } } func TestBatch(t *testing.T) { @@ -182,7 +108,6 @@ func TestBatch(t *testing.T) { cluster := getCluster() sr := tracetest.NewSpanRecorder() tracerProvider := sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(sr)) - meterProvider, metricExporter := metrictest.NewTestMeterProvider() ctx, parentSpan := tracerProvider.Tracer(internal.InstrumentationName).Start(context.Background(), "gocql-test") @@ -190,7 +115,6 @@ func TestBatch(t *testing.T) { ctx, cluster, otelgocql.WithTracerProvider(tracerProvider), - otelgocql.WithMeterProvider(meterProvider), otelgocql.WithConnectInstrumentation(false), ) require.NoError(t, err) @@ -220,53 +144,6 @@ func TestBatch(t *testing.T) { assert.Contains(t, span.Attributes(), semconv.DBOperationKey.String("db.cassandra.batch.query")) assertConnectionLevelAttributes(t, span) } - - // Check metrics - require.NoError(t, metricExporter.Collect(context.Background())) - actual := obtainTestRecords(metricExporter.GetRecords()) - require.Len(t, actual, 2) - expected := []testRecord{ - { - name: "db.cassandra.batch.queries", - meterName: internal.InstrumentationName, - attributes: []attribute.KeyValue{ - internal.CassDBSystem(), - internal.CassPeerIP("127.0.0.1"), - internal.CassPeerPort(9042), - internal.CassVersion("3"), - internal.CassHostID("test-id"), - internal.CassHostState("UP"), - internal.CassKeyspace(keyspace), - }, - number: 1, - }, - { - name: "db.cassandra.latency", - meterName: internal.InstrumentationName, - attributes: []attribute.KeyValue{ - internal.CassDBSystem(), - internal.CassPeerIP("127.0.0.1"), - internal.CassPeerPort(9042), - internal.CassVersion("3"), - internal.CassHostID("test-id"), - internal.CassHostState("UP"), - internal.CassKeyspace(keyspace), - }, - }, - } - - for _, record := range actual { - switch record.name { - case "db.cassandra.batch.queries": - recordEqual(t, expected[0], record) - assert.Equal(t, expected[0].number, record.number) - case "db.cassandra.latency": - recordEqual(t, expected[1], record) - assert.True(t, !record.number.IsZero(record.numberKind)) - default: - t.Fatalf("wrong metric %s", record.name) - } - } } func TestConnection(t *testing.T) { @@ -274,7 +151,6 @@ func TestConnection(t *testing.T) { cluster := getCluster() sr := tracetest.NewSpanRecorder() tracerProvider := sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(sr)) - meterProvider, metricExporter := metrictest.NewTestMeterProvider() connectObserver := &mockConnectObserver{0} ctx := context.Background() @@ -282,7 +158,6 @@ func TestConnection(t *testing.T) { ctx, cluster, otelgocql.WithTracerProvider(tracerProvider), - otelgocql.WithMeterProvider(meterProvider), otelgocql.WithConnectObserver(connectObserver), ) require.NoError(t, err) @@ -299,32 +174,6 @@ func TestConnection(t *testing.T) { assert.Contains(t, span.Attributes(), semconv.DBOperationKey.String("db.cassandra.connect")) assertConnectionLevelAttributes(t, span) } - - // Verify the metrics - actual := obtainTestRecords(metricExporter.GetRecords()) - expected := []testRecord{ - { - name: "db.cassandra.connections", - meterName: internal.InstrumentationName, - attributes: []attribute.KeyValue{ - internal.CassDBSystem(), - internal.CassPeerIP("127.0.0.1"), - internal.CassPeerPort(9042), - internal.CassVersion("3"), - internal.CassHostID("test-id"), - internal.CassHostState("UP"), - }, - }, - } - - for _, record := range actual { - switch record.name { - case "db.cassandra.connections": - recordEqual(t, expected[0], record) - default: - t.Fatalf("wrong metric %s", record.name) - } - } } func TestHostOrIP(t *testing.T) { @@ -369,54 +218,6 @@ func getCluster() *gocql.ClusterConfig { return cluster } -// obtainTestRecords creates a slice of testRecord with values -// obtained from measurements. -func obtainTestRecords(mers []metrictest.ExportRecord) []testRecord { - var records []testRecord - for _, mer := range mers { - var n number.Number - switch mer.AggregationKind { - case aggregation.SumKind, aggregation.HistogramKind: - n = mer.Sum - case aggregation.LastValueKind: - n = mer.LastValue - default: - panic(fmt.Sprintf("unsupported aggregation type: %v", mer.AggregationKind)) - } - records = append( - records, - testRecord{ - name: mer.InstrumentName, - meterName: mer.InstrumentationLibrary.InstrumentationName, - attributes: mer.Attributes, - number: n, - numberKind: mer.NumberKind, - }, - ) - } - - return records -} - -// recordEqual checks that the given metric name and instrumentation names are equal. -func recordEqual(t *testing.T, expected testRecord, actual testRecord) { - assert.Equal(t, expected.name, actual.name) - assert.Equal(t, expected.meterName, actual.meterName) - require.Len(t, actual.attributes, len(expected.attributes)) - actualSet := attribute.NewSet(actual.attributes...) - for _, attr := range expected.attributes { - actualValue, ok := actualSet.Value(attr.Key) - assert.True(t, ok) - assert.NotNil(t, actualValue) - // Can't test equality of host id - if attr.Key != internal.CassHostIDKey && attr.Key != internal.CassVersionKey { - assert.Equal(t, attr.Value, actualValue) - } else { - assert.NotEmpty(t, actualValue) - } - } -} - // beforeAll creates the testing keyspace and table if they do not already exist. func beforeAll() error { cluster := gocql.NewCluster("localhost")