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

feat: Persist retried hog function logs #29193

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

Conversation

benjackwhite
Copy link
Contributor

@benjackwhite benjackwhite commented Feb 25, 2025

Problem

Follow up from other PR

Changes

  • Allows sending the invocationID to be used for the event
  • Persist logs and use real URLs etc.
  • Add option when testing to bypass filtering
  • Add option when testing to give the invocation ID (and persist logs)
  • Refactors the way we produce logs and metrics to use shared methods

Follow up

  • Change invocationID to be the eventID
  • Persist log viewer filters to url
  • Fixes scrolling of nested table
  • Fix timestamp parsing madness....
  • Enrich with group types at the api level

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Does this work well for both Cloud and self-hosted?

How did you test this code?

Copy link
Contributor

github-actions bot commented Feb 25, 2025

Size Change: 0 B

Total Size: 9.72 MB

ℹ️ View Unchanged
Filename Size
frontend/dist/toolbar.js 9.72 MB

compressed-size-action

Base automatically changed from feat/retry-errored-events to master February 26, 2025 08:39
# Conflicts:
#	frontend/src/scenes/pipeline/hogfunctions/logs/hogFunctionLogsLogic.ts
@benjackwhite benjackwhite requested a review from a team February 26, 2025 09:39
@benjackwhite benjackwhite marked this pull request as ready for review February 26, 2025 09:39
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR introduces a centralized approach to handling logs and metrics for hog functions through a new HogFunctionMonitoringService class, focusing on persisting logs during retries.

  • Added new HogFunctionMonitoringService class that centralizes log and metric production functionality
  • Modified CdpCyclotronWorker to use the monitoring service for processing invocation results and producing messages
  • Added support for custom invocation IDs in the API to maintain log continuity across retries
  • Updated cdp-api.ts to handle ClickHouse events and ensure logs are properly persisted even in error cases
  • Refactored CdpProcessedEventsConsumer to use the monitoring service instead of direct log/metric production
  • Simplified API interfaces in Python code by using a more flexible payload-based approach

9 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +37 to +39
.catch((reason) => {
status.error('⚠️', `failed to produce message: ${reason}`)
})
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Error is logged but not propagated. Consider returning a result indicating success/failure or throwing the error to allow callers to handle it.

this.messagesToProduce.push({
topic: KAFKA_EVENTS_PLUGIN_INGESTION,
value: convertToCaptureEvent(event, team),
key: `${team!.api_token}:${event.distinct_id}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

syntax: The non-null assertion operator (!) is redundant here since the if-check on line 112 already ensures team is not null.

Suggested change
key: `${team!.api_token}:${event.distinct_id}`,
key: `${team.api_token}:${event.distinct_id}`,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant