Code Monkey home page Code Monkey logo

libhoney-rust's People

Contributors

andrewaylett avatar dependabot-preview[bot] avatar dependabot[bot] avatar fishrock123 avatar nlopes avatar poignardazur avatar ramosbugs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

libhoney-rust's Issues

Examples should be integration- or doctests

Currently, none of the code samples work right out of the box.

Rust offers two features that can be easily leveraged to ensure documentation is on-par with the current working changes:

  1. Implement examples as doc-tests
    Not much explanation needed here. Doc-tests can be set to compile only, or compile and run, depending on what the code does you'd want to choose between the two.

  2. Implement examples as integration tests
    This is a bit harder but will test that the library functionality stays working across branches. Integration tests can serve as excellent examples, as they touch upon most, if not all, of the functionality implemented by a library.

Both tests will need to run as a mandatory step in CI, so any braking changes can be fixed before getting merged.

I understand that this project is super-WIP, but having working documentation is crucial for on-boarding people to a library instead of driving them away

Dependabot can't resolve your Rust dependency files

Dependabot can't resolve your Rust dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

    Updating crates.io index
error: failed to select a version for the requirement `log = "= 0.4.10"`
  candidate versions found which didn't match: 0.4.8, 0.4.7, 0.4.6, ...
  location searched: crates.io index
required by package `libhoney-rust v0.1.3 (/home/dependabot/dependabot-updater/dependabot_tmp_dir

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependency versions locked too tightly

Per https://doc.rust-lang.org/cargo/faq.html#why-do-binaries-have-cargolock-in-version-control-but-not-libraries I see you've not got a Cargo.lock, but we're using the = requirements specifier for all our dependencies, which can still cause problems.

My specific issue is that the new 2.0.0 release of actix-web depends on a strictly later version of serde, meaning that my project can't now contain both the new release of actix-web and libhoney-rust.

Can we relax the dependencies to caret dependencies, and trust semver to do the right thing unless proven otherwise?

cargo update blew up a few tests

running 15 tests
test builder::tests::test_builder_add ... ok
test builder::tests::test_builder_add_conflict ... ok
test client::tests::test_flush ... FAILED
test client::tests::test_init ... ok
test client::tests::test_send_without_api_key ... ok
test event::tests::test_add ... ok
test event::tests::test_empty ... ok
test event::tests::test_send ... FAILED
test tests::test_init ... ok
test transmission::tests::test_bad_response ... FAILED
test transmission::tests::test_defaults ... ok
test transmission::tests::test_metadata ... FAILED
test transmission::tests::test_modifiable_defaults ... ok
test transmission::tests::test_multiple_batches ... FAILED
test transmission::tests::test_responses ... FAILED

failures:

---- client::tests::test_flush stdout ----
thread 'main' panicked at 'assertion failed: (left == right)
left: None,
right: Some(202)', src/client.rs:197:9
note: Run with RUST_BACKTRACE=1 environment variable to display a backtrace.

---- event::tests::test_send stdout ----
thread 'main' panicked at 'assertion failed: (left == right)
left: None,
right: Some(200)', src/event.rs:216:13

---- transmission::tests::test_bad_response stdout ----
thread 'main' panicked at 'assertion failed: (left == right)
left: None,
right: Some(400)', src/transmission.rs:620:13

---- transmission::tests::test_metadata stdout ----
thread 'main' panicked at 'assertion failed: (left == right)
left: None,
right: Some(202)', src/transmission.rs:513:13

---- transmission::tests::test_multiple_batches stdout ----
thread 'main' panicked at 'assertion failed: (left == right)
left: None,
right: Some(202)', src/transmission.rs:578:9

---- transmission::tests::test_responses stdout ----
thread 'main' panicked at 'assertion failed: (left == right)
left: None,
right: Some(202)', src/transmission.rs:470:13

failures:
client::tests::test_flush
event::tests::test_send
transmission::tests::test_bad_response
transmission::tests::test_metadata
transmission::tests::test_multiple_batches
transmission::tests::test_responses

test result: FAILED. 9 passed; 6 failed; 0 ignored; 0 measured; 0 filtered out

Consider using async channels instead of `crossbeam`

I was following the issue here eaze/tracing-honeycomb#9, and it seems that some environments are having issues with this library (I myself am not one of these currently). There is a fork of this library that uses async channels (https://github.com/agrinman/libhoney-rust) and this has resolved those issues for some.

Additionally, it just seems like the more cohesive approach would be to use async channels because this library is built on async anyway.

Please bump version number on crates.io

Latest version released is 0.1.6, but this version change is still stuck at reqwest 0.10.10 which itself is stick at tokio 0.2 which is incompatible with current tokio versions.

This repo's Cargo.toml has been updated to newer reqwest, but the version on crates.io does not reflect this.

Dependabot can't resolve your Rust dependency files

Dependabot can't resolve your Rust dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

    Updating crates.io index
error: failed to select a version for the requirement `log = "= 0.4.10"`
  candidate versions found which didn't match: 0.4.8, 0.4.7, 0.4.6, ...
  location searched: crates.io index
required by package `libhoney-rust v0.1.3 (/home/dependabot/dependabot-updater/dependabot_tmp_dir

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Rust dependency files

Dependabot can't resolve your Rust dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

    Updating crates.io index
error: failed to select a version for the requirement `log = ">= 0.4.10"`
  candidate versions found which didn't match: 0.4.8, 0.4.7, 0.4.6, ...
  location searched: crates.io index
required by package `libhoney-rust v0.1.3 (/home/dependabot/dependabot-updater/dependabot_tmp_dir

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

transmission freezes when response channel is full

Description

We noticed an issue where the response channel will fill up and freeze the transmission if responses are not consumed.

A send call is used to send information to the response channel. It seems that the response channel is a bounded crossbeam-channel, so the sender's send function will block if the channel is full.

With a default sized channel, this occurs after 40000 events.

Meanwhile, the README states:

You don’t have to process responses if you’re not interested in them—simply ignoring them is perfectly safe. Unread responses will be dropped.

Code

response_sender
.send(Response {
status_code: None,
body: None,
duration: clock.elapsed(),
metadata: event.metadata,
error: Some(e.to_string()),
})

History

The bug seems to originate in this commit: 2f004da

Potential ideas

I would propose a solution where everything regarding the responses is put behind a feature flag and then explicitly state that you must consume the response channel if you activate the feature.

I would be happy to implement a fix.
Just let me know if you think the proposed idea would be a good fit for this project.

[feat] Interface for waiting on flush to complete

The current client flush interface causes an asynchronous flush:

libhoney-rust/src/client.rs

Lines 122 to 133 in 2f7cdc8

/// flush closes and reopens the Transmission, ensuring events are sent without
/// waiting on the batch to be sent asyncronously. Generally, it is more efficient to
/// rely on asyncronous batches than to call Flush, but certain scenarios may require
/// Flush if asynchronous sends are not guaranteed to run (i.e. running in AWS Lambda)
/// Flush is not thread safe - use it only when you are sure that no other parts of
/// your program are calling Send
pub fn flush(&mut self) -> Result<()> {
info!("flushing libhoney client");
self.transmission.stop()?;
self.transmission.start();
Ok(())
}

That function returns once the stop event has been queued and the new worker has been spawned. It would be useful to have this interface (or another) return a future that callers can wait on in order to determine when the original queue has been emptied.

An example use case is for a serverless (AWS Lambda) function, where we need to flush the events to Honeycomb before the Lambda runtime suspends the execution environment until the next function invocation.

A straightforward solution would be for stop to create a oneshot channel and pass the sender into the stop_event, and return a future that waits on the receiver. The stop event handler can then send to the channel when it's done flushing. I'd be happy to contribute a PR to do this (I need it pretty badly for a project) if that approach seems reasonable or if there's another approach you'd prefer!

Queued events are ignored when flushing client

The client flush method is implemented in terms of stopping and restarting the Transmission:

libhoney-rust/src/client.rs

Lines 122 to 133 in 2f7cdc8

/// flush closes and reopens the Transmission, ensuring events are sent without
/// waiting on the batch to be sent asyncronously. Generally, it is more efficient to
/// rely on asyncronous batches than to call Flush, but certain scenarios may require
/// Flush if asynchronous sends are not guaranteed to run (i.e. running in AWS Lambda)
/// Flush is not thread safe - use it only when you are sure that no other parts of
/// your program are calling Send
pub fn flush(&mut self) -> Result<()> {
info!("flushing libhoney client");
self.transmission.stop()?;
self.transmission.start();
Ok(())
}

Unfortunately, the stop event causes a break that breaks out of the loop and doesn't send any of the queued events:

if event.fields.contains_key("internal_stop_event") {
info!("got 'internal_stop_event' event");
break;
}

I think the code should probably jump to this line instead of breaking out of the loop:

let mut batches_sent = Vec::new();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.