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

fix(ingest/bigquery): increase logging in bigquery-queries extractor #11774

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(self, ctx: PipelineContext, config: BigQueryQueriesSourceConfig):
schema_api=BigQuerySchemaApi(
self.report.schema_api_perf,
self.connection,
projects_client=self.config.connection.get_projects_client(),
projects_client=self.connection,
),
config=self.config,
structured_report=self.report,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,18 +276,23 @@ def get_workunits_internal(
logger.info(f"Found {self.report.num_unique_queries} unique queries")

with self.report.audit_log_load_timer, queries_deduped:
i = 0
for _, query_instances in queries_deduped.items():
last_log_time = datetime.now()
last_report_time = datetime.now()
for i, (_, query_instances) in enumerate(queries_deduped.items()):
for query in query_instances.values():
if i > 0 and i % 10000 == 0:
now = datetime.now()
if (now - last_log_time).total_seconds() >= 60:
Copy link
Collaborator Author

@hsheth2 hsheth2 Nov 1, 2024

Choose a reason for hiding this comment

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

might be good to have a general abstraction for "do every X seconds", since the modulo stuff just feels like an approximation of that

e.g.

should_report = DoEvery(60)

for ...:
	if should_report.should():
		logger.info(...)

logger.info(
f"Added {i} query log equeries_dedupedntries to SQL aggregator"
f"Added {i} deduplicated query log entries to SQL aggregator"
)
last_log_time = now

if (now - last_report_time).total_seconds() >= 300:
if self.report.sql_aggregator:
logger.info(self.report.sql_aggregator.as_string())
last_report_time = now

self.aggregator.add(query)
i += 1

yield from auto_workunit(self.aggregator.gen_metadata())

Expand Down
Loading