Skip to content

Commit bf2ce39

Browse files
committed
add dbname to metrics
1 parent fa56eea commit bf2ce39

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

create_function_toddog.sql

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ PARAMETERS (
2929
/
3030
show err
3131

32-
prompt create function f_eventtoddog
33-
CREATE OR REPLACE FUNCTION f_eventtoddog (
32+
prompt create function eventtoddog
33+
CREATE OR REPLACE FUNCTION eventtoddog (
3434
title IN VARCHAR2,
3535
text IN VARCHAR2,
3636
tag IN VARCHAR2)
@@ -52,39 +52,39 @@ PARAMETERS (
5252
/
5353
show err
5454

55-
CREATE OR REPLACE FUNCTION f_gaugetoddog(
55+
CREATE OR REPLACE FUNCTION gaugetoddog(
5656
name IN VARCHAR2,
5757
metric IN number,
5858
tag IN VARCHAR2)
5959
RETURN VARCHAR2 IS
6060
BEGIN
61-
return f_metrictoddog(name,metric,'g',tag);
61+
return f_metrictoddog(name,metric,'g',tag || ',dbname:' || sys_context('USERENV','DB_NAME'));
6262
END;
6363
/
6464
show err
6565

66-
CREATE OR REPLACE FUNCTION f_counttoddog(
66+
CREATE OR REPLACE FUNCTION counttoddog(
6767
name IN VARCHAR2,
6868
metric IN number,
6969
tag IN VARCHAR2)
7070
RETURN VARCHAR2 IS
7171
BEGIN
72-
return f_metrictoddog(name,metric,'c',tag);
72+
return f_metrictoddog(name,metric,'c',tag || ',dbname:' || sys_context('USERENV','DB_NAME'));
7373
END;
7474
/
7575
show err
7676

7777
prompt grant access and create public synonym
7878

79+
GRANT EXECUTE ON eventtoddog TO public;
7980
GRANT EXECUTE ON f_metrictoddog TO public;
80-
GRANT EXECUTE ON f_eventtoddog TO public;
81-
GRANT EXECUTE ON f_gaugetoddog TO public;
82-
GRANT EXECUTE ON f_counttoddog TO public;
81+
GRANT EXECUTE ON gaugetoddog TO public;
82+
GRANT EXECUTE ON counttoddog TO public;
8383

84+
CREATE OR REPLACE PUBLIC SYNONYM eventtoddog FOR SYS.eventtoddog;
8485
CREATE OR REPLACE PUBLIC SYNONYM f_metrictoddog FOR SYS.f_metrictoddog;
85-
CREATE OR REPLACE PUBLIC SYNONYM f_eventtoddog FOR SYS.f_eventtoddog;
86-
CREATE OR REPLACE PUBLIC SYNONYM f_gaugetoddog FOR SYS.f_gaugetoddog;
87-
CREATE OR REPLACE PUBLIC SYNONYM f_counttoddog FOR SYS.f_counttoddog;
86+
CREATE OR REPLACE PUBLIC SYNONYM gaugetoddog FOR SYS.gaugetoddog;
87+
CREATE OR REPLACE PUBLIC SYNONYM counttoddog FOR SYS.counttoddog;
8888
show err
8989

9090
prompt calling function from pl/sql block
@@ -100,8 +100,8 @@ declare
100100
begin
101101
name := 'sample.gauge';
102102
metric := 15;
103-
tag := 'source:plsql' || ',dbname:' || sys_context('USERENV','DB_NAME');
104-
result := f_gaugetoddog(name,metric,tag);
103+
tag := 'source:plsql';
104+
result := gaugetoddog(name,metric,tag);
105105
dbms_output.put_line(result);
106106
EXCEPTION
107107
WHEN OTHERS THEN
@@ -122,8 +122,8 @@ declare
122122
begin
123123
name := 'sample.count';
124124
metric := 15;
125-
tag := 'source:plsql'|| ',dbname:' || sys_context('USERENV','DB_NAME');
126-
result := f_counttoddog(name,metric,tag);
125+
tag := 'source:plsql';
126+
result := counttoddog(name,metric,tag);
127127
dbms_output.put_line(result);
128128
EXCEPTION
129129
WHEN OTHERS THEN
@@ -145,7 +145,7 @@ begin
145145
title := 'title of event';
146146
text := 'text for event';
147147
tag := 'source:plsql' || ',dbname:' || sys_context('USERENV','DB_NAME');
148-
result := f_eventtoddog(title,text,tag);
148+
result := eventtoddog(title,text,tag);
149149
dbms_output.put_line(result);
150150
EXCEPTION
151151
WHEN OTHERS THEN

samples/errtoevent.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ begin
1919
end loop;
2020
EXCEPTION
2121
WHEN errorsysdate THEN
22-
event_rmsg := f_eventtoddog('sample event','sample: error counting sysdate, expected 2 or more','sample');
22+
event_rmsg := eventtoddog('sample event','sample: error counting sysdate, expected 2 or more','sample');
2323
raise_application_error(-20101, 'error counting from sysdate, event to ddog:' || event_rmsg);
2424
WHEN OTHERS THEN
2525
err_num := SQLCODE;

samples/rowcount.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ begin
1515
for t in c_table loop
1616
tag := 'table_name:' || t.table_name || ',schema:' || t.owner || ',dbname:' || sys_context('USERENV','DB_NAME');
1717
dbms_output.put_line(name || ':' || t.num_rows || ',' || tag);
18-
result := f_gaugetoddog(name,t.num_rows,tag);
18+
result := gaugetoddog(name,t.num_rows,tag);
1919
IF result != 'done' THEN
2020
RAISE errorinloop;
2121
END IF;

samples/rowcount_job.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ begin
1414
name := 'sample.rowcount';
1515
for t in c_table loop
1616
tag := 'table_name:' || t.table_name || ',schema:' || t.owner || ',dbname:' || sys_context('USERENV','DB_NAME');
17-
result := f_gaugetoddog(name,t.num_rows,tag);
17+
result := gaugetoddog(name,t.num_rows,tag);
1818
IF result != 'done' THEN
1919
RAISE errorinloop;
2020
END IF;

0 commit comments

Comments
 (0)