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

fix(plugins/datadog): add return value for log function in batch queue #10044

Merged
merged 6 commits into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@
[#9877](https://github.com/Kong/kong/pull/9877)
- **JWT**: Deny requests that have different tokens in the jwt token search locations. Thanks Jackson 'Che-Chun' Kuo from Latacora for reporting this issue.
[#9946](https://github.com/Kong/kong/pull/9946)
- **Datadog**: Fix a bug that the batch queue in datadog can't get the right result when processing batch entries produced by datadog.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make this text match what's in the StatsD PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

[#10044](https://github.com/Kong/kong/pull/10044)

#### Core

Expand Down
3 changes: 2 additions & 1 deletion kong/plugins/datadog/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ local function log(conf, messages)
local logger, err = statsd_logger:new(conf)
if err then
kong.log.err("failed to create Statsd logger: ", err)
return
return false, err
end

for _, message in ipairs(messages) do
Expand Down Expand Up @@ -103,6 +103,7 @@ local function log(conf, messages)
end

logger:close_socket()
return true
end


Expand Down
19 changes: 19 additions & 0 deletions spec/03-plugins/08-datadog/01-log_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -424,5 +424,24 @@ for _, strategy in helpers.each_strategy() do

thread:join()
end)

-- the purpose of this test case is to test the batch queue
-- finish processing messages in one time(no retries)
it("no more messages than expected", function()
local thread = helpers.udp_server(9999, 10, 10)

local res = assert(proxy_client:send {
method = "GET",
path = "/status/200?apikey=kong",
headers = {
["Host"] = "datadog7.com"
}
})
assert.res_status(200, res)

local ok, gauges = thread:join()
assert.True(ok)
assert.equal(6, #gauges)
end)
end)
end