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

Add Ktor-powered REST Datadog module #122

Merged
merged 11 commits into from
Feb 11, 2025
Merged

Add Ktor-powered REST Datadog module #122

merged 11 commits into from
Feb 11, 2025

Conversation

sdonn3
Copy link
Contributor

@sdonn3 sdonn3 commented Feb 4, 2025

Adds a new module, ktor, which provides a ktor based implementation of a Datadog Logger, providing through a ktor client directly through the Datadog Log Submission Api

@sdonn3 sdonn3 requested a review from a team as a code owner February 4, 2025 22:00
@sdonn3 sdonn3 requested review from twyatt and Phoenix7351 February 4, 2025 22:00
@sdonn3 sdonn3 added the major Changes that should bump the MAJOR version number label Feb 4, 2025
@sdonn3 sdonn3 changed the title Add rest-based datadog module Add rest/ktor-based datadog module Feb 4, 2025
internal class HttpError(message: String? = null) : Throwable(message)

internal interface LogSubmission {
suspend fun submitLogs(logs: List<JsonObject>): Result<Unit, Throwable>
Copy link
Member

Choose a reason for hiding this comment

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

We return a Result, but it isn't even used.

There is no persistence or retry mechanism, is that planned in a follow up 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.

Batching, error handling and a retry mechanism are all potential upgrades for later. The idea was to get a first version out and see if we need to prioritize these upgrades after we the first implementation going in Proksy

It wasn't a huge lift to add the Result as a return type on the api request, and it felt like best practice? I know we aren't using it yet but I have a feeling its going to be utilized soon (if we end up needing any of the above features)

Copy link

@Phoenix7351 Phoenix7351 left a comment

Choose a reason for hiding this comment

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

LGTM

@sdonn3 sdonn3 requested a review from twyatt February 7, 2025 22:00
Copy link
Member

@twyatt twyatt left a comment

Choose a reason for hiding this comment

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

Left some comments about potential optimizations, although I realize that might involve bringing back AtomicFu for synchronized. Sowwy.
Let me know if that doesn't seem feasible. Just ideas, I'm not super attached to them.

@sdonn3 sdonn3 requested a review from twyatt February 10, 2025 22:25
@sdonn3
Copy link
Contributor Author

sdonn3 commented Feb 10, 2025

@twyatt I think I made all the requested changes and it looks quite a bit better. I went ahead and tested it again (still works as expected)

Copy link
Member

@twyatt twyatt left a comment

Choose a reason for hiding this comment

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

OMG! Amazing job! Love how it turned out!
Great idea using the immutable collections library, that made things work out great. Looks like it'd be way more efficient now.

💯 🏅

http
.preparePost("api/v2/logs") {
setBody(logs)
}.executeForResult()
Copy link
Member

Choose a reason for hiding this comment

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

ultra nit

Suggested change
}.executeForResult()
}
.executeForResult()

@twyatt twyatt changed the title Add rest/ktor-based datadog module Add Ktor-powered REST Datadog module Feb 11, 2025
@sdonn3 sdonn3 enabled auto-merge (squash) February 11, 2025 18:01
@sdonn3 sdonn3 disabled auto-merge February 11, 2025 18:16
@sdonn3 sdonn3 enabled auto-merge (squash) February 11, 2025 18:16
@sdonn3 sdonn3 merged commit 7d8f7cb into main Feb 11, 2025
2 checks passed
@sdonn3 sdonn3 deleted the steve/add_rest_datadog branch February 11, 2025 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major Changes that should bump the MAJOR version number
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants