-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: Added telemetry for pg_catalog and information_schema tables access
Previously, when querying a not implemented table it was tracket by telemetry This was inadequate because when adding these tables as empty tables we no longer capture the access of these tables that are empty and unsupported To address this, this patch adds telemetry to track queries at pg_catalog and information_schema existing tables Release note (sql change): Added telemetry to track usage of pg_catalog and information_schema tables Fixes #58732
- Loading branch information
MiguelNovelo
committed
Feb 12, 2021
1 parent
9ca068f
commit bd760b0
Showing
4 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2020 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package sqltelemetry | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/server/telemetry" | ||
) | ||
|
||
const getVirtualSchemaEntry = "sql.schema.get_virtual_table.%s.%s" | ||
|
||
// trackedSchemas have the schemas that we track by telemetry. | ||
var trackedSchemas = map[string]struct{}{ | ||
"pg_catalog": {}, | ||
"information_schema": {}, | ||
} | ||
|
||
// IncrementGetVirtualTableEntry is used to increment telemetry counter for any | ||
// use of tracked schemas tables. | ||
func IncrementGetVirtualTableEntry(schema, tableName string) { | ||
if _, ok := trackedSchemas[schema]; ok { | ||
telemetry.Inc(telemetry.GetCounter(fmt.Sprintf(getVirtualSchemaEntry, schema, tableName))) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
feature-allowlist | ||
sql.schema.get_virtual_table.* | ||
---- | ||
|
||
feature-usage | ||
SELECT * FROM pg_catalog.pg_cast | ||
---- | ||
sql.schema.get_virtual_table.pg_catalog.pg_cast | ||
|
||
feature-usage | ||
SELECT * FROM information_schema.schema_privileges LIMIT 1 | ||
---- | ||
sql.schema.get_virtual_table.information_schema.schema_privileges | ||
|
||
feature-usage | ||
SELECT * FROM crdb_internal.databases LIMIT 1 | ||
---- | ||
|
||
feature-usage | ||
SELECT * FROM pg_catalog.pg_xxx | ||
---- | ||
error: pq: relation "pg_catalog.pg_xxx" does not exist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters