{"id":25453162,"url":"https://github.com/nlopes/libhoney-rust","last_synced_at":"2025-04-09T21:20:16.455Z","repository":{"id":34898864,"uuid":"187007915","full_name":"nlopes/libhoney-rust","owner":"nlopes","description":"Rust library for sending data to Honeycomb","archived":false,"fork":false,"pushed_at":"2024-03-26T01:27:20.000Z","size":106,"stargazers_count":23,"open_issues_count":13,"forks_count":17,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-02T19:06:06.290Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nlopes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-16T10:42:49.000Z","updated_at":"2022-12-04T06:00:15.000Z","dependencies_parsed_at":"2025-02-25T03:10:42.045Z","dependency_job_id":"3eb21849-0d12-405b-a8c0-0074d82aaf7b","html_url":"https://github.com/nlopes/libhoney-rust","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nlopes%2Flibhoney-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nlopes%2Flibhoney-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nlopes%2Flibhoney-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nlopes%2Flibhoney-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nlopes","download_url":"https://codeload.github.com/nlopes/libhoney-rust/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248112229,"owners_count":21049620,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-17T23:49:29.402Z","updated_at":"2025-04-09T21:20:16.427Z","avatar_url":"https://github.com/nlopes.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n[![docs.rs](https://docs.rs/libhoney-rust/badge.svg)](https://docs.rs/libhoney-rust)\n[![crates.io](https://img.shields.io/crates/v/libhoney-rust.svg)](https://crates.io/crates/libhoney-rust)\n[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/nlopes/libhoney-rust/blob/master/LICENSE)\n[![Build Status](https://travis-ci.org/nlopes/libhoney-rust.svg?branch=master)](https://travis-ci.org/nlopes/libhoney-rust)\n\n# libhoney-rust\n\nRust library for sending data to [Honeycomb](https://www.honeycomb.io/).\n\nI'd be forever greatful if you can try it out and provide feedback. There are a few\nreasons why I think this may not yet be ready for production use:\n\n- Honeycomb uses the singleton pattern for the libraries but I decided not to use it here (mostly due to: harder to get right, it feels to me like a rust anti-pattern). If you think I should have, please let me know.\n\n- I'm not convinced of the threading code. Although \"it works\" it probably isn't great - any feedback would be greatly appreciated.\n\nFor these reasons, you're probably better waiting for a 1.0.0 release (I'll follow\n[semantic versioning][semantic versioning]). Having said that, if you still want to use\nthis, thank you for being brave, and make sure to open bugs against it!\n\n## libhoney\n\nRust library for sending events to Honeycomb, a service for debugging your software in\nproduction.\n\n- [Usage and Examples](#usage-and-examples)\n- [API Reference][API reference]\n\n## Usage and Examples\n\n### Initialization\n\nInitialize the library by passing in your Team API key and the default dataset name to\nwhich it should send events. When you call the library’s initialization routine, it spins\nup background threads to handle sending all the events. Calling .close() on the client\nwill terminate all background threads.\n\n```rust\nlet client = libhoney::init(libhoney::Config{\n  options: libhoney::client::Options {\n    api_key: \"YOUR_API_KEY\".to_string(),\n    dataset: \"honeycomb-rust-example\".to_string(),\n    ..libhoney::client::Options::default()\n  },\n  transmission_options: libhoney::transmission::Options::default(),\n});\n\nclient.close();\n```\n\nFurther configuration options can be found in the [API reference][API reference].\n\n### Building and Sending Events\n\nOnce initialized, the libhoney client is ready to send events. Events go through three\nphases:\n\n- Creation `event := builder.new_event()`\n- Adding fields `event.add_field(\"key\", Value::String(\"val\".to_string()))`, `event.add(data)`\n- Transmission `event.send(\u0026mut client)`\n\nUpon calling .send(), the event is dispatched to be sent to Honeycomb. All libraries set\ndefaults that will allow your application to function as smoothly as possible during error\nconditions.\n\nIn its simplest form, you can add a single attribute to an event with the `.add_field(k,\nv)` method. If you add the same key multiple times, only the last value added will be\nkept.\n\nMore complex structures (maps and structs—things that can be serialized into a JSON\nobject) can be added to an event with the .add(data) method.\n\nEvents can have metadata associated with them that is not sent to Honeycomb. This metadata\nis used to identify the event when processing the response. More detail about metadata is\nbelow in the Response section.\n\n### Handling responses\n\nSending an event is an asynchronous action and will avoid blocking by default. .send()\nwill enqueue the event to be sent as soon as possible (thus, the return value doesn’t\nindicate that the event was successfully sent). Use the Vec returned by .responses() to\ncheck whether events were successfully received by Honeycomb’s servers.\n\nBefore sending an event, you have the option to attach metadata to that event. This\nmetadata is not sent to Honeycomb; instead, it’s used to help you match up individual\nresponses with sent events. When sending an event, libhoney will take the metadata from\nthe event and attach it to the response object for you to consume. Add metadata by\npopulating the .metadata attribute directly on an event.\n\nResponses have a number of fields describing the result of an attempted event send:\n\n- `metadata`: the metadata you attached to the event to which this response corresponds\n\n- `status_code`: the HTTP status code returned by Honeycomb when trying to send the event. 2xx indicates success.\n\n- `duration`: the time.Duration it took to send the event.\n\n- `body`: the body of the HTTP response from Honeycomb. On failures, this body contains some more information about the failure.\n\n- `error`: when the event doesn’t even get to create a HTTP attempt, the reason will be in this field. (e.g. when sampled or dropped because of a queue overflow).\n\nYou don’t have to process responses if you’re not interested in them—simply ignoring them\nis perfectly safe. Unread responses will be dropped.\n\n### Examples\n\nHoneycomb can calculate all sorts of statistics, so send the data you care about and let\nus crunch the averages, percentiles, lower/upper bounds, cardinality—whatever you want—for\nyou.\n\n#### Simple: send an event\n```rust\n\nuse libhoney::FieldHolder; // Add trait to allow for adding fields\n// Call init to get a client\nlet mut client = init(libhoney::Config {\n  options: options,\n  transmission_options: libhoney::transmission::Options::default(),\n});\n\nlet mut data: HashMap\u003cString, Value\u003e = HashMap::new();\ndata.insert(\"duration_ms\".to_string(), json!(153.12));\ndata.insert(\"method\".to_string(), Value::String(\"get\".to_string()));\ndata.insert(\"hostname\".to_string(), Value::String(\"appserver15\".to_string()));\ndata.insert(\"payload_length\".to_string(), json!(27));\n\nlet mut ev = client.new_event();\nev.add(data);\n // In production code, please check return of `.send()`\nev.send(\u0026mut client).err();\n```\n\n[API reference]: https://docs.rs/libhoney-rust\n[semantic versioning]: https://semver.org\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnlopes%2Flibhoney-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnlopes%2Flibhoney-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnlopes%2Flibhoney-rust/lists"}