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

[improve][fn] Flush logs to log-topic periodically for Go Pulsar functions #22516

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

DavidRayner
Copy link

Motivation

Currently log messages for Go pulsar functions are only sent out to the log topic when addLogTopicHandler is called, which only happens when a Pulsar message is received (just before it is processed).

Therefore, if a function is not processing any data, any log statements from healthchecks etc will not be sent to the log topic. Also, any log statements that occur when processing a message will only appear when another message is processed.

Modifications

After logAppender.Start is called, a new method setupLogHandlerTicker is called to start a ticker in a goroutine.
The ticker calls flushLogsToTopicHandler (previously named addLogTopicHandler) every 100ms.

The logAppender.Stop method has been updated to stop the ticker after one final flush of logs to the log-topic.

A mutex has been added to flushLogsToTopicHandler to ensure that the ticker does not attempt to flush log statements to the log-topic whilst they are being flushed when a Pulsar message is received.

Verifying this change

  • Make sure that the change passes the CI checks.

This change added tests and can be verified as follows:

  • Unit tests have been added to test that the new ticker will flush logs out to the log-topic.

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: DavidRayner#2

Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the contribution @DavidRayner. Good work!

@Technoboy- Technoboy- added this to the 3.3.0 milestone Apr 24, 2024
@coderzc coderzc modified the milestones: 3.3.0, 3.4.0 May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/function doc-not-needed Your PR changes do not impact docs ready-to-test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants