8000 feat(sessions): Basic session handling by mitsuhiko · Pull Request #178 · getsentry/sentry-native · GitHub
[go: up one dir, main page]

Skip to content

feat(sessions): Basic session handling #178

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

Merged
merged 39 commits into from
Mar 26, 2020
Merged

feat(sessions): Basic session handling #178

merged 39 commits into from
Mar 26, 2020

Conversation

mitsuhiko
Copy link
Contributor
@mitsuhiko mitsuhiko commented Mar 14, 2020

This doesn't do much yet but can become the start of proper session handling.

I believe we might want to persist session data to disk and read it back. I added some basic JSON parsing based on jsmn with some added ugly utf-8 handling.

@mitsuhiko mitsuhiko force-pushed the feature/sessions branch 7 times, most recently from 986cb91 to 26880de Compare March 14, 2020 20:13
@mitsuhiko mitsuhiko changed the title feat(sessions): WIP for session handling feat(sessions): Basic session handling Mar 15, 2020
size_t body_len = sentry__stringbuilder_len(&sb);
char *body = sentry__stringbuilder_into_string(&sb);
req = prepare_http_request(&event_id, endpoint_type,
"application/x-sentry-envelope", body, body_len, true);
Copy link
Member

Choose a reason for hiding this comment

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

hm, since we already require a sentry which can deal with envelopes, I was considering to massively simplify this (throwing out all the multipart handling), and basically make envelope 1 <-> 1 http request a 1:1 relation. but that is for the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't do that unfortunately because of different rate limits.

Copy link
Member

Choose a reason for hiding this comment

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

Just so I understand the intention correctly…

  • In the normal case, we want to drop events from capture_event on rate-limit, right?
  • Also, with the changes to capture_event, we attach the session to the captured envelope, and want to send it as different http requests for rate limiting purposes…
  • Then, on normal shutdown, we close the session and send it as its own envelope.

I wonder why we don’t just create a separate envelope for it?
Also since you mentioned raw envelopes, how should we proceed with that? I would personally prefer to still have a 1:1 relation between event->envelope->http request.

In any case, I think the rate limiting itself needs some work in the transports.

Copy link
Member

Choose a reason for hiding this comment

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

You can actually throw everything into one request, since Sentry enforces the rate limits per item (or, at least it will eventually). It seems that with the above logic that removes rate limited items from envelopes, this should work just fine.

There is just one final issue remaining with a size limit on the /store/ endpoint, but we can solve this fairly easily.


TEST_CHECK_INT_EQUAL(sentry__envelope_get_item_count(envelope), 1);

const sentry_envelope_item_t *item = sentry__envelope_get_item(envelope, 0);
Copy link
Member

Choose a reason for hiding this comment

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

maybe also add a second test to see what happens when you manually call capture_event

@mitsuhiko
Copy link
Contributor Author

Resolved most comments.

@Swatinem Swatinem requested a review from jan-auer March 19, 2020 11:09
Copy link
Member
@jan-auer jan-auer left a comment

Choose a reason for hiding this comment

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

Hope that we got everything 😅 Good stuff, pretty excited to get that merged 🎉

struct tm tm_buf;
tm = gmtime_r(&secs, &tm_buf);
#endif
size_t end = strftime(buf, sizeof buf, "%FT%T", tm);
Copy link
Member

Choose a reason for hiding this comment

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

@Amphaal So for some reason the mingw build returns 0 here, which means that the snprintf below overwrites the whole buffer, which in turn means that our tests are failing because of wrong time formatting here:
https://dev.azure.com/sentry-builds/sentry-native/_build/results?buildId=1789&view=logs&j=3e1f1b51-d184-5f5a-906a-d9e9ce13cd6b&t=372e633b-daac-5e1b-39f1-1bfa2728bd78
Do you have any quick idea about that?
I had a talk earlier with @jan-auer and given that none of us has the capacity to actually maintain this, and the problem that it just hangs and times out half of the builds on CI, and the builds generally being slower than all the other platforms.
We might just remove it from CI again, and demote it to kind of works, but we don’t actively maintain it status.

Copy link
Contributor

Choose a reason for hiding this comment

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

Giving the context, it's fully understandable. The only way to reduce build time would be to use a precompiled docker image paired with the adequate CI (like Jenkins or CircleCI, I do not believe Azure Pipelines can do that rn). And that LLVM linker bug is really annoying... I'm 100% with you on this one.

Copy link
Member

Choose a reason for hiding this comment

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

@Amphaal thanks for your contributions to this! In case you come around to find a good working solution, let us know and we can reenable builds again.

@Swatinem Swatinem merged commit c979eb7 into master Mar 26, 2020
@Swatinem Swatinem deleted the feature/sessions branch March 26, 2020 09:01
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.

4 participants
0