Skip to content

contrib/gocql: add NewCluster function to trace clients#1995

Closed
rarguelloF wants to merge 10 commits into
mainfrom
rarguelloF/cassandra-contact-points
Closed

contrib/gocql: add NewCluster function to trace clients#1995
rarguelloF wants to merge 10 commits into
mainfrom
rarguelloF/cassandra-contact-points

Conversation

@rarguelloF

@rarguelloF rarguelloF commented May 23, 2023

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds db.cassandra.contact.points to contrib/gocql.

  • Adds gocqltrace.NewCluster method to wrap the Cassandra client since it's created instead of individual queries.
  • Deprecate current WrapQuery and WrapBatch in favor of the new NewCluster method.
  • Updates the example to encourage new users to use this method instead.
  • Adds db.cassandra.contact.points tag for clients traced with NewCluster.

Motivation

We want to be able to tag db.cassandra.contact.points (and probably other stuff from the config in the future). With the current way of tracing this integration (WrapQuery and WrapBatch), we don't have access to the information that was specified during the client initialization unless we use reflection, that we should avoid.

Describe how to test/QA your changes

Reviewer's Checklist

  • Changed code has unit tests for its functionality.
  • If this interacts with the agent in a new way, a system test has been added.

@rarguelloF
rarguelloF marked this pull request as ready for review May 23, 2023 11:33
@rarguelloF
rarguelloF requested a review from a team May 23, 2023 11:33
Comment thread contrib/gocql/gocql/gocql.go Outdated
Comment thread contrib/gocql/gocql/gocql.go Outdated
Comment thread contrib/gocql/gocql/gocql.go Outdated
@pr-commenter

pr-commenter Bot commented May 31, 2023

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2023-06-19 13:48:43

Comparing candidate commit 7737493 in PR branch rarguelloF/cassandra-contact-points with baseline commit b34590b in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 24 metrics, 0 unstable metrics.

@rarguelloF
rarguelloF marked this pull request as draft May 31, 2023 09:23
@rarguelloF rarguelloF changed the title contrib/gocql: add db.cassandra.contact.points tag contrib/gocql: add NewCluster function to trace clients Jun 2, 2023
@rarguelloF
rarguelloF marked this pull request as ready for review June 7, 2023 10:04
telemetry.LoadIntegration(componentName)
}

type ClusterConfig struct {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add godoc comments for all these new public and exported types and functions

Comment thread contrib/gocql/gocql/gocql.go Outdated
return tb
}

// WithWrapOptions allows to specify options specific to the batch.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// WithWrapOptions allows to specify options specific to the batch.
// WithWrapOptions specifies options specific to the batch.

Comment thread contrib/gocql/gocql/gocql.go Outdated
return tq
}

// WithWrapOptions allows to specify options specific to the query.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// WithWrapOptions allows to specify options specific to the query.
// WithWrapOptions specifies options specific to the query.

Comment thread contrib/gocql/gocql/gocql_test.go Outdated
require.NoError(t, err)
q := session.Query("CREATE KEYSPACE trace WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'datacenter1' : 1 };")
err = q.Iter().Close()
require.Error(t, err)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This requires an error?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added IF NOT EXISTS to the query so an error is not expected require.NoError

Comment thread contrib/gocql/gocql/gocql_test.go Outdated
q := session.Query("CREATE KEYSPACE trace WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'datacenter1' : 1 };")
q = q.WithWrapOptions(WithResourceName("test-resource"))
err = q.Iter().Close()
require.Error(t, err)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did same change here

@rarguelloF
rarguelloF requested a review from ajgajg1134 June 16, 2023 14:21
Comment thread contrib/gocql/gocql/gocql.go Outdated
return tq
}

// WithWrapOptions specifies options specific to the query.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// WithWrapOptions specifies options specific to the query.
// WithWrapOptions applies the given set of options to the query.

Comment thread contrib/gocql/gocql/gocql.go Outdated
return tb
}

// WithWrapOptions specifies options specific to the batch.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar here, applies the given set of options to the

@rarguelloF rarguelloF closed this Jun 19, 2023
@rarguelloF
rarguelloF deleted the rarguelloF/cassandra-contact-points branch June 19, 2023 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants