Skip to content

feat: add agentsdk function for sending logs #7629

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

Closed
wants to merge 1 commit into from
Closed

Conversation

kylecarbs
Copy link
Member

This enables external API consumers to easily send logs in order and with failure tolerance.

@kylecarbs kylecarbs requested a review from sreya May 22, 2023 16:28
@kylecarbs kylecarbs self-assigned this May 22, 2023
@kylecarbs kylecarbs force-pushed the logsdk branch 4 times, most recently from c8befde to f196725 Compare May 22, 2023 18:53
This enables external API consumers to easily send logs in order and
with failure tolerance.
@github-actions
Copy link

This Pull Request is becoming stale. In order to minimize WIP, prevent merge conflicts and keep the tracker readable, I'm going close to this PR in 3 days if there isn't more activity.

@github-actions github-actions bot added the stale This issue is like stale bread. label May 30, 2023
@coadler coadler removed the stale This issue is like stale bread. label May 30, 2023
@github-actions github-actions bot added the stale This issue is like stale bread. label Jun 7, 2023
@github-actions github-actions bot closed this Jun 11, 2023
@kylecarbs kylecarbs reopened this Jun 11, 2023
@github-actions github-actions bot removed the stale This issue is like stale bread. label Jun 12, 2023
@github-actions github-actions bot added the stale This issue is like stale bread. label Jun 20, 2023
}
c.SDK.Logger.Warn(ctx, "upload startup logs failed", slog.Error(err), slog.F("count", len(logs)))
}
if ctx.Err() != nil {
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be captured and shared, i.e. if lastSendErr == nil { lastSendErr = ctx.Err(); } or some such.

Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

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

I recently made a PR (#8084) to fix a log sending deadlock in the agent. Since I noticed this PR I decided to give it a quick review and it didn't have the same problem (but perhaps some others). Not sure whether or not it's still relevant but submitting the review in case it is.

queuedLogs := make([]StartupLog, 0, 100)
for {
select {
case <-time.After(debounce):
Copy link
Member

@mafredri mafredri Jun 20, 2023

Choose a reason for hiding this comment

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

Suggestion: Consider a timer vs time.After for conserving resources/cleaner shutdown. Let's say we log 1000 lines in 100ms, we will have ~1000 of these timers.

I also wonder if we should avoid starting a new timer because 100 log entries at a rate of 249ms/line will take ~25s to be sent to the server.

sendLogsWithRetry(queuedLogs)
queuedLogs = nil
case <-closeChan:
close(logChan)
Copy link
Member

@mafredri mafredri Jun 20, 2023

Choose a reason for hiding this comment

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

The func(log StartupLog) may panic after this since it can try to send on the closed channel. It should be left open.

https://go.dev/play/p/-qzJ3Wo1TYp (Try running a few times.)

@github-actions github-actions bot removed the stale This issue is like stale bread. label Jun 21, 2023
@github-actions github-actions bot added the stale This issue is like stale bread. label Jun 28, 2023
@kylecarbs
Copy link
Member Author

See 3b9b06f

@kylecarbs kylecarbs closed this Jun 28, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jun 28, 2023
@github-actions github-actions bot deleted the logsdk branch November 23, 2023 00:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
stale This issue is like stale bread.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants