Struct honeybadger::ConfigBuilder[][src]

pub struct ConfigBuilder { /* fields omitted */ }

Configuration builder struct, used for building a Config instance

Methods

impl ConfigBuilder
[src]

Construct a ConfigBuilder to parametrize the Honeybadger client.

ConfigBuilder is populated using environment variables, which will inject Honeybadger event fields:

  • HONEYBADGER_ROOT - project root for each event.
  • ENV - environment name for each event.
  • HOSTNAME - host name for each event.
  • HONEYBADGER_ENDPOINT - override the default endpoint for the HTTPS client.
  • HONEYBADGER_TIMEOUT - write timeout for the Honeybadger HTTPS client.

Arguments

  • api_token - API key for the honeybadger project

Example

let api_token = "ffffff";
let config = ConfigBuilder::new(api_token);

Override the project root property for events posted to the Honeybadger API. Consumes the ConfigBuilder and returns a new value.

Arguments

  • project_root - The directory where your code lives.

Example

let api_token = "ffffff";
let config = ConfigBuilder::new(api_token).with_root("/tmp/my_project_root");

Add an environment name property for events posted to the Honeybadger API, which will then be categorized accordingly in the UI. Consumes the ConfigBuilder and returns a new value.

Arguments

  • environment - The directory where your code lives.

Example

let api_token = "ffffff";
let config = ConfigBuilder::new(api_token).with_env("production");

Override the hostname property for events posted to the Honeybadger API. Consumes the ConfigBuilder and returns a new value.

Arguments

  • hostname - The server's hostname

Example

let api_token = "ffffff";
let config = ConfigBuilder::new(api_token).with_hostname("localhost");

Override the Honeybadger endpoint used to post HTTP payloads. Consumes the ConfigBuilder and returns a new value.

Arguments

  • endpoint - A custom honeybadger endpoint to query

Example

let api_token = "ffffff";
let config = ConfigBuilder::new(api_token).with_endpoint("http://proxy.example.com:5050/");

Override the HTTP write timeout for the client used to post events to Honeybadger. Consumes the ConfigBuilder and returns a new value.

Arguments

  • timeout - A Duration reference specifying the HTTP timeout for the write request

Example

let api_token = "ffffff";
let config = ConfigBuilder::new(api_token).with_timeout(&Duration::new(20, 0));

Override the number of threads the async HTTP connection should use to queue Honeybadger payloads. Consumes the ConfigBuilder and returns a new reference.

Arguments

  • threads - The number of threads to configure the hyper connector

Example

let api_token = "ffffff";
let config = ConfigBuilder::new(api_token).with_threads(8);

Prepare a Config instance for constructing a Honeybadger instance.

Defaults are set if the ConfigBuilder used to construct the Config is empty.

  • default root: the current directory
  • default hostname: the host name as reported by the operating system
  • default endpoint: https://api.honeybadger.io/v1/notices
  • default timeout: a 5 second client write timeout
  • default threads: 4 threads are used in the asynchronous runtime pool

Example

ConfigBuilder::new(api_token).build();

Auto Trait Implementations