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

Office365: save end date of date range in the checkpoint #1247

Merged
merged 3 commits into from
Jan 13, 2025
Merged
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
6 changes: 6 additions & 0 deletions Office365/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## 2024-01-10 - 2.18.7

### Fixed

- Save the end date of each date range in the checkpoint, in order to always progress

## 2024-01-10 - 2.18.6

### Changed
Expand Down
2 changes: 1 addition & 1 deletion Office365/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"name": "Microsoft Office365",
"uuid": "2dc2855e-3f9a-441c-af2a-30c64e0d0f4a",
"slug": "office365",
"version": "2.18.6",
"version": "2.18.7",
"categories": [
"Applicative"
]
Expand Down
21 changes: 17 additions & 4 deletions Office365/office365/management_api/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@
for event in events:
pulled_events.append(json.dumps(event))

if len(pulled_events) > self.limit_of_events_to_push:
yield pulled_events
pulled_events = []
if len(pulled_events) > self.limit_of_events_to_push:
yield pulled_events
pulled_events = []

Check warning on line 75 in Office365/office365/management_api/connector.py

View check run for this annotation

Codecov / codecov/patch

Office365/office365/management_api/connector.py#L74-L75

Added lines #L74 - L75 were not covered by tests

if len(pulled_events) > 0:
yield pulled_events
Expand Down Expand Up @@ -106,14 +106,27 @@
for start_date, end_date in split_date_range(
start_pull_date, end_pull_date, timedelta(minutes=self.time_range_interval)
):
intermediate_start_time = time.time()

# Get events for the current date range
async for list_of_events in self.pull_content(start_date, end_date):
await self.send_events(list_of_events)

# get the ending time and compute the duration to forward the events
intermediate_end_time = time.time()
intermediate_batch_duration = intermediate_end_time - intermediate_start_time
FORWARD_EVENTS_DURATION.labels(intake_key=self.configuration.intake_key).observe(
intermediate_batch_duration
)

# save intermediate end date
checkpoint.offset = end_date

# get the ending time and compute the duration to forward the events
end_time = time.time()
batch_duration = end_time - start_time
FORWARD_EVENTS_DURATION.labels(intake_key=self.configuration.intake_key).observe(batch_duration)

# save end date
checkpoint.offset = end_pull_date

# compute the remaining sleeping time. If greater than 0, sleep
Expand Down
Loading