Skip to content

Commit ceb3374

Browse files
author
Cory G Watson
committed
Add global tags
1 parent aaeec30 commit ceb3374

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

redis-statsd.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
parser.add_argument('--prefix', dest='prefix', type=str, default='redis', help='The prefix to use for metric names')
1111
parser.add_argument('--redis-host', dest='redis_host', type=str, default='localhost:6379', help='The address and port of the Redis host to connect to')
1212
parser.add_argument('--statsd-host', dest='statsd_host', type=str, default='localhost:8125', help='The address and port of the StatsD host to connect to')
13+
parser.add_argument('--global-tags', dest='global_tags', type=str, help='Global tags to add to all metrics')
1314
parser.add_argument('--no-tags', dest='tags', action='store_false', help='Disable tags for use with DogStatsD')
1415

1516
args = parser.parse_args()
@@ -54,8 +55,15 @@
5455
def send_metric(name, mtype, value, tags=None):
5556
tagstring = ''
5657
finalvalue = value
57-
if tags is not None and args.tags:
58+
if tags is None:
59+
tags = []
60+
61+
if args.global_tags is not None:
62+
tags.extend(args.global_tags.split(','))
63+
64+
if len(tags) > 0 and args.tags:
5865
tagstring = '#{}'.format(','.join(tags))
66+
5967
if mtype == 'c':
6068
# For counters we will calculate our own deltas.
6169
mkey = '{}:{}'.format(name, tagstring)

0 commit comments

Comments
 (0)