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

42-normalize-timestamp #46

Merged
merged 5 commits into from
Jul 3, 2024
Merged

42-normalize-timestamp #46

merged 5 commits into from
Jul 3, 2024

Conversation

rc10house
Copy link
Contributor

Added timestamp normalization function for use in log ID creation. The function can accept arbitrary timestamps and timezones and will attempt to normalize to a python date time object (defaults to +0000 timezone). The function can also accept POSIX timestamps (seconds or milliseconds since the epoch).

Closes #42

distill/core/log.py Outdated Show resolved Hide resolved
@rc10house rc10house requested a review from EandrewJones July 3, 2024 00:02
@@ -58,7 +58,7 @@ class UserAleSchema(BaseModel):
page_title: str
page_referrer: str
browser: Browser
client_time: int
client_time: int
Copy link
Contributor

Choose a reason for hiding this comment

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

why the trailing space?

@@ -19,8 +19,9 @@

from pydantic import ValidationError

from distill.core.log import Log
from distill.core.log import Log
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: trailing ws

Comment on lines +74 to +82

@field_validator("client_time")
def validate_ct(cls, ct: float):
return datetime.fromtimestamp(ct / 1000)

@field_serializer("client_time")
def serialize_ct(self, ct: datetime):
return int(ct.timestamp() * 1000)

Copy link
Contributor

Choose a reason for hiding this comment

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

so simple and clean.

@EandrewJones EandrewJones merged commit 6ef4dac into apache:master Jul 3, 2024
4 checks passed
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.

feat(NormalizeTimestamp): Normalize UserAle and arbitrary log timestamps to UTC
2 participants