-
Notifications
You must be signed in to change notification settings - Fork 62
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
Allow different days as start of the week #263
Comments
I am wondering if we could use the ISO 8601 Time intervals for this? |
I'm also in support of using ISO 8601 time-intervals for this. I'm not sure if this is the intended way to use the spec, but I was thinking of something like follows (I assume @weyert might also be thinking along the same lines, if not please correct me here). If we want a weekly time window that starts on a wednesday we could potentially do something like:
@alexewerlof do you see a use case which will not be fulfilled with the above approach (assuming this is intended way) |
@anoopknayak yeah I'm aware of that format. The general format for specifying repeating periods in ISO 8601 is:
AdvantageCompliance: no need to reinvent the wheel. Sticking to the standard means that we can potentially benefit from the wider ecosystem that can parse, lint, and generate this format. Moreover, it keep the OpenSLO standard shorter because we can just refer to ISO 8601. DisadvantageHarder to read: It requires some mental gymnastics and lookup the date and see which day of the week it is (2024-06-19 is a Wednesday), and then reason about the implicit behavior that if the date starts in the middle of the week, that day of the week is considered as the start of the period going forward. One could refer to the documentation for that to know that behavior, but I believe the whole point of YAML is to make it human-readable and I'm not sure if this format with those 2 extra steps is immediately approachable and intuitive. It works, but probably we could do better. So if we want to specify weekly periods starting from Subjectively, harder to read, but due to the advantages above, it might be better than my initial suggestion? Note: |
In the group discussion today we agreed that we don't change the spec but rather be more specific with an example about how it's done. For this use case, we can mention:
e.g: if the start date is 2024-10-09 which is a Wednesday, this means a calendar-bound config of |
Problem to solve
Most countries consider Monday the start of the week:
The current OpenSLO spec for
timeWindow
doesn't acknowledge that nuance for "calendar–aligned time window".Proposal
I've been building another OSS tool that faced this same challenge.
I went for:
Where the string can be
w
for week-bound,m
for month-bound,q
for quarter-bound, andy
for year-bound.For week, one can add an extra number to specify which exact day is the start:
w0
start the week on Sundayw1
start the week on Mondayw6
start the week on SaturdayThe reason I went with those exact numbers is because my tool is built in JS and this is how Javascript works (which is the reason I looked into seeing how OpenSLO solves this problem).
One could use the english day names (e.g.,
w-monday
) or a shorthand (e.g.,w-mo
) but there's another use case which fits beautifully to the number-annotation: month-aligned time windows.Suppose a SLO window needs to always start on the second day of the month. In my tool, it is indicated like this:
m2
(why not start from zero? You guessed it! That's how Javascript works) 😄Anyway, I'm not suggesting that OpenSLO should be using the same syntax as my code, but I hope we can agree that the need exists and we need to have a way to configure it:
Further details
To annotate a specific date, I suggest to use a number instead of the English name for the days (e.g.
1
instead ofmonday
).If
N
is the numerical value indicating the day of the week, it can map to a lookup table like this:w:0
w:1
w:2
w:3
w:4
w:5
w:6
Some other notable alternatives:
w(N)
w-N
wN
w_N
w::N
Month
By extension, it'd be great if we could have a way to specify a date other than the first day of the month as the start of the compliance period.
For example
m+2
could mean the second day of the month andm-10
could mean 10 days before the current month ends.The latter can be useful for systems that work with payroll where the majority of transactions happen on the last few days of the month.
This is just an idea. But my suggestion is to think about the month also, when finding a solution for the week.
Links / references
The text was updated successfully, but these errors were encountered: