# `Appsignal.Instrumentation`
[🔗](https://github.com/appsignal/appsignal-elixir/blob/v2.17.4/lib/appsignal/instrumentation.ex#L1)

# `instrument`

```elixir
@spec instrument(String.t(), function()) :: any()
```

Instrument a function.

    def call do
      Appsignal.instrument("foo.bar", fn ->
        :timer.sleep(1000)
      end)
    end

When passing a function that takes an argument, the function is called with
the created span to allow adding extra information.

    def call(params) do
      Appsignal.instrument("foo.bar", fn span ->
        Appsignal.Span.set_sample_data(span, "params", params)
        :timer.sleep(1000)
      end)
    end

# `instrument`

```elixir
@spec instrument(String.t(), String.t(), function()) :: any()
```

Instrument a function, and set the `"appsignal:category"` attribute to the
value passed as the `category` argument.

# `instrument`

> This function is deprecated. Use Appsignal.instrument/3 instead..

# `send_error`

```elixir
@spec send_error(Exception.t(), Exception.stacktrace()) :: Appsignal.Span.t() | nil
```

Send an error in a newly created `Appsignal.Span`.

# `send_error`

```elixir
@spec send_error(Exception.t(), Exception.stacktrace(), function()) ::
  Appsignal.Span.t() | nil
@spec send_error(Exception.kind(), any(), Exception.stacktrace()) ::
  Appsignal.Span.t() | nil
```

Send an error in a newly created `Appsignal.Span`. Calls the passed function
with the created `Appsignal.Span` before closing it.

# `send_error`

# `set_error`

```elixir
@spec set_error(Exception.t(), Exception.stacktrace()) :: Appsignal.Span.t() | nil
```

Set an error in the current root span.

# `set_error`

```elixir
@spec set_error(Exception.kind(), any(), Exception.stacktrace()) ::
  Appsignal.Span.t() | nil
```

Set an error in the current root span by passing a `kind` and `reason`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
