-
Notifications
You must be signed in to change notification settings - Fork 310
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
[OPIK-797] Implement get log API #1079
Conversation
…ora/OPIK-796_implement_clickhouse_user_logs
…ora/OPIK-796_implement_clickhouse_user_logs
…ttps://github.com/comet-ml/opik into thiagohora/OPIK-796_implement_clickhouse_user_logs
…o thiagohora/OPIK-796_implement_get_log_api
0bd37c9
to
6ba985b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very good, I'd like some extra logging for easier debugging, but it's a great work and easy to extend no other log types.
...end/src/main/java/com/comet/opik/api/resources/v1/priv/AutomationRuleEvaluatorsResource.java
Show resolved
Hide resolved
evaluatorId, projectId, workspaceId); | ||
var criteria = LogCriteria.builder().workspaceId(workspaceId).entityId(evaluatorId).size(size).build(); | ||
LogPage logs = service.getLogs(criteria).block(); | ||
log.info("Found {} logs for automated evaluator: id '{}' on project_id '{}'and workspace_id '{}'", logs.size(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trivial: missing whitespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, where?
apps/opik-backend/src/main/java/com/comet/opik/domain/AutomationRuleEvaluatorLogsDAO.java
Show resolved
Hide resolved
public static synchronized void init(@NonNull UserLogTableFactory userLogTableFactory, int batchSize, | ||
@NonNull Duration flushIntervalDuration) { | ||
public static synchronized ClickHouseAppender init(@NonNull UserLogTableFactory userLogTableFactory, int batchSize, | ||
@NonNull Duration flushIntervalDuration, @NonNull LoggerContext context) { | ||
|
||
if (instance == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe an else log to know its returning the existent instance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This "if" only init the instance; the final line always returns the instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean it means init(...) was called multiple times. Maybe it can be useful to know it was called again and its not creating an instance but reusing the existent one - unless its happening way to often. Maybe the naming sugests me a 2nd execution would be unexpected. If it was called 'getOrCreate' I would expect multiple calls naturaly.
apps/opik-backend/src/main/java/com/comet/opik/infrastructure/log/ClickHouseAppender.java
Show resolved
Hide resolved
private BlockingQueue<ILoggingEvent> logQueue; | ||
private ScheduledExecutorService scheduler; | ||
private final BlockingQueue<ILoggingEvent> logQueue = new LinkedBlockingQueue<>(); | ||
private ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use final too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The scheduler cannot be final due to tests, where a JVM instance the application multiple times. When this happened the scheduler is shutdown after each test, so we need a new one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it volatile then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used atomic reference, as sonar complains about using volatile in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reuse the existing DAO.
import static com.comet.opik.api.LogItem.LogPage; | ||
|
||
@ImplementedBy(AutomationRuleEvaluatorLogsDAOImpl.class) | ||
public interface AutomationRuleEvaluatorLogsDAO { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please re-use the existing DAO: AutomationRuleEvaluatorLogDAO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
private BlockingQueue<ILoggingEvent> logQueue; | ||
private ScheduledExecutorService scheduler; | ||
private final BlockingQueue<ILoggingEvent> logQueue = new LinkedBlockingQueue<>(); | ||
private ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it volatile then.
…lication lifecycle
…ithub.com/comet-ml/opik into thiagohora/OPIK-796_implement_get_log_api
cfffdc9
to
57f232e
Compare
Let's break this PR in two parts:
This is hard to review and it will hard to identify an issue during deployment and to rollback it. |
Closing to favor the one which splits scope |
Details
This PR also unveiled two issues:
Managed
interface, which added the bean to the application lifecycle and allowed us to close the stream during the application shutdown.Issues
OPIK-797