# Instrument HTTP Requests | Sentry for Rails

As a prerequisite to setting up [Requests](https://docs.sentry.io/product/insights/backend/requests.md), you’ll need to first [set up performance monitoring](https://docs.sentry.io/platforms/ruby/guides/rails/tracing.md). Once this is done, the Ruby SDK will automatically instrument outgoing HTTP requests made via `Net::HTTP`. If that doesn't fit your use case, you can set up using [custom instrumentation](https://docs.sentry.io/platforms/ruby/guides/rails/tracing/instrumentation/custom-instrumentation/requests-module.md#custom-instrumentation).

## [Custom Instrumentation](https://docs.sentry.io/platforms/ruby/guides/rails/tracing/instrumentation/custom-instrumentation/requests-module.md#custom-instrumentation)

For detailed information about which data can be set, see the [Requests Module developer specifications](https://develop.sentry.dev/sdk/performance/modules/requests/).

### [Wrap HTTP Requests in a Span](https://docs.sentry.io/platforms/ruby/guides/rails/tracing/instrumentation/custom-instrumentation/requests-module.md#wrap-http-requests-in-a-span)

NOTE: Refer to [HTTP Span Data Conventions](https://develop.sentry.dev/sdk/performance/span-data-conventions/#http) for a full list of the span data attributes.

Here is an example of an instrumented function that makes HTTP requests:

```ruby
require 'uri'

def make_request(method, url)
  Sentry.with_child_span(op: 'http.client', description: "#{method} #{url}") do |span|
    span.set_data('http.request.method', method)

    parsed_url = URI.parse(url)
    span.set_data('url', url)
    span.set_data('server.address', parsed_url.hostname)
    span.set_data('server.port', parsed_url.port)

    # make your custom HTTP request
    response = do_request(method: method, url: url)

    span.set_data('http.response.status_code', response.status_code)
    span.set_data('http.response_content_length', response.headers['content-length'])

    response
  end
end
```
