Skip to content

Commit c9d0b85

Browse files
authored
Merge pull request DataDog#175 from DataDog/stephenf/only-add-env-none-if-no-env-set
Only add env:none tag to logs if no env tag is set
2 parents c54d985 + 2e5ffaf commit c9d0b85

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

aws/logs_monitoring/lambda_function.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def compileRegex(rule, pattern):
250250
DD_CUSTOM_TAGS = "ddtags"
251251
DD_SERVICE = "service"
252252
DD_HOST = "host"
253-
DD_FORWARDER_VERSION = "2.3.0"
253+
DD_FORWARDER_VERSION = "2.3.1"
254254

255255
class RetriableException(Exception):
256256
pass
@@ -822,7 +822,11 @@ def awslogs_handler(event, context, metadata):
822822
# Default `env` to `none` and `service` to the function name,
823823
# for correlation with the APM env and service.
824824
metadata[DD_SERVICE] = function_name
825-
metadata[DD_CUSTOM_TAGS] += ",env:none"
825+
826+
env_tag_exists = metadata[DD_CUSTOM_TAGS].startswith('env:') or ',env:' in metadata[DD_CUSTOM_TAGS]
827+
# If there is no env specified, default to env:none
828+
if not env_tag_exists:
829+
metadata[DD_CUSTOM_TAGS] += ",env:none"
826830

827831
# Create and send structured logs to Datadog
828832
for log in logs["logEvents"]:

0 commit comments

Comments
 (0)