File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -265,6 +265,23 @@ def _get_license_key(license_key=None):
265
265
return os .getenv ("LICENSE_KEY" , "" )
266
266
267
267
268
+ def _get_newrelic_tags (payload ):
269
+ """
270
+ This functions gets New Relic's tags from env vars and adds it to the payload
271
+ A tag is a key value pair. Multiple tags can be specified.
272
+ Key and value are colon delimited. Multiple key value pairs are semi-colon delimited.
273
+ e.g. env:prod;team:myTeam
274
+ """
275
+ nr_tags_str = os .getenv ("NR_TAGS" , "" )
276
+ if nr_tags_str :
277
+ nr_tags = dict (
278
+ item .split (":" )
279
+ for item in nr_tags_str .split (";" )
280
+ if not item .startswith (tuple (["aws:" , "plugin:" ]))
281
+ )
282
+ payload [0 ]["common" ]["attributes" ].update (nr_tags )
283
+
284
+
268
285
def _debug_logging_enabled ():
269
286
"""
270
287
Determines whether or not debug logging should be enabled based on the env var.
@@ -336,7 +353,7 @@ def _get_entry_type(log_entry):
336
353
337
354
def _get_infra_endpoint ():
338
355
"""
339
- Service url is determined by the lincese key's region.
356
+ Service url is determined by the license key's region.
340
357
Any other URL could be passed by using the NR_INFRA_ENDPOINT env var.
341
358
"""
342
359
if "NR_INFRA_ENDPOINT" in os .environ :
@@ -453,6 +470,8 @@ def _package_log_payload(data):
453
470
}
454
471
]
455
472
473
+ _get_newrelic_tags (packaged_payload )
474
+
456
475
return packaged_payload
457
476
458
477
You can’t perform that action at this time.
0 commit comments