GithubHelp home page GithubHelp logo

Comments (8)

titanous avatar titanous commented on May 18, 2024

I'm quite happy with the explicitness of Send vs Report. I think the docs need to be more clear, but I don't think combining them makes much sense. In Go all of your underlying transports are going to be async to some extent, and 99% of users will use the HTTP transport, which is async.

from raven-go.

tylrtrmbl avatar tylrtrmbl commented on May 18, 2024

I can get behind that. Any purpose in keeping Report around then? If it's conventional for golang transports to be asynchronous by default we could probably get rid of it.

from raven-go.

titanous avatar titanous commented on May 18, 2024

Do you mean Send? Report is the async one. I'm okay with dropping Send if we provide a channel that returns an error value so that Report can optionally be used synchronously. The ID from the response should also be made accessible.

from raven-go.

tylrtrmbl avatar tylrtrmbl commented on May 18, 2024

I just figured out where some confusion is!

It's based the truthiness of these statements: "A synchronous send to Sentry waits for the HTTP response and parses the returned "id". An asynchronous send does not. Therefore, when you want the "id" you do a sync send, and when you don't you do an async send."

However, I'm not convinced that's the way to think about it, and I'm feeling thorough: I've got 2️⃣ reasons Sentry isn't built this way, 3️⃣ examples of it not being built that way, and 1️⃣ demonstrated behavior of why the 3 examples work. Buckle your seat belts. 😉

Sentry isn't built this way

  1. The docs don't actually encourage Reading the Response of anything but the status code
  2. UDP. UDP is a valid transport, and you don't get a response from sentry's UDP server

Examples of how the eventID is actually returned

  1. raven-python
  2. raven-php
  3. raven-csharp

The first two have a form of return $data['event_id']; where $data is what's passed to it, and the last one explicitly documents that the expected behavior is returning the request event_id, not the response's. The commit message reads: "Made the documentation in RavenClient.Capture methods explicit about using JsonPacket.EventID as its return value", though it admittedly doesn't do this: interestingly enough, the conflict was introduced by the same person on the same day. 😝 But it seems to be the consensus that you should return what you send, not what you receive.

Why this works

Sentry doesn't prevent duplicate IDs. No really! I made this change, and every response I got back from the Sentry server was the ID I sent it, even if it was a duplicate. In other words, like the docs say, you only need to read the response code from the response: the ID it sends back will always be the one you sent it:

tylrtrmbl:example % go run example.go http://<pubkey>:<pvtkey>@sentry.thenewtricks.com/4
{"id": "0123456789abcdef0123456789abcdef"}2013/12/27 14:39:54 sent packet successfully
tylrtrmbl:example % go run example.go http://<pubkey>:<pvtkey>@sentry.thenewtricks.com/4
{"id": "0123456789abcdef0123456789abcdef"}2013/12/27 14:40:02 sent packet successfully
tylrtrmbl:example % 

To conclude my novel

I think we should mimic raven-python's architecture, since it's basically the golden master template for a Sentry client and it works:

  1. Async is introduced by the transports, not the "send" methods
  2. You prepare for any kind of async transport by assuming you don't get a response - you parse your ID return value from the packet you send

This is exactly the way #2 works now, since our HTTP transport is async by default as given to us by the go std library. Whaddaya think, heavy reader? :bowtie:

Fin

from raven-go.

titanous avatar titanous commented on May 18, 2024

Okay, so clients generate the ID if they want it? We should probably add that.

I miscommunicated the asyncness of our current HTTP transport. The Send method on the transport is actually asynchronous, it is made async by the worker goroutine and the channel used in Report.

My inclination is to keep it close to the existing model of having the Send method on transports be blocking until a final error can be returned. This allows the synchronicity to be managed by the Client rather than creating two options (sync/async) for each of two protocols (HTTP/UDP).

from raven-go.

titanous avatar titanous commented on May 18, 2024

Hmm, we could do a wrapper transport that's async.

from raven-go.

titanous avatar titanous commented on May 18, 2024

Also solved by #2?

from raven-go.

tylrtrmbl avatar tylrtrmbl commented on May 18, 2024

Yeppers!

from raven-go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.