Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLOUDS-4012] Fix service tag setting in lambda forwarder #714

Merged
merged 12 commits into from
Dec 5, 2023

Conversation

ge0Aja
Copy link
Contributor

@ge0Aja ge0Aja commented Nov 29, 2023

What does this PR do?

Fixing a bug related to service tag setting in the lambda forwarder

This PR fixes the precedence of setting the service tag from multiple sources and removes the redundancy when having multiple values for the service tag from these sources.

The order of priority for setting the service tag is as follows:

  1. message field in the log if it has a custom tags field set i.e. message.ddtags
  2. ddtags env var in the lambda logs forwarder
  3. LogGroup tags cache
  4. Lambda tags cache
  5. ddsource if non of the above is set

Previously the forwarder appended all the values set for the service from all sources in the custom tags field which created a confusion between the actual value of the service key in the log and the appended values in the custom tags field.
This PR removes the redundant values based on the above priorities and ensures that the service key is set according to the value of the highest priority.

Motivation

https://datadoghq.atlassian.net/browse/CLOUDS-4012

Testing Guidelines

Additional Notes

Types of changes

  • Bug fix
  • New feature
  • Breaking change
  • Misc (docs, refactoring, dependency upgrade, etc.)

Check all that apply

  • This PR's description is comprehensive
  • This PR contains breaking changes that are documented in the description
  • This PR introduces new APIs or parameters that are documented and unlikely to change in the foreseeable future
  • This PR impacts documentation, and it has been updated (or a ticket has been logged)
  • This PR's changes are covered by the automated tests
  • This PR collects user input/sensitive content into Datadog
  • This PR passes the integration tests (ask a Datadog member to run the tests)
  • This PR passes the unit tests
  • This PR passes the installation tests (ask a Datadog member to run the tests)

@github-actions github-actions bot added the aws label Nov 29, 2023
@ge0Aja ge0Aja marked this pull request as ready for review November 30, 2023 16:02
@ge0Aja ge0Aja requested review from a team December 1, 2023 08:56
aws/logs_monitoring/lambda_function.py Outdated Show resolved Hide resolved
aws/logs_monitoring/lambda_function.py Outdated Show resolved Hide resolved
aws/logs_monitoring/tests/test_lambda_function.py Outdated Show resolved Hide resolved
aws/logs_monitoring/lambda_function.py Outdated Show resolved Hide resolved
aws/logs_monitoring/lambda_cache.py Show resolved Hide resolved
aws/logs_monitoring/lambda_cache.py Outdated Show resolved Hide resolved
aws/logs_monitoring/lambda_function.py Outdated Show resolved Hide resolved
aws/logs_monitoring/lambda_function.py Show resolved Hide resolved
ge0Aja added 11 commits December 4, 2023 15:31
If the service tag in set in dd_tags use it, otherwise use the one coming from the logGroup
If none of the above, check if the tag is set on the lambda forwarder and use it, otherwise use the function name.
Finally, check if the service tag is set in the application level and override
ALso:
	- Update Itests
	- Add __init__.py to create a package for running utests inside the IDE
…tags

Override the service tag if it exists.
Merge upper level ddtags and message ddtags in one string.
@ge0Aja ge0Aja force-pushed the georgi.ajaeiya/clouds-4012 branch from ee43fac to 379dd1e Compare December 4, 2023 14:36
@ge0Aja ge0Aja merged commit 17d2bf6 into master Dec 5, 2023
12 checks passed
@ge0Aja ge0Aja deleted the georgi.ajaeiya/clouds-4012 branch December 5, 2023 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants