bhuvan-somisetty opened a new pull request, #14001: URL: https://github.com/apache/apisix/pull/14001
### Description In `apisix/plugins/datadog.lua`, when `prefer_name` is enabled (default `true`), the plugin attempts to replace `entry.service_id` with `svc.value.name` if available. Previously, it checked `if svc and svc.value.name ~= "" then`. Because in Lua `nil ~= ""` evaluates to `true`, if a service did not have an optional `name` configured, `svc.value.name` was `nil` and overwrote `entry.service_id` with `nil`. This resulted in the `service_name` tag being completely dropped from emitted DogStatsD metrics instead of falling back to the service ID. This change verifies that `svc.value.name` is truthy before assigning, preserving the service ID fallback as intended, and adds unit test coverage. #### Which issue(s) this PR fixes: Fixes #14000 ### Checklist - [x] I have explained the need for this PR and the problem it solves - [x] I have explained the changes or the new features added to this PR - [x] I have added tests corresponding to this change - [ ] I have updated the documentation to reflect this change - [x] I have verified that this change is backward compatible (If not, please discuss on the [APISIX mailing list](https://github.com/apache/apisix/tree/master#community) first) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
