-
Notifications
You must be signed in to change notification settings - Fork 92
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: Added cron specific endpoint #2153
Conversation
Looking over this I think we're good to merge this. I'll create some follow up tickets since not long after we'll likely also want to support |
@evanpurkhiser fwiw I did implement some parameters as query strings. Eg as implemented you can pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requesting changes, since I have still few questions I would like to clarify before merging this into the Relay.
@@ -6,6 +6,8 @@ | |||
|
|||
- Use different error message for empty strings in schema processing. ([#2151](https://github.com/getsentry/relay/pull/2151)) | |||
|
|||
- Relay now supports a simplified cron check-in API. ([#2153](https://github.com/getsentry/relay/pull/2153)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is the unnecessary new line before this record
.route("/api/cron/:monitor_slug/:sentry_key", cron::route(config)) | ||
.route("/api/cron/:monitor_slug/:sentry_key/", cron::route(config)) | ||
.route("/api/cron/:monitor_slug", cron::route(config)) | ||
.route("/api/cron/:monitor_slug/", cron::route(config)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have to support trailing /
and no trailing /
URLs? Have the routes without trailing slashes been already exposed to customers and customer got used to using them by now?
If not, IMO we have to keep our endpoints consistent, and steer the customers to use only one defined route. And currently we have /
at the end, which I would also lean to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I generally think, from a devex perspective, it's confusing to get errors for missing (or extra) slashes at the end of an URL. Although, I would have imagined we handle this in a cleaner way that adding both URL variants.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree would be nice to handle this in a more general way
@@ -479,6 +480,30 @@ fn auth_from_parts(req: &Parts, path_key: Option<String>) -> Result<Auth, BadEve | |||
auth = Some(header.parse::<Auth>()?); | |||
} | |||
|
|||
// try to get authentication info from basic auth | |||
if let Some(basic_auth) = req |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What the reason even to add basic auth?
Using basic auth is super confusion to me to be honest.
Especially when you look at the format users should use to make it work. And I talk about the part when you have yo prove the key (curl -u sentry_key:
) this colon after sentry_key
is super easy to miss and mess up your curl command. IMO it makes this very error-prone to the customer.
Much easier and more explicit way would be to use the header which we support or path param, which is also supported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're adding this as a bit of an experiment for crons to feel out the ergonomics and DX doing it this way.
I don't think we're planning to immediately tell customers to use this. I agree with the points you make though @olksdr, I think it's not unlikely this will get removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add the note here, which explains why this added and that this is just an experiment and will be removed in the follow-up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@olksdr fwiw I think basic auth should be generally supported, beyond this experiment, entirely independent of this. From the original x-sentry-auth
header basically nothing remains and we already support auth purely by ?sentry_key
in the URL. At this point I would honestly love to see us supporting just Bearer
and basic auth with just the public key.
cc @jan-auer
Ok(_) | Err(BadStoreRequest::RateLimited(_)) => (), | ||
Err(error) => return Err(error), | ||
}; | ||
// What do we want to return? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to have this comment here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@evanpurkhiser can we remove this comment? And return what you want to return? Or add a note here to followup and why the return value cannot be decided right now.
@olksdr Anything else you wanted to follow up with on this? @mitsuhiko I think we're good to go ahead and merge this in and start playing with it yeah? |
This is to support getsentry/relay#2153 Provdes a means to creating check-ins without giving a check_in_id in the consumer payload. Documentation for this is here getsentry/develop#950 Fixes: #49664
This is to support getsentry/relay#2153 Provdes a means to creating check-ins without giving a check_in_id in the consumer payload. Documentation for this is here getsentry/develop#950 Fixes: #49664
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left few comments.
Will approve to unblock you, if the open questions will be followed up on.
And also maybe @jan-auer wants also have a quick review
@@ -479,6 +480,30 @@ fn auth_from_parts(req: &Parts, path_key: Option<String>) -> Result<Auth, BadEve | |||
auth = Some(header.parse::<Auth>()?); | |||
} | |||
|
|||
// try to get authentication info from basic auth | |||
if let Some(basic_auth) = req |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add the note here, which explains why this added and that this is just an experiment and will be removed in the follow-up.
Ok(_) | Err(BadStoreRequest::RateLimited(_)) => (), | ||
Err(error) => return Err(error), | ||
}; | ||
// What do we want to return? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@evanpurkhiser can we remove this comment? And return what you want to return? Or add a note here to followup and why the return value cannot be decided right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left few comments.
Will approve to unblock you, if the open questions will be followed up on.
And also maybe @jan-auer wants also have a quick review
monitor_slug = "my-monitor" | ||
public_key = relay.get_dsn_public_key(project_id) | ||
basic_auth = base64.b64encode((public_key + ":").encode("utf-8")).decode("utf-8") | ||
relay.post( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed, this should be get
right @mitsuhiko ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The endpoint supports either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah cool. I'll expand on POST in a future PR.
Will follow up on your comments @olksdr Thanks! |
* master: (32 commits) feat(txname): Mark all URL transactions as sanitized (#2210) fix(profiles): Enforce profile quotas on metrics buckets (#2212) revert(spans): Move span metrics back to transactions namespace (#2206) instr(metrics): Add values to invalid metric errors (#2201) ref(spans): Move span metrics to spans namespace (#2205) chore(protocol): Add missing py/changelog entry for lock property (#2203) build(py): Move pytest.ini to tests directory (#2204) ref: Use serde collect_str to avoid allocations (#2149) chore(gocd): Auto approve deploy relay-pop on check success (#2200) test(document-pii): Fix flaky test (#2198) feat(spans): Extract transaction `user` into span's databag (#2197) feat(spans): Extract `release` tag from the transaction to the span (#2189) ref(metrics-extraction): Split span and transaction metric extraction (#2191) ref(crons): Support GET in the check-in endpoint (#2192) ref(spans): Introduce opinionated casing in span metrics (#2193) chore(py): Bump `requests` lib version (#2194) doc: document pii fields (#1972) feat: Added cron specific endpoint (#2153) feat(profiling): Extract app identifier from app context (#2172) feat(ci): Add CI-check for pop-deploys (#2184) ...
Implements a cron specific API endpoint. The
check_in_id
is changed to nullable in this. If acheck_in_id
is not supplied, the consumer will get the nilcheck_in_id
which is an alias for "latest". I decided not to tackle the base62 implementation, mostly because now that this reuses the generic infrastructure it might be quite confusing if we end up with different key formats.The URL format is also slightly different than in the original ticket. The following options are supported:
Work remaining:
latest
forcheck_in_id
processing
buildsFixes #2101
Fixes getsentry/sentry#49203