File tree 4 files changed +27
-5
lines changed
4 files changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -32,9 +32,9 @@ postgres://root@?redacted
32
32
33
33
# The session on the source should have an app name set.
34
34
query-sql as=source-system
35
- SELECT application_name FROM [SHOW SESSIONS] WHERE application_name LIKE '%repstream%' LIMIT 1
35
+ SELECT application_name FROM [SHOW ALL SESSIONS] WHERE application_name LIKE '%repstream%' LIMIT 1
36
36
----
37
- repstream job id=$_producerJobID
37
+ $ internal repstream job id=$_producerJobID
38
38
39
39
40
40
query-sql as=source-system
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ go_library(
25
25
"//pkg/sql/catalog/descs" ,
26
26
"//pkg/sql/isql" ,
27
27
"//pkg/sql/pgwire/pgcode" ,
28
+ "//pkg/sql/sem/catconstants" ,
28
29
"//pkg/util/ctxgroup" ,
29
30
"//pkg/util/hlc" ,
30
31
"//pkg/util/log" ,
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import (
16
16
"github.com/cockroachdb/cockroach/pkg/roachpb"
17
17
"github.com/cockroachdb/cockroach/pkg/sql/catalog/descs"
18
18
"github.com/cockroachdb/cockroach/pkg/sql/isql"
19
+ "github.com/cockroachdb/cockroach/pkg/sql/sem/catconstants"
19
20
"github.com/cockroachdb/cockroach/pkg/util/hlc"
20
21
"github.com/cockroachdb/cockroach/pkg/util/log"
21
22
"github.com/cockroachdb/cockroach/pkg/util/span"
@@ -317,11 +318,13 @@ type options struct {
317
318
}
318
319
319
320
func (o * options ) appName () string {
320
- const appNameBase = "repstream"
321
+ // NOTE: use an internal app name prefix so that the sql.*.internal metrics
322
+ // are used instead of the user facing metrics. The logic responsible for
323
+ // picking the metric family lives in conn_executor.go:SetupConn.
321
324
if o .streamID != 0 {
322
- return fmt .Sprintf ("%s job id=%d" , appNameBase , o .streamID )
325
+ return fmt .Sprintf ("%s repstream job id=%d" , catconstants . InternalAppNamePrefix , o .streamID )
323
326
} else {
324
- return appNameBase
327
+ return fmt . Sprintf ( "%s repstream" , catconstants . InternalAppNamePrefix )
325
328
}
326
329
}
327
330
Original file line number Diff line number Diff line change @@ -340,3 +340,21 @@ func ExampleClient() {
340
340
// kv: "key_1"->value_1@1
341
341
// resolved 100
342
342
}
343
+
344
+ func TestStreamClientAppName (t * testing.T ) {
345
+ defer leaktest .AfterTest (t )()
346
+ defer log .Scope (t ).Close (t )
347
+
348
+ expectAppName := func (t * testing.T , name string , options ... Option ) {
349
+ o := processOptions (options )
350
+ cfg , err := setupPGXConfig (& url.URL {
351
+ Scheme : "postgresql" ,
352
+ Host : "localhost:26257" ,
353
+ }, o )
354
+ require .NoError (t , err )
355
+ require .Equal (t , name , cfg .RuntimeParams ["application_name" ])
356
+ }
357
+
358
+ expectAppName (t , "$ internal repstream" )
359
+ expectAppName (t , "$ internal repstream job id=1337" , WithStreamID (1337 ))
360
+ }
You can’t perform that action at this time.
0 commit comments