Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: Add telemetry for some partitioning UX improvements #40839

Merged
merged 1 commit into from
Sep 18, 2019

Conversation

rohany
Copy link
Contributor

@rohany rohany commented Sep 17, 2019

Add telemetry for the following operations:

  • show partitions
  • show ranges
  • show locality
  • show create table (intending to capture usage of new partitioning info)

Work towards https://github.com/cockroachlabs/registration/issues/228

Release justification: Low risk improvement to monitoring.

Release note: None

@rohany rohany requested review from solongordon, rafiss and a team September 17, 2019 17:24
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @rafiss, @rohany, and @solongordon)


pkg/sql/sqltelemetry/show.go, line 19 at r1 (raw file):

)

var showTelemetryCounters map[string]telemetry.Counter

this might be a little safer with an enum type as the key (with a String() method) instead of a string key. that way if it's used in different contexts it's harder to mess up the key name


pkg/sql/sqltelemetry/show.go, line 29 at r1 (raw file):

		telemetry.Inc(counter)
	} else {
		showTelemetryCounters[showType] = telemetry.GetCounterOnce(fmt.Sprintf("sql.show.%s", showType))

I think theoretically there is a race condition here, since two threads could be calling IncrementShowCounter for the same string, and both could end up in this branch. GetCounterOnce will panic if the counter exists

I think it would be safest to do all the GetCounterOnce calls in the init function. for example, take a look at pkg/sql/opt/telemetry.go

That would also be easier to do if there were an enum type and the init function just iterates over the enum values.

Copy link
Contributor Author

@rohany rohany left a comment

Choose a reason for hiding this comment

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

Good catches @rafiss. I wanted to have this so that you could just add different telemetry counters without having to touch show.go, but it seems better to explicitly have to add an enum to opt in.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @rafiss and @solongordon)


pkg/sql/sqltelemetry/show.go, line 19 at r1 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

this might be a little safer with an enum type as the key (with a String() method) instead of a string key. that way if it's used in different contexts it's harder to mess up the key name

Done.


pkg/sql/sqltelemetry/show.go, line 29 at r1 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

I think theoretically there is a race condition here, since two threads could be calling IncrementShowCounter for the same string, and both could end up in this branch. GetCounterOnce will panic if the counter exists

I think it would be safest to do all the GetCounterOnce calls in the init function. for example, take a look at pkg/sql/opt/telemetry.go

That would also be easier to do if there were an enum type and the init function just iterates over the enum values.

Done.

@rohany rohany requested a review from rafiss September 17, 2019 17:51
Add telemetry for the following operations:
* show partitions
* show ranges
* show locality
* show create table (intending to capture usage of new partitioning info)

Release justification: Low risk improvement to monitoring.

Release note: None
Copy link
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

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

looks great!

Reviewed 3 of 8 files at r1, 5 of 5 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @rafiss and @solongordon)

@rohany
Copy link
Contributor Author

rohany commented Sep 18, 2019

bors r+

craig bot pushed a commit that referenced this pull request Sep 18, 2019
40839: sql: Add telemetry for some partitioning UX improvements r=rohany a=rohany

Add telemetry for the following operations:
* show partitions
* show ranges
* show locality
* show create table (intending to capture usage of new partitioning info)

Work towards https://github.com/cockroachlabs/registration/issues/228

Release justification: Low risk improvement to monitoring.

Release note: None

Co-authored-by: Rohan Yadav <rohany@cockroachlabs.com>
@craig
Copy link
Contributor

craig bot commented Sep 18, 2019

Build succeeded

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.

3 participants