-
Notifications
You must be signed in to change notification settings - Fork 453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable metric integration test for req-blocking #2445
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,7 @@ | |
"shoppingcart", | ||
"struct", | ||
"Tescher", | ||
"testresults", | ||
"tracerprovider", | ||
"updown", | ||
"Zhongyang", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
# OTLP - Integration Tests | ||
This directory contains integration tests for `opentelemetry-otlp`. It uses | ||
[testcontainers](https://testcontainers.com/) to start an instance of the OTEL collector using [otel-collector-config.yaml](otel-collector-config.yaml), which then uses a file exporter per signal to write the output it receives back to the host machine. | ||
|
||
The tests connect directly to the collector on `localhost:4317` and `localhost:4318`, push data through, and then check that what they expect | ||
has popped back out into the files output by the collector. | ||
This directory contains integration tests for `opentelemetry-otlp`. It uses | ||
[testcontainers](https://testcontainers.com/) to start an instance of the OTEL | ||
collector using [otel-collector-config.yaml](otel-collector-config.yaml), which | ||
then uses a file exporter per signal to write the output it receives back to the | ||
host machine. | ||
|
||
The tests connect directly to the collector on `localhost:4317` and | ||
`localhost:4318`, push data through, and then check that what they expect has | ||
popped back out into the files output by the collector. | ||
|
||
## Pre-requisites | ||
|
||
For this to work, you need a couple of things: | ||
* Docker, for the test container | ||
* TCP/4317 and TCP/4318 free on your local machine. If you are running another collector, you'll need to stop it for the tests to run | ||
* TCP/4317 and TCP/4318 free on your local machine. If you are running another | ||
collector, you'll need to stop it for the tests to run. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ async fn init_metrics() -> SdkMeterProvider { | |
let exporter = create_exporter(); | ||
|
||
let reader = PeriodicReader::builder(exporter) | ||
.with_interval(Duration::from_millis(100)) | ||
.with_interval(Duration::from_millis(500)) | ||
.with_timeout(Duration::from_secs(1)) | ||
.build(); | ||
|
||
|
@@ -146,7 +146,7 @@ async fn setup_metrics_test() -> Result<()> { | |
println!("Running setup before any tests..."); | ||
*done = true; // Mark setup as done | ||
|
||
// Initialise the metrics subsystem | ||
// Initialize the metrics subsystem | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. US-English spelling strikes again 🤣 |
||
_ = init_metrics().await; | ||
} | ||
|
||
|
@@ -184,13 +184,13 @@ pub fn validate_metrics_against_results(scope_name: &str) -> Result<()> { | |
} | ||
|
||
/// | ||
/// TODO - the HTTP metrics exporters do not seem to flush at the moment. | ||
/// TODO - the HTTP metrics exporters except reqwest-blocking-client do not seem | ||
/// to work at the moment. | ||
/// TODO - fix this asynchronously. | ||
/// | ||
#[cfg(test)] | ||
#[cfg(not(feature = "hyper-client"))] | ||
#[cfg(not(feature = "reqwest-client"))] | ||
#[cfg(not(feature = "reqwest-blocking-client"))] | ||
mod tests { | ||
|
||
use super::*; | ||
|
@@ -293,7 +293,7 @@ mod tests { | |
// Set up the exporter | ||
let exporter = create_exporter(); | ||
let reader = PeriodicReader::builder(exporter) | ||
.with_interval(Duration::from_millis(100)) | ||
.with_interval(Duration::from_secs(30)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. putting a large interval here, to make sure the test is actually testing shutdown triggered exporting, not a timer triggered. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea |
||
.with_timeout(Duration::from_secs(1)) | ||
.build(); | ||
let resource = Resource::builder_empty() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the sleep is around 5 seconds, so 500 msec interval is fine, and this reduces the amount of internal logs.
Also, I am thinking if we should rely on force_flush/shutdown for integration tests more, to avoid this sleep requirement. We should still have one set of tests for testing the export triggered by interval.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we'll still need a bit of a buffer because of the flushing on the otlp-collector side? What I think what would be the nicest would be to setup a simple, short exponential backoff mechanism in here - the function knows what it is looking for for the particular test, so it's well positioned to decide to wait a bit and look again:
opentelemetry-rust/opentelemetry-otlp/tests/integration_test/tests/metrics.rs
Line 80 in 9011f63
so that we can use a tighter timing in the best case.
I've also added this
rotation
thing for logs, which I believe will decrease buffering on the collector side - doesn't help us with the other signals, though:opentelemetry-rust/opentelemetry-otlp/tests/integration_test/otel-collector-config.yaml
Lines 12 to 14 in 9011f63