diff --git a/instrumentation/github.com/gocql/gocql/README.md b/instrumentation/github.com/gocql/gocql/README.md new file mode 100644 index 00000000000..1c9ca0b9843 --- /dev/null +++ b/instrumentation/github.com/gocql/gocql/README.md @@ -0,0 +1,45 @@ +## `go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql` + +This package provides tracing and metrics to the golang cassandra client `github.com/gocql/gocql` using the `ConnectObserver`, `QueryObserver` and `BatchObserver` interfaces. + +To enable tracing in your application: + +```go +package main + +import ( + "context" + + "github.com/gocql/gocql" + otelGocql "go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql" +) + +func main() { + // Create a cluster + host := "localhost" + cluster := gocql.NewCluster(host) + + // Create a session with tracing + session, err := otelGocql.NewSessionWithTracing( + context.Background(), + cluster, + // Include any options here + ) + + // Begin using the session + +} +``` + +You can customize instrumentation by passing any of the following options to `NewSessionWithTracing`: + +| Function | Description | +| -------- | ----------- | +| `WithQueryObserver(gocql.QueryObserver)` | Specify an additional QueryObserver to be called. | +| `WithBatchObserver(gocql.BatchObserver)` | Specify an additional BatchObserver to be called. | +| `WithConnectObserver(gocql.ConnectObserver)` | Specify an additional ConnectObserver to be called. | +| `WithTracer(trace.Tracer)` | The tracer to be used to create spans for the gocql session. If not specified, `global.Tracer("go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql")` will be used. | +| `WithQueryInstrumentation(bool)` | To enable/disable tracing and metrics for queries. | +| `WithBatchInstrumentation(bool)` | To enable/disable tracing and metrics for batch queries. | +| `WithConnectInstrumentation(bool)` | To enable/disable tracing and metrics for new connections. | + diff --git a/instrumentation/github.com/gocql/gocql/cass.go b/instrumentation/github.com/gocql/gocql/cass.go new file mode 100644 index 00000000000..d626a23480f --- /dev/null +++ b/instrumentation/github.com/gocql/gocql/cass.go @@ -0,0 +1,154 @@ +// 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 gocql + +import ( + "go.opentelemetry.io/otel/api/kv" + "go.opentelemetry.io/otel/api/standard" +) + +const ( + // cassVersionKey is the key for the attribute/label describing + // the cql version. + cassVersionKey = kv.Key("db.cassandra.version") + + // cassHostIDKey is the key for the attribute/label describing the id + // of the host being queried. + cassHostIDKey = kv.Key("db.cassandra.host.id") + + // cassHostStateKey is the key for the attribute/label describing + // the state of the casssandra server hosting the node being queried. + cassHostStateKey = kv.Key("db.cassandra.host.state") + + // cassBatchQueriesKey is the key for the attribute describing + // the number of queries contained within the batch statement. + cassBatchQueriesKey = kv.Key("db.cassandra.batch.queries") + + // cassErrMsgKey is the key for the attribute/label describing + // the error message from an error encountered when executing a query, batch, + // or connection attempt to the cassandra server. + cassErrMsgKey = kv.Key("db.cassandra.error.message") + + // cassRowsReturnedKey is the key for the span attribute describing the number of rows + // returned on a query to the database. + cassRowsReturnedKey = kv.Key("db.cassandra.rows.returned") + + // cassQueryAttemptsKey is the key for the span attribute describing the number of attempts + // made for the query in question. + cassQueryAttemptsKey = kv.Key("db.cassandra.attempts") + + // Static span names + cassBatchQueryName = "Batch Query" + cassConnectName = "New Connection" + + // instrumentationName is the name of the instrumentation package. + instrumentationName = "go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql" +) + +// ------------------------------------------ Connection-level Attributes + +// cassDBSystem returns the name of the DB system, +// cassandra, as a KeyValue pair (db.system). +func cassDBSystem() kv.KeyValue { + return standard.DBSystemCassandra +} + +// cassPeerName returns the hostname of the cassandra +// server as a standard KeyValue pair (net.peer.name). +func cassPeerName(name string) kv.KeyValue { + return standard.NetPeerNameKey.String(name) +} + +// cassPeerPort returns the port number of the cassandra +// server as a standard KeyValue pair (net.peer.port). +func cassPeerPort(port int) kv.KeyValue { + return standard.NetPeerPortKey.Int(port) +} + +// cassPeerIP returns the IP address of the cassandra +// server as a standard KeyValue pair (net.peer.ip). +func cassPeerIP(ip string) kv.KeyValue { + return standard.NetPeerIPKey.String(ip) +} + +// cassVersion returns the cql version as a KeyValue pair. +func cassVersion(version string) kv.KeyValue { + return cassVersionKey.String(version) +} + +// cassHostID returns the id of the cassandra host as a KeyValue pair. +func cassHostID(id string) kv.KeyValue { + return cassHostIDKey.String(id) +} + +// cassHostState returns the state of the cassandra host as a KeyValue pair. +func cassHostState(state string) kv.KeyValue { + return cassHostStateKey.String(state) +} + +// ------------------------------------------ Call-level attributes + +// cassStatement returns the statement made to the cassandra database as a +// standard KeyValue pair (db.statement). +func cassStatement(stmt string) kv.KeyValue { + return standard.DBStatementKey.String(stmt) +} + +// cassDBOperation returns the batch query operation +// as a standard KeyValue pair (db.operation). This is used in lieu of a +// db.statement, which is not feasible to include in a span for a batch query +// because there can be n different query statements in a batch query. +func cassBatchQueryOperation() kv.KeyValue { + cassBatchQueryOperation := "db.cassandra.batch.query" + return standard.DBOperationKey.String(cassBatchQueryOperation) +} + +// cassConnectOperation returns the connect operation +// as a standard KeyValue pair (db.operation). This is used in lieu of a +// db.statement since connection creation does not have a CQL statement. +func cassConnectOperation() kv.KeyValue { + cassConnectOperation := "db.cassandra.connect" + return standard.DBOperationKey.String(cassConnectOperation) +} + +// cassKeyspace returns the keyspace of the session as +// a standard KeyValue pair (db.cassandra.keyspace). +func cassKeyspace(keyspace string) kv.KeyValue { + return standard.DBCassandraKeyspaceKey.String(keyspace) +} + +// cassBatchQueries returns the number of queries in a batch query +// as a KeyValue pair. +func cassBatchQueries(num int) kv.KeyValue { + return cassBatchQueriesKey.Int(num) +} + +// cassErrMsg returns the KeyValue pair of an error message +// encountered when executing a query, batch query, or error. +func cassErrMsg(msg string) kv.KeyValue { + return cassErrMsgKey.String(msg) +} + +// cassRowsReturned returns the KeyValue pair of the number of rows +// returned from a query. +func cassRowsReturned(rows int) kv.KeyValue { + return cassRowsReturnedKey.Int(rows) +} + +// cassQueryAttempts returns the KeyValue pair of the number of attempts +// made for a query. +func cassQueryAttempts(num int) kv.KeyValue { + return cassQueryAttemptsKey.Int(num) +} diff --git a/instrumentation/github.com/gocql/gocql/config.go b/instrumentation/github.com/gocql/gocql/config.go new file mode 100644 index 00000000000..c761c9aefe2 --- /dev/null +++ b/instrumentation/github.com/gocql/gocql/config.go @@ -0,0 +1,129 @@ +// 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 gocql + +import ( + "github.com/gocql/gocql" + + "go.opentelemetry.io/otel/api/global" + "go.opentelemetry.io/otel/api/trace" +) + +// TracedSessionConfig provides configuration for sessions +// created with NewSessionWithTracing. +type TracedSessionConfig struct { + tracer trace.Tracer + instrumentQuery bool + instrumentBatch bool + instrumentConnect bool + queryObserver gocql.QueryObserver + batchObserver gocql.BatchObserver + connectObserver gocql.ConnectObserver +} + +// TracedSessionOption applies a configuration option to +// the given TracedSessionConfig. +type TracedSessionOption interface { + Apply(*TracedSessionConfig) +} + +// TracedSessionOptionFunc is a function type that applies +// a particular configuration to the traced session in question. +type TracedSessionOptionFunc func(*TracedSessionConfig) + +// Apply will apply the TracedSessionOptionFunc to c, the given +// TracedSessionConfig. +func (o TracedSessionOptionFunc) Apply(c *TracedSessionConfig) { + o(c) +} + +// ------------------------------------------ TracedSessionOptions + +// WithQueryObserver sets an additional QueryObserver to the session configuration. Use this if +// there is an existing QueryObserver that you would like called. It will be called after the +// OpenTelemetry implementation, if it is not nil. Defaults to nil. +func WithQueryObserver(observer gocql.QueryObserver) TracedSessionOption { + return TracedSessionOptionFunc(func(cfg *TracedSessionConfig) { + cfg.queryObserver = observer + }) +} + +// WithBatchObserver sets an additional BatchObserver to the session configuration. Use this if +// there is an existing BatchObserver that you would like called. It will be called after the +// OpenTelemetry implementation, if it is not nil. Defaults to nil. +func WithBatchObserver(observer gocql.BatchObserver) TracedSessionOption { + return TracedSessionOptionFunc(func(cfg *TracedSessionConfig) { + cfg.batchObserver = observer + }) +} + +// WithConnectObserver sets an additional ConnectObserver to the session configuration. Use this if +// there is an existing ConnectObserver that you would like called. It will be called after the +// OpenTelemetry implementation, if it is not nil. Defaults to nil. +func WithConnectObserver(observer gocql.ConnectObserver) TracedSessionOption { + return TracedSessionOptionFunc(func(cfg *TracedSessionConfig) { + cfg.connectObserver = observer + }) +} + +// WithTracer will set tracer to be the tracer used to create spans +// for query, batch query, and connection instrumentation. +// Defaults to global.Tracer("go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql"). +func WithTracer(tracer trace.Tracer) TracedSessionOption { + return TracedSessionOptionFunc(func(c *TracedSessionConfig) { + c.tracer = tracer + }) +} + +// WithQueryInstrumentation will enable and disable instrumentation of +// queries. Defaults to enabled. +func WithQueryInstrumentation(enabled bool) TracedSessionOption { + return TracedSessionOptionFunc(func(cfg *TracedSessionConfig) { + cfg.instrumentQuery = enabled + }) +} + +// WithBatchInstrumentation will enable and disable insturmentation of +// batch queries. Defaults to enabled. +func WithBatchInstrumentation(enabled bool) TracedSessionOption { + return TracedSessionOptionFunc(func(cfg *TracedSessionConfig) { + cfg.instrumentBatch = enabled + }) +} + +// WithConnectInstrumentation will enable and disable instrumentation of +// connection attempts. Defaults to enabled. +func WithConnectInstrumentation(enabled bool) TracedSessionOption { + return TracedSessionOptionFunc(func(cfg *TracedSessionConfig) { + cfg.instrumentConnect = enabled + }) +} + +// ------------------------------------------ Private Functions + +func configure(options ...TracedSessionOption) *TracedSessionConfig { + config := &TracedSessionConfig{ + tracer: global.Tracer(instrumentationName), + instrumentQuery: true, + instrumentBatch: true, + instrumentConnect: true, + } + + for _, apply := range options { + apply.Apply(config) + } + + return config +} diff --git a/instrumentation/github.com/gocql/gocql/doc.go b/instrumentation/github.com/gocql/gocql/doc.go new file mode 100644 index 00000000000..6bc0e28e1c7 --- /dev/null +++ b/instrumentation/github.com/gocql/gocql/doc.go @@ -0,0 +1,18 @@ +// 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 gocql provides functions to instrument the gocql/gocql package +// (https://github.com/gocql/gocql). +// +package gocql // import "go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql" diff --git a/instrumentation/github.com/gocql/gocql/example/README.md b/instrumentation/github.com/gocql/gocql/example/README.md new file mode 100644 index 00000000000..a2c7683f15f --- /dev/null +++ b/instrumentation/github.com/gocql/gocql/example/README.md @@ -0,0 +1,18 @@ +## Integration Example + +### To run the example: +1. `cd` into the example directory. +2. Run `docker-compose up`. +3. Wait for cassandra to listen for cql clients with the following message in the logs: + +``` +Server.java:159 - Starting listening for CQL clients on /0.0.0.0:9042 (unencrypted)... +``` + +4. Run the example using `go run .`. + +5. You can view the spans in the browser at `localhost:9411` and the metrics at `localhost:2222`. + +### When you're done: +1. `ctrl+c` to stop the example program. +2. `docker-compose down` to stop cassandra and zipkin. diff --git a/instrumentation/github.com/gocql/gocql/example/client.go b/instrumentation/github.com/gocql/gocql/example/client.go new file mode 100644 index 00000000000..4c89dff68f8 --- /dev/null +++ b/instrumentation/github.com/gocql/gocql/example/client.go @@ -0,0 +1,205 @@ +// 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. + +// This example will create the keyspace +// "gocql_integration_example" and a single table +// with the following schema: +// gocql_integration_example.book +// id UUID +// title text +// author_first_name text +// author_last_name text +// PRIMARY KEY(id) +// The example will insert fictional books into the database and +// then truncate the table. + +package main + +import ( + "context" + "fmt" + "log" + "net/http" + "os" + "os/signal" + "sync" + "time" + + "github.com/gocql/gocql" + + otelGocql "go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql" + "go.opentelemetry.io/otel/api/global" + "go.opentelemetry.io/otel/exporters/metric/prometheus" + zipkintrace "go.opentelemetry.io/otel/exporters/trace/zipkin" + sdktrace "go.opentelemetry.io/otel/sdk/trace" +) + +const keyspace = "gocql_integration_example" + +var wg sync.WaitGroup + +func main() { + initMetrics() + initTracer() + initDb() + + ctx, span := global.Tracer( + "go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql/example", + ).Start(context.Background(), "begin example") + + cluster := getCluster() + // Create a session to begin making queries + session, err := otelGocql.NewSessionWithTracing( + ctx, + cluster, + ) + if err != nil { + log.Fatalf("failed to create a session, %v", err) + } + defer session.Close() + + batch := session.NewBatch(gocql.LoggedBatch) + for i := 0; i < 500; i++ { + batch.Query( + "INSERT INTO book (id, title, author_first_name, author_last_name) VALUES (?, ?, ?, ?)", + gocql.TimeUUID(), + fmt.Sprintf("Example Book %d", i), + "firstName", + "lastName", + ) + } + if err := session.ExecuteBatch(batch.WithContext(ctx)); err != nil { + log.Printf("failed to batch insert, %v", err) + } + + res := session.Query( + "SELECT title, author_first_name, author_last_name from book WHERE author_last_name = ?", + "lastName", + ).WithContext(ctx).PageSize(100).Iter() + + var ( + title string + firstName string + lastName string + ) + + for res.Scan(&title, &firstName, &lastName) { + res.Scan(&title, &firstName, &lastName) + } + + res.Close() + + if err = session.Query("truncate table book").WithContext(ctx).Exec(); err != nil { + log.Printf("failed to delete data, %v", err) + } + + span.End() + + wg.Wait() +} + +func initMetrics() { + // Start prometheus + metricExporter, err := prometheus.NewExportPipeline(prometheus.Config{}) + if err != nil { + log.Fatalf("failed to install metric exporter, %v", err) + } + server := http.Server{Addr: ":2222"} + http.HandleFunc("/", metricExporter.ServeHTTP) + go func() { + defer wg.Done() + wg.Add(1) + log.Print(server.ListenAndServe()) + }() + + // ctrl+c will stop the server gracefully + shutdown := make(chan os.Signal, 1) + signal.Notify(shutdown, os.Interrupt) + 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") + } + }() + + otelGocql.InstrumentWithProvider(metricExporter.Provider()) +} + +func initTracer() { + traceExporter, err := zipkintrace.NewExporter( + "http://localhost:9411/api/v2/spans", + "zipkin-example", + ) + if err != nil { + log.Fatalf("failed to create span traceExporter, %v", err) + } + + provider, err := sdktrace.NewProvider( + sdktrace.WithBatcher( + traceExporter, + sdktrace.WithBatchTimeout(5), + sdktrace.WithMaxExportBatchSize(10), + ), + sdktrace.WithConfig(sdktrace.Config{DefaultSampler: sdktrace.AlwaysSample()}), + ) + if err != nil { + log.Fatalf("failed to create trace provider, %v", err) + } + + global.SetTraceProvider(provider) +} + +func initDb() { + cluster := gocql.NewCluster("127.0.0.1") + cluster.Keyspace = "system" + cluster.Consistency = gocql.LocalQuorum + cluster.Timeout = time.Second * 2 + session, err := cluster.CreateSession() + if err != nil { + log.Fatal(err) + } + stmt := fmt.Sprintf( + "create keyspace if not exists %s with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }", + keyspace, + ) + if err := session.Query(stmt).Exec(); err != nil { + log.Fatal(err) + } + + cluster.Keyspace = keyspace + session, err = cluster.CreateSession() + if err != nil { + log.Fatal(err) + } + + stmt = "create table if not exists book(id UUID, title text, author_first_name text, author_last_name text, PRIMARY KEY(id))" + if err = session.Query(stmt).Exec(); err != nil { + log.Fatal(err) + } + + if err := session.Query("create index if not exists on book(author_last_name)").Exec(); err != nil { + log.Fatal(err) + } +} + +func getCluster() *gocql.ClusterConfig { + cluster := gocql.NewCluster("127.0.0.1") + cluster.Keyspace = keyspace + cluster.Consistency = gocql.LocalQuorum + cluster.ProtoVersion = 3 + cluster.Timeout = 2 * time.Second + return cluster +} diff --git a/instrumentation/github.com/gocql/gocql/example/docker-compose.yml b/instrumentation/github.com/gocql/gocql/example/docker-compose.yml new file mode 100644 index 00000000000..e9eaeb86b91 --- /dev/null +++ b/instrumentation/github.com/gocql/gocql/example/docker-compose.yml @@ -0,0 +1,24 @@ +# 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. + +version: '3' +services: + cassandra: + image: cassandra:3 + ports: + - 9042:9042 + zipkin: + image: openzipkin/zipkin:2 + ports: + - 9411:9411 diff --git a/instrumentation/github.com/gocql/gocql/example/go.mod b/instrumentation/github.com/gocql/gocql/example/go.mod new file mode 100644 index 00000000000..4e9858fcd44 --- /dev/null +++ b/instrumentation/github.com/gocql/gocql/example/go.mod @@ -0,0 +1,16 @@ +module go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql/example + +go 1.14 + +require ( + github.com/DataDog/sketches-go v0.0.1 // indirect + github.com/gocql/gocql v0.0.0-20200624222514-34081eda590e + go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql v0.0.0 + go.opentelemetry.io/otel v0.9.0 + go.opentelemetry.io/otel/exporters/metric/prometheus v0.9.0 + go.opentelemetry.io/otel/exporters/trace/zipkin v0.9.0 + golang.org/x/sys v0.0.0-20200722175500-76b94024e4b6 // indirect + google.golang.org/protobuf v1.25.0 // indirect +) + +replace go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql => ../ diff --git a/instrumentation/github.com/gocql/gocql/example/go.sum b/instrumentation/github.com/gocql/gocql/example/go.sum new file mode 100644 index 00000000000..b072602d8f7 --- /dev/null +++ b/instrumentation/github.com/gocql/gocql/example/go.sum @@ -0,0 +1,227 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/DataDog/sketches-go v0.0.0-20190923095040-43f19ad77ff7 h1:qELHH0AWCvf98Yf+CNIJx9vOZOfHFDDzgDRYsnNk/vs= +github.com/DataDog/sketches-go v0.0.0-20190923095040-43f19ad77ff7/go.mod h1:Q5DbzQ+3AkgGwymQO7aZFNP7ns2lZKGtvRBzRXfdi60= +github.com/DataDog/sketches-go v0.0.1 h1:RtG+76WKgZuz6FIaGsjoPePmadDBkuD/KC6+ZWu78b8= +github.com/DataDog/sketches-go v0.0.1/go.mod h1:Q5DbzQ+3AkgGwymQO7aZFNP7ns2lZKGtvRBzRXfdi60= +github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= +github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/benbjohnson/clock v1.0.3 h1:vkLuvpK4fmtSCuo60+yC63p7y0BmQ8gm5ZXGuBCJyXg= +github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= +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= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +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= +github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= +github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= +github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= +github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +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-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-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gocql/gocql v0.0.0-20200624222514-34081eda590e h1:SroDcndcOU9BVAduPf/PXihXoR2ZYTQYLXbupbqxAyQ= +github.com/gocql/gocql v0.0.0-20200624222514-34081eda590e/go.mod h1:DL0ekTmBSTdlNF25Orwt/JMzqIq3EJ4MVa/J/uK64OY= +github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/snappy v0.0.0-20170215233205-553a64147049 h1:K9KHZbXKpGydfDN0aZrsoHpLJlZsBrGMFWbgLDGnPZk= +github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w= +github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= +github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= +github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8= +github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= +github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= +github.com/openzipkin/zipkin-go v0.2.2 h1:nY8Hti+WKaP0cRsSeQ026wU03QsM762XBeCXBb9NAWI= +github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= +github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.7.1 h1:NTGy1Ja9pByO+xAeH/qiWnLrKtr3hJPNjaVUwnjpdpA= +github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= +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= +github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.10.0 h1:RyRA7RzGXQZiW+tGMr7sxa85G1z0yOpM1qq5c8lNawc= +github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= +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 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8= +github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= +github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +go.opentelemetry.io/contrib v0.9.0 h1:4FgJizPVyLabjo4BDy9yJC8NvVbSYjqEHwHBRz3u2vQ= +go.opentelemetry.io/contrib v0.9.0/go.mod h1:LGBQF/ydvt3WgH9NbFNzsFFwIkzTBFcJNiVkEQ165/Q= +go.opentelemetry.io/otel v0.9.0 h1:nsdCDHzQx1Yv8E2nwCPcMXMfg+EMIlx1LBOXNC8qSQ8= +go.opentelemetry.io/otel v0.9.0/go.mod h1:ckxzUEfk7tAkTwEMVdkllBM+YOfE/K9iwg6zYntFYSg= +go.opentelemetry.io/otel/exporters/metric/prometheus v0.9.0 h1:Q06RcQzoI7eeXOsdUROTx71TktUNdpCJT0FJJJAq9cQ= +go.opentelemetry.io/otel/exporters/metric/prometheus v0.9.0/go.mod h1:za3FCvOkKCM3H9RpkseWpKVF3RApyQj4WNnpaBjB3Mc= +go.opentelemetry.io/otel/exporters/trace/zipkin v0.9.0 h1:Ndk6Ajf2fLEq9/yCxwlVPG8DiARTJMp4D2gkVGB9vUw= +go.opentelemetry.io/otel/exporters/trace/zipkin v0.9.0/go.mod h1:dZhgw4MjVLIWEgKZZVNw6FyE0FhLPTB2QgqXWi1bjxM= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +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= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1 h1:ogLJMz+qpzav7lGMh10LMvAkM/fAoGlaiiHYiFYdm80= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200722175500-76b94024e4b6 h1:X9xIZ1YU8bLZA3l6gqDUHSFiD0GFI9S548h6C8nDtOY= +golang.org/x/sys v0.0.0-20200722175500-76b94024e4b6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20191009194640-548a555dbc03/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940 h1:MRHtG0U6SnaUb+s+LhNE1qt1FQ1wlhqr5E4usBKC0uA= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.30.0 h1:M5a8xTlYTxwMn5ZFkwhRabsygDY5G8TYLyQDBxJNAxE= +google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +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-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/instrumentation/github.com/gocql/gocql/go.mod b/instrumentation/github.com/gocql/gocql/go.mod new file mode 100644 index 00000000000..ce71beee7a1 --- /dev/null +++ b/instrumentation/github.com/gocql/gocql/go.mod @@ -0,0 +1,12 @@ +module go.opentelemetry.io/contrib/instrumentation/github.com/gocql/gocql + +go 1.14 + +require ( + github.com/gocql/gocql v0.0.0-20200624222514-34081eda590e + github.com/golang/snappy v0.0.1 // indirect + github.com/stretchr/testify v1.6.1 + go.opentelemetry.io/contrib v0.9.0 + go.opentelemetry.io/otel v0.9.0 + google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940 // indirect +) diff --git a/instrumentation/github.com/gocql/gocql/go.sum b/instrumentation/github.com/gocql/gocql/go.sum new file mode 100644 index 00000000000..6e795f3ffec --- /dev/null +++ b/instrumentation/github.com/gocql/gocql/go.sum @@ -0,0 +1,124 @@ +cloud.google.com/go v0.26.0 h1:e0WKqKTd5BnrG8aKH3J3h+QvEIQtSUcf2n5UZ5ZgLtQ= +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/DataDog/sketches-go v0.0.0-20190923095040-43f19ad77ff7 h1:qELHH0AWCvf98Yf+CNIJx9vOZOfHFDDzgDRYsnNk/vs= +github.com/DataDog/sketches-go v0.0.0-20190923095040-43f19ad77ff7/go.mod h1:Q5DbzQ+3AkgGwymQO7aZFNP7ns2lZKGtvRBzRXfdi60= +github.com/benbjohnson/clock v1.0.3 h1:vkLuvpK4fmtSCuo60+yC63p7y0BmQ8gm5ZXGuBCJyXg= +github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= +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= +github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/gocql/gocql v0.0.0-20200624222514-34081eda590e h1:SroDcndcOU9BVAduPf/PXihXoR2ZYTQYLXbupbqxAyQ= +github.com/gocql/gocql v0.0.0-20200624222514-34081eda590e/go.mod h1:DL0ekTmBSTdlNF25Orwt/JMzqIq3EJ4MVa/J/uK64OY= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/snappy v0.0.0-20170215233205-553a64147049 h1:K9KHZbXKpGydfDN0aZrsoHpLJlZsBrGMFWbgLDGnPZk= +github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= +github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8= +github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +go.opentelemetry.io/contrib v0.9.0 h1:4FgJizPVyLabjo4BDy9yJC8NvVbSYjqEHwHBRz3u2vQ= +go.opentelemetry.io/contrib v0.9.0/go.mod h1:LGBQF/ydvt3WgH9NbFNzsFFwIkzTBFcJNiVkEQ165/Q= +go.opentelemetry.io/otel v0.9.0 h1:nsdCDHzQx1Yv8E2nwCPcMXMfg+EMIlx1LBOXNC8qSQ8= +go.opentelemetry.io/otel v0.9.0/go.mod h1:ckxzUEfk7tAkTwEMVdkllBM+YOfE/K9iwg6zYntFYSg= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +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-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20191009194640-548a555dbc03 h1:4HYDjxeNXAOTv3o1N2tjo8UUSlhQgAD52FVkwxnWgM8= +google.golang.org/genproto v0.0.0-20191009194640-548a555dbc03/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940 h1:MRHtG0U6SnaUb+s+LhNE1qt1FQ1wlhqr5E4usBKC0uA= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.30.0 h1:M5a8xTlYTxwMn5ZFkwhRabsygDY5G8TYLyQDBxJNAxE= +google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/instrumentation/github.com/gocql/gocql/gocql.go b/instrumentation/github.com/gocql/gocql/gocql.go new file mode 100644 index 00000000000..1dfa14c08fb --- /dev/null +++ b/instrumentation/github.com/gocql/gocql/gocql.go @@ -0,0 +1,45 @@ +// 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 gocql + +import ( + "context" + + "github.com/gocql/gocql" +) + +// NewSessionWithTracing creates a new session using the given cluster +// configuration enabling tracing for queries, batch queries, and connection attempts. +// You may use additional observers and disable specific tracing using the provided `TracedSessionOption`s. +func NewSessionWithTracing(ctx context.Context, cluster *gocql.ClusterConfig, options ...TracedSessionOption) (*gocql.Session, error) { + config := configure(options...) + cluster.QueryObserver = &OTelQueryObserver{ + enabled: config.instrumentQuery, + observer: config.queryObserver, + tracer: config.tracer, + } + cluster.BatchObserver = &OTelBatchObserver{ + enabled: config.instrumentBatch, + observer: config.batchObserver, + tracer: config.tracer, + } + cluster.ConnectObserver = &OTelConnectObserver{ + ctx: ctx, + enabled: config.instrumentConnect, + observer: config.connectObserver, + tracer: config.tracer, + } + return cluster.CreateSession() +} diff --git a/instrumentation/github.com/gocql/gocql/gocql_test.go b/instrumentation/github.com/gocql/gocql/gocql_test.go new file mode 100644 index 00000000000..5e8d15771db --- /dev/null +++ b/instrumentation/github.com/gocql/gocql/gocql_test.go @@ -0,0 +1,528 @@ +// 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 gocql + +import ( + "context" + "fmt" + "log" + "os" + "strings" + "testing" + "time" + + "github.com/stretchr/testify/require" + + "go.opentelemetry.io/otel/api/standard" + "go.opentelemetry.io/otel/api/trace" + + "go.opentelemetry.io/otel/sdk/metric/controller/push" + "go.opentelemetry.io/otel/sdk/metric/selector/simple" + + "github.com/gocql/gocql" + "github.com/stretchr/testify/assert" + + mocktracer "go.opentelemetry.io/contrib/internal/trace" + "go.opentelemetry.io/otel/api/kv" + "go.opentelemetry.io/otel/api/metric" + export "go.opentelemetry.io/otel/sdk/export/metric" + "go.opentelemetry.io/otel/sdk/export/metric/aggregation" +) + +const ( + keyspace string = "gotest" + tableName string = "test_table" +) + +var exporter *mockExporter + +// mockExporter provides an exporter to access metrics +// used for testing puporses only. +type mockExporter struct { + t *testing.T + records []export.Record +} + +func (mockExporter) ExportKindFor(*metric.Descriptor, aggregation.Kind) export.ExportKind { + return export.PassThroughExporter +} + +func (e *mockExporter) Export(_ context.Context, set export.CheckpointSet) error { + if err := set.ForEach(e, func(record export.Record) error { + e.records = append(e.records, record) + return nil + }); err != nil { + e.t.Fatal(err) + return err + } + return nil +} + +// mockExportPipeline returns a push controller with a mockExporter. +func mockExportPipeline(t *testing.T) *push.Controller { + var records []export.Record + exporter = &mockExporter{t, records} + controller := push.New( + simple.NewWithExactDistribution(), + exporter, + push.WithPeriod(1*time.Second), + ) + controller.Start() + return controller +} + +type mockConnectObserver struct { + callCount int +} + +func (m *mockConnectObserver) ObserveConnect(observedConnect gocql.ObservedConnect) { + m.callCount++ +} + +type testRecord struct { + Name string + MeterName string + Labels []kv.KeyValue + Number metric.Number +} + +func TestQuery(t *testing.T) { + controller := getController(t) + defer afterEach() + cluster := getCluster() + tracer := mocktracer.NewTracer("gocql-test") + + ctx, parentSpan := tracer.Start(context.Background(), "gocql-test") + + session, err := NewSessionWithTracing( + ctx, + cluster, + WithTracer(tracer), + WithConnectInstrumentation(false), + ) + require.NoError(t, err) + defer session.Close() + require.NoError(t, session.AwaitSchemaAgreement(ctx)) + + id := gocql.TimeUUID() + title := "example-title" + insertStmt := fmt.Sprintf("insert into %s (id, title) values (?, ?)", tableName) + query := session.Query(insertStmt, id, title).WithContext(ctx) + assert.NotNil(t, query, "expected query to not be nil") + require.NoError(t, query.Exec()) + + parentSpan.End() + + // Get the spans and ensure that they are child spans to the local parent + spans := tracer.EndedSpans() + + // Collect all the connection spans + // total spans: + // 1 span for the Query + // 1 span created in test + require.Len(t, spans, 2) + + // Verify attributes are correctly added to the spans. Omit the one local span + for _, span := range spans[0 : len(spans)-1] { + + switch span.Name { + case insertStmt: + assert.Equal(t, insertStmt, span.Attributes[standard.DBStatementKey].AsString()) + assert.Equal(t, parentSpan.SpanContext().SpanID.String(), span.ParentSpanID.String()) + default: + t.Fatalf("unexpected span name %s", span.Name) + } + assertConnectionLevelAttributes(t, span) + } + + // Check metrics + controller.Stop() + + require.Len(t, exporter.records, 3) + expected := []testRecord{ + { + Name: "db.cassandra.queries", + MeterName: instrumentationName, + Labels: []kv.KeyValue{ + cassDBSystem(), + cassPeerIP("127.0.0.1"), + cassPeerPort(9042), + cassVersion("3"), + cassHostID("test-id"), + cassHostState("UP"), + cassKeyspace(keyspace), + cassStatement(insertStmt), + }, + Number: 1, + }, + { + Name: "db.cassandra.rows", + MeterName: instrumentationName, + Labels: []kv.KeyValue{ + cassDBSystem(), + cassPeerIP("127.0.0.1"), + cassPeerPort(9042), + cassVersion("3"), + cassHostID("test-id"), + cassHostState("UP"), + cassKeyspace(keyspace), + }, + Number: 0, + }, + { + Name: "db.cassandra.latency", + MeterName: instrumentationName, + Labels: []kv.KeyValue{ + cassDBSystem(), + cassPeerIP("127.0.0.1"), + cassPeerPort(9042), + cassVersion("3"), + cassHostID("test-id"), + cassHostState("UP"), + cassKeyspace(keyspace), + }, + }, + } + + for _, record := range exporter.records { + name := record.Descriptor().Name() + agg := record.Aggregation() + switch name { + case "db.cassandra.queries": + recordEqual(t, expected[0], record) + numberEqual(t, expected[0].Number, agg) + case "db.cassandra.rows": + recordEqual(t, expected[1], record) + numberEqual(t, expected[1].Number, agg) + case "db.cassandra.latency": + recordEqual(t, expected[2], record) + // The latency will vary, so just check that it exists + if _, ok := agg.(aggregation.MinMaxSumCount); !ok { + t.Fatal("missing aggregation in latency record") + } + default: + t.Fatalf("wrong metric %s", name) + } + } + +} + +func TestBatch(t *testing.T) { + controller := getController(t) + defer afterEach() + cluster := getCluster() + tracer := mocktracer.NewTracer("gocql-test") + + ctx, parentSpan := tracer.Start(context.Background(), "gocql-test") + + session, err := NewSessionWithTracing( + ctx, + cluster, + WithTracer(tracer), + WithConnectInstrumentation(false), + ) + require.NoError(t, err) + defer session.Close() + require.NoError(t, session.AwaitSchemaAgreement(ctx)) + + batch := session.NewBatch(gocql.LoggedBatch).WithContext(ctx) + for i := 0; i < 10; i++ { + id := gocql.TimeUUID() + title := fmt.Sprintf("batch-title-%d", i) + stmt := fmt.Sprintf("insert into %s (id, title) values (?, ?)", tableName) + batch.Query(stmt, id, title) + } + + require.NoError(t, session.ExecuteBatch(batch)) + + parentSpan.End() + + spans := tracer.EndedSpans() + // total spans: + // 1 span for the query + // 1 span for the local span + if assert.Len(t, spans, 2) { + span := spans[0] + assert.Equal(t, cassBatchQueryName, span.Name) + assert.Equal(t, parentSpan.SpanContext().SpanID, span.ParentSpanID) + assert.Equal(t, "db.cassandra.batch.query", + span.Attributes[standard.DBOperationKey].AsString(), + ) + assertConnectionLevelAttributes(t, span) + } + + controller.Stop() + + // Check metrics + require.Len(t, exporter.records, 2) + expected := []testRecord{ + { + Name: "db.cassandra.batch.queries", + MeterName: instrumentationName, + Labels: []kv.KeyValue{ + cassDBSystem(), + cassPeerIP("127.0.0.1"), + cassPeerPort(9042), + cassVersion("3"), + cassHostID("test-id"), + cassHostState("UP"), + cassKeyspace(keyspace), + }, + Number: 1, + }, + { + Name: "db.cassandra.latency", + MeterName: instrumentationName, + Labels: []kv.KeyValue{ + cassDBSystem(), + cassPeerIP("127.0.0.1"), + cassPeerPort(9042), + cassVersion("3"), + cassHostID("test-id"), + cassHostState("UP"), + cassKeyspace(keyspace), + }, + }, + } + + for _, record := range exporter.records { + name := record.Descriptor().Name() + agg := record.Aggregation() + switch name { + case "db.cassandra.batch.queries": + recordEqual(t, expected[0], record) + numberEqual(t, expected[0].Number, agg) + case "db.cassandra.latency": + recordEqual(t, expected[1], record) + if _, ok := agg.(aggregation.MinMaxSumCount); !ok { + t.Fatal("missing aggregation in latency record") + } + default: + t.Fatalf("wrong metric %s", name) + } + } + +} + +func TestConnection(t *testing.T) { + controller := getController(t) + defer afterEach() + cluster := getCluster() + tracer := mocktracer.NewTracer("gocql-test") + connectObserver := &mockConnectObserver{0} + ctx := context.Background() + + session, err := NewSessionWithTracing( + ctx, + cluster, + WithTracer(tracer), + WithConnectObserver(connectObserver), + ) + require.NoError(t, err) + defer session.Close() + require.NoError(t, session.AwaitSchemaAgreement(ctx)) + + spans := tracer.EndedSpans() + + assert.Less(t, 0, connectObserver.callCount) + + controller.Stop() + + // Verify the span attributes + for _, span := range spans { + assert.Equal(t, cassConnectName, span.Name) + assert.Equal(t, "db.cassandra.connect", span.Attributes[standard.DBOperationKey].AsString()) + assertConnectionLevelAttributes(t, span) + } + + // Verify the metrics + expected := []testRecord{ + { + Name: "db.cassandra.connections", + MeterName: instrumentationName, + Labels: []kv.KeyValue{ + cassDBSystem(), + cassPeerIP("127.0.0.1"), + cassPeerPort(9042), + cassVersion("3"), + cassHostID("test-id"), + cassHostState("UP"), + }, + }, + } + + for _, record := range exporter.records { + name := record.Descriptor().Name() + switch name { + case "db.cassandra.connections": + recordEqual(t, expected[0], record) + default: + t.Fatalf("wrong metric %s", name) + } + } +} + +func TestHostOrIP(t *testing.T) { + hostAndPort := "127.0.0.1:9042" + attribute := hostOrIP(hostAndPort) + assert.Equal(t, standard.NetPeerIPKey, attribute.Key) + assert.Equal(t, "127.0.0.1", attribute.Value.AsString()) + + hostAndPort = "exampleHost:9042" + attribute = hostOrIP(hostAndPort) + assert.Equal(t, standard.NetPeerNameKey, attribute.Key) + assert.Equal(t, "exampleHost", attribute.Value.AsString()) + + hostAndPort = "invalid-host-and-port-string" + attribute = hostOrIP(hostAndPort) + require.Empty(t, attribute.Value.AsString()) +} + +func assertConnectionLevelAttributes(t *testing.T, span *mocktracer.Span) { + assert.Equal(t, span.Attributes[standard.DBSystemKey].AsString(), + standard.DBSystemCassandra.Value.AsString(), + ) + assert.Equal(t, "127.0.0.1", span.Attributes[standard.NetPeerIPKey].AsString()) + assert.Equal(t, int32(9042), span.Attributes[standard.NetPeerPortKey].AsInt32()) + assert.Contains(t, span.Attributes, cassVersionKey) + assert.Contains(t, span.Attributes, cassHostIDKey) + assert.Equal(t, "up", strings.ToLower(span.Attributes[cassHostStateKey].AsString())) + assert.Equal(t, trace.SpanKindClient, span.Kind) +} + +// getCluster creates a gocql ClusterConfig with the appropriate +// settings for test cases. +func getCluster() *gocql.ClusterConfig { + cluster := gocql.NewCluster("127.0.0.1") + cluster.Keyspace = keyspace + cluster.Consistency = gocql.LocalQuorum + cluster.NumConns = 1 + return cluster +} + +// getController returns the push controller for the mock +// export pipeline. +func getController(t *testing.T) *push.Controller { + controller := mockExportPipeline(t) + InstrumentWithProvider(controller.Provider()) + return controller +} + +// recordEqual checks that the given metric name and instrumentation names are equal. +func recordEqual(t *testing.T, expected testRecord, actual export.Record) { + descriptor := actual.Descriptor() + assert.Equal(t, expected.Name, descriptor.Name()) + assert.Equal(t, expected.MeterName, descriptor.InstrumentationName()) + require.Len(t, actual.Labels().ToSlice(), len(expected.Labels)) + for _, label := range expected.Labels { + actualValue, ok := actual.Labels().Value(label.Key) + assert.True(t, ok) + assert.NotNil(t, actualValue) + // Can't test equality of host id + if label.Key != cassHostIDKey && label.Key != cassVersionKey { + assert.Equal(t, label.Value, actualValue) + } else { + assert.NotEmpty(t, actualValue) + } + } +} + +func numberEqual(t *testing.T, expected metric.Number, agg aggregation.Aggregation) { + kind := agg.Kind() + switch kind { + case aggregation.SumKind: + if sum, ok := agg.(aggregation.Sum); !ok { + t.Fatal("missing sum value") + } else { + if num, err := sum.Sum(); err == nil { + assert.Equal(t, expected, num) + } else { + t.Fatal("missing value") + } + } + case aggregation.ExactKind: + if mmsc, ok := agg.(aggregation.MinMaxSumCount); !ok { + t.Fatal("missing aggregation") + } else { + if max, err := mmsc.Max(); err == nil { + assert.Equal(t, expected, max) + } else { + t.Fatal("missing sum") + } + } + default: + t.Fatalf("unexpected kind %s", kind) + } +} + +// beforeAll creates the testing keyspace and table if they do not already exist. +func beforeAll() { + cluster := gocql.NewCluster("localhost") + cluster.Consistency = gocql.LocalQuorum + cluster.Keyspace = "system" + + session, err := cluster.CreateSession() + if err != nil { + log.Fatalf("failed to connect to database during beforeAll, %v", err) + } + + err = session.Query( + fmt.Sprintf( + "create keyspace if not exists %s with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }", + keyspace, + ), + ).Exec() + if err != nil { + log.Fatal(err) + } + + cluster.Keyspace = keyspace + cluster.Timeout = time.Second * 2 + session, err = cluster.CreateSession() + if err != nil { + log.Fatal(err) + } + + err = session.Query( + fmt.Sprintf("create table if not exists %s(id UUID, title text, PRIMARY KEY(id))", tableName), + ).Exec() + if err != nil { + log.Fatal(err) + } +} + +// afterEach truncates the table used for testing. +func afterEach() { + cluster := gocql.NewCluster("localhost") + cluster.Consistency = gocql.LocalQuorum + cluster.Keyspace = keyspace + cluster.Timeout = time.Second * 2 + session, err := cluster.CreateSession() + if err != nil { + log.Fatalf("failed to connect to database during afterEach, %v", err) + } + if err = session.Query(fmt.Sprintf("truncate table %s", tableName)).Exec(); err != nil { + log.Fatalf("failed to truncate table, %v", err) + } +} + +func TestMain(m *testing.M) { + if _, present := os.LookupEnv("INTEGRATION"); !present { + fmt.Println("--- SKIP: to enable integration test, set the INTEGRATION environment variable") + os.Exit(0) + } + beforeAll() + os.Exit(m.Run()) +} diff --git a/instrumentation/github.com/gocql/gocql/instrument.go b/instrumentation/github.com/gocql/gocql/instrument.go new file mode 100644 index 00000000000..bbc13762956 --- /dev/null +++ b/instrumentation/github.com/gocql/gocql/instrument.go @@ -0,0 +1,89 @@ +// 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 gocql + +import ( + "log" + + "go.opentelemetry.io/otel/api/global" + + "go.opentelemetry.io/otel/api/metric" + "go.opentelemetry.io/otel/api/unit" +) + +var ( + // iQueryCount is the number of queries executed. + iQueryCount metric.Int64Counter + + // iQueryRows is the number of rows returned by a query. + iQueryRows metric.Int64ValueRecorder + + // iBatchCount is the number of batch queries executed. + iBatchCount metric.Int64Counter + + // iConnectionCount is the number of connections made + // with the traced session. + iConnectionCount metric.Int64Counter + + // iLatency is the sum of attempt latencies. + iLatency metric.Int64ValueRecorder +) + +// InstrumentWithProvider will recreate instruments using a meter +// from the given provider p. +func InstrumentWithProvider(p metric.Provider) { + meter := p.Meter(instrumentationName) + var err error + + if iQueryCount, err = meter.NewInt64Counter( + "db.cassandra.queries", + metric.WithDescription("Number queries executed"), + ); err != nil { + log.Printf("failed to create iQueryCount instrument, %v", err) + } + + if iQueryRows, err = meter.NewInt64ValueRecorder( + "db.cassandra.rows", + metric.WithDescription("Number of rows returned from query"), + ); err != nil { + log.Printf("failed to create iQueryRows instrument, %v", err) + } + + if iBatchCount, err = meter.NewInt64Counter( + "db.cassandra.batch.queries", + metric.WithDescription("Number of batch queries executed"), + ); err != nil { + log.Printf("failed to create iBatchCount instrument, %v", err) + } + + if iConnectionCount, err = meter.NewInt64Counter( + "db.cassandra.connections", + metric.WithDescription("Number of connections created"), + ); err != nil { + log.Printf("failed to create iConnectionCount instrument, %v", err) + } + + if iLatency, err = meter.NewInt64ValueRecorder( + "db.cassandra.latency", + metric.WithDescription("Sum of latency to host in milliseconds"), + metric.WithUnit(unit.Milliseconds), + ); err != nil { + log.Printf("failed to create iLatency instrument, %v", err) + } +} + +func init() { + InstrumentWithProvider(global.MeterProvider()) +} diff --git a/instrumentation/github.com/gocql/gocql/observer.go b/instrumentation/github.com/gocql/gocql/observer.go new file mode 100644 index 00000000000..30693e4bb7c --- /dev/null +++ b/instrumentation/github.com/gocql/gocql/observer.go @@ -0,0 +1,245 @@ +// 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 gocql + +import ( + "context" + "log" + "net" + "time" + + "github.com/gocql/gocql" + + "go.opentelemetry.io/otel/api/kv" + "go.opentelemetry.io/otel/api/trace" +) + +// OTelQueryObserver implements the gocql.QueryObserver interface +// to provide instrumentation to gocql queries. +type OTelQueryObserver struct { + enabled bool + observer gocql.QueryObserver + tracer trace.Tracer +} + +// OTelBatchObserver implements the gocql.BatchObserver interface +// to provide instrumentation to gocql batch queries. +type OTelBatchObserver struct { + enabled bool + observer gocql.BatchObserver + tracer trace.Tracer +} + +// OTelConnectObserver implements the gocql.ConnectObserver interface +// to provide instrumentation to connection attempts made by the session. +type OTelConnectObserver struct { + ctx context.Context + enabled bool + observer gocql.ConnectObserver + tracer trace.Tracer +} + +// ------------------------------------------ Observer Functions + +// ObserveQuery is called once per query, and provides instrumentation for it. +func (o *OTelQueryObserver) ObserveQuery(ctx context.Context, observedQuery gocql.ObservedQuery) { + if o.enabled { + host := observedQuery.Host + keyspace := observedQuery.Keyspace + + attributes := includeKeyValues(host, + cassKeyspace(keyspace), + cassStatement(observedQuery.Statement), + cassRowsReturned(observedQuery.Rows), + cassQueryAttempts(observedQuery.Metrics.Attempts), + ) + + ctx, span := o.tracer.Start( + ctx, + observedQuery.Statement, + trace.WithStartTime(observedQuery.Start), + trace.WithAttributes(attributes...), + trace.WithSpanKind(trace.SpanKindClient), + ) + + if observedQuery.Err != nil { + span.SetAttributes(cassErrMsg(observedQuery.Err.Error())) + iQueryCount.Add( + ctx, + 1, + includeKeyValues(host, + cassKeyspace(keyspace), + cassStatement(observedQuery.Statement), + cassErrMsg(observedQuery.Err.Error()), + )..., + ) + } else { + iQueryCount.Add( + ctx, + 1, + includeKeyValues(host, + cassKeyspace(keyspace), + cassStatement(observedQuery.Statement), + )..., + ) + } + + span.End(trace.WithEndTime(observedQuery.End)) + + iQueryRows.Record( + ctx, + int64(observedQuery.Rows), + includeKeyValues(host, cassKeyspace(keyspace))..., + ) + iLatency.Record( + ctx, + nanoToMilliseconds(observedQuery.Metrics.TotalLatency), + includeKeyValues(host, cassKeyspace(keyspace))..., + ) + } + + if o.observer != nil { + o.observer.ObserveQuery(ctx, observedQuery) + } +} + +// ObserveBatch is called once per batch query, and provides instrumentation for it. +func (o *OTelBatchObserver) ObserveBatch(ctx context.Context, observedBatch gocql.ObservedBatch) { + if o.enabled { + host := observedBatch.Host + keyspace := observedBatch.Keyspace + + attributes := includeKeyValues(host, + cassKeyspace(keyspace), + cassBatchQueryOperation(), + cassBatchQueries(len(observedBatch.Statements)), + ) + + ctx, span := o.tracer.Start( + ctx, + cassBatchQueryName, + trace.WithStartTime(observedBatch.Start), + trace.WithAttributes(attributes...), + trace.WithSpanKind(trace.SpanKindClient), + ) + + if observedBatch.Err != nil { + span.SetAttributes(cassErrMsg(observedBatch.Err.Error())) + iBatchCount.Add( + ctx, + 1, + includeKeyValues(host, + cassKeyspace(keyspace), + cassErrMsg(observedBatch.Err.Error()), + )..., + ) + } else { + iBatchCount.Add( + ctx, + 1, + includeKeyValues(host, cassKeyspace(keyspace))..., + ) + } + + span.End(trace.WithEndTime(observedBatch.End)) + + iLatency.Record( + ctx, + nanoToMilliseconds(observedBatch.Metrics.TotalLatency), + includeKeyValues(host, cassKeyspace(keyspace))..., + ) + } + + if o.observer != nil { + o.observer.ObserveBatch(ctx, observedBatch) + } +} + +// ObserveConnect is called once per connection attempt, and provides instrumentation for it. +func (o *OTelConnectObserver) ObserveConnect(observedConnect gocql.ObservedConnect) { + if o.enabled { + host := observedConnect.Host + + attributes := includeKeyValues(host, cassConnectOperation()) + + _, span := o.tracer.Start( + o.ctx, + cassConnectName, + trace.WithStartTime(observedConnect.Start), + trace.WithAttributes(attributes...), + trace.WithSpanKind(trace.SpanKindClient), + ) + + if observedConnect.Err != nil { + span.SetAttributes(cassErrMsg(observedConnect.Err.Error())) + iConnectionCount.Add( + o.ctx, + 1, + includeKeyValues(host, cassErrMsg(observedConnect.Err.Error()))..., + ) + } else { + iConnectionCount.Add( + o.ctx, + 1, + includeKeyValues(host)..., + ) + } + + span.End(trace.WithEndTime(observedConnect.End)) + } + + if o.observer != nil { + o.observer.ObserveConnect(observedConnect) + } +} + +// ------------------------------------------ Private Functions + +// includeKeyValues is a convenience function for adding multiple attributes/labels to a +// span or instrument. By default, this function includes connection-level attributes, +// (as per the semantic conventions) which have been made standard for all spans and metrics +// generated by this instrumentation integration. +func includeKeyValues(host *gocql.HostInfo, values ...kv.KeyValue) []kv.KeyValue { + connectionLevelAttributes := []kv.KeyValue{ + cassDBSystem(), + hostOrIP(host.HostnameAndPort()), + cassPeerPort(host.Port()), + cassVersion(host.Version().String()), + cassHostID(host.HostID()), + cassHostState(host.State().String()), + } + return append(connectionLevelAttributes, values...) +} + +// hostOrIP returns a KeyValue pair for the hostname +// retrieved from gocql.HostInfo.HostnameAndPort(). If the hostname +// is returned as a resolved IP address (as is the case for localhost), +// then the KeyValue will have the key net.peer.ip. +// If the hostname is the proper DNS name, then the key will be net.peer.name. +func hostOrIP(hostnameAndPort string) kv.KeyValue { + hostname, _, err := net.SplitHostPort(hostnameAndPort) + if err != nil { + log.Printf("failed to parse hostname from port, %v", err) + } + if parse := net.ParseIP(hostname); parse != nil { + return cassPeerIP(parse.String()) + } + return cassPeerName(hostname) +} + +// nanoToMilliseconds converts nanoseconds to milliseconds. +func nanoToMilliseconds(ns int64) int64 { + return ns / int64(time.Millisecond) +}