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

Feedback Wanted: Proposed API: SetWebRequest #78

Closed
willnewrelic opened this issue Dec 6, 2018 · 1 comment
Closed

Feedback Wanted: Proposed API: SetWebRequest #78

willnewrelic opened this issue Dec 6, 2018 · 1 comment

Comments

@willnewrelic
Copy link

willnewrelic commented Dec 6, 2018

Hi All,

For the next agent release, we are considering a new Transaction method called SetWebRequest. This method allow consumers to provide request information without having an *http.Request, or without having the request at the beginning of the Transaction. We're thinking it could look something like this:

type Transaction interface {
    // ... other methods

    // SetWebRequest adds request attributes and marks the transaction as a
    // web transaction.
    SetWebRequest(Request) error
}

// Request provides request information to Transaction.SetWebRequest.
type Request interface {
    Header() http.Header
    URL() *url.URL
    Method() string
    Transport() TransportType
}

What do you think?

It would be nice to allow consumers to provide a *http.Request to SetWebRequest. Possible ways of making this happen:

  1. We could change the Transaction.SetWebRequest parameter to an interface{} (which could be either a Request or a *http.Request). Unfortunately, this would lose strong type safety.

  2. We could have a func NewRequest(*http.Request) Request helper function do the necessary transformation. This would look something like this:

txn.SetWebRequest(newrelic.NewRequest(req))

What would be a better name for the NewRequest helper?

  1. Or we could have two Transaction methods: one which takes a Request and another which takes a *http.Request.

  2. We could change the Transaction.SetWebRequest parameter to an *http.Request, and ask consumers to convert their requests into *http.Request format. Is it easier to convert into a *http.Request, or to satisfy the Request interface? The Request interface makes it explicit which fields we will access, which is nice.

This will satisfy: #19

@willnewrelic willnewrelic changed the title Proposed API Feedback Wanted: SetWebRequest Feedback Wanted: Proposed API: SetWebRequest Dec 6, 2018
@willnewrelic
Copy link
Author

This functionality has now been released in 2.2.0!

Check it out!

https://godoc.org/github.com/newrelic/go-agent#WebRequest

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

No branches or pull requests

1 participant