Skip to content

Commit

Permalink
sql: Add telemetry for parsable plpgsql statements
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
ZhouXing19 authored and e-mbrown committed May 5, 2023
1 parent eab391e commit 5168146
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pkg/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -1627,6 +1627,7 @@ GO_TARGETS = [
"//pkg/sql/plpgsql/parser/lexbase:lexbase",
"//pkg/sql/plpgsql/parser:parser_test",
"//pkg/sql/plpgsql/parser:plpgparser",
"//pkg/sql/plpgsql/plpgsqltelemetry:plpgsqltelemetry",
"//pkg/sql/privilege:privilege",
"//pkg/sql/privilege:privilege_test",
"//pkg/sql/protoreflect/test:test",
Expand Down Expand Up @@ -2755,6 +2756,7 @@ GET_X_DATA_TARGETS = [
"//pkg/sql/physicalplan/replicaoracle:get_x_data",
"//pkg/sql/plpgsql/parser:get_x_data",
"//pkg/sql/plpgsql/parser/lexbase:get_x_data",
"//pkg/sql/plpgsql/plpgsqltelemetry:get_x_data",
"//pkg/sql/privilege:get_x_data",
"//pkg/sql/protoreflect:get_x_data",
"//pkg/sql/protoreflect/test:get_x_data",
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/catalog/funcinfo/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
load("//build/bazelutil/unused_checker:unused.bzl", "get_x_data")
4 changes: 4 additions & 0 deletions pkg/sql/parser/testdata/create_function_plpgsql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parse
CREATE OR REPLACE FUNCTION f(a int = 7) RETURNS INT AS 'SELECT 1' LANGUAGE SQL
----

1 change: 0 additions & 1 deletion pkg/sql/plpgsql/parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func TestParseDataDriver(t *testing.T) {
if err != nil {
d.Fatalf(t, "unexpected parse error: %v", err)
}

return fn.String()
}
d.Fatalf(t, "unsupported command: %s", d.Cmd)
Expand Down
12 changes: 12 additions & 0 deletions pkg/sql/plpgsql/plpgsqltelemetry/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
load("//build/bazelutil/unused_checker:unused.bzl", "get_x_data")
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "plpgsqltelemetry",
srcs = ["stmt_tags.go"],
importpath = "github.com/cockroachdb/cockroach/pkg/sql/plpgsql/plpgsqltelemetry",
visibility = ["//visibility:public"],
deps = ["//pkg/server/telemetry"],
)

get_x_data(name = "get_x_data")
6 changes: 6 additions & 0 deletions pkg/sql/plpgsql/plpgsqltelemetry/stmt_tags.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package plpgsqltelemetry

import "github.com/cockroachdb/cockroach/pkg/server/telemetry"

var StmtAssign = telemetry.GetCounter("plpgsql.stmt_assign")
var StmtCase = telemetry.GetCounter("plpgsql.stmt_case")

0 comments on commit 5168146

Please sign in to comment.