opengleametry_test
import gleam/dict
import gleeunit
import opengleametry/span
import opengleametry_test
pub fn main() {
opengleametry_test.reconfigure_opentelemetry()
gleeunit.main()
}
pub fn a_test() {
opengleametry_test.set_self_as_exporter_pid()
{
use _ctx <- span.with("hello", [#("zapf", "dingbat")])
Nil
}
assert opengleametry_test.receive_attributes(123, "hello")
== Ok(#(opengleametry_test.OkStatus, dict.from_list([#("zapf", "dingbat")])))
}
The full span as this test package receives under the hood is of no interest. The status and attributes should do.
The function takes a name
argument, so you do not need to receive
all spans. Beware that spans will linger in the inbox of your test
process you may receive spans by name from an earlier test!
Special Note
Part of the output is this:
=WARNING REPORT==== 6-Sep-2025::21:30:55.530928 ===
OTLP exporter failed to initialize with exception throw:{application_either_not_started_or_not_ready,
tls_certificate_check}
=== opengleametry_test does not care about opentelemetry_exporter
=== opengleametry_test will now stop opentelemetry and configure+restart
it to direct spans to the current process.
=INFO REPORT==== 6-Sep-2025::21:30:55.645980 ===
application: opentelemetry
exited: stopped
type: temporary
Gleam launches all dependent apps. That includes:
opentelemetry
on which this package depends. We must reconfigure it. That is what the first line inmain
does. We print a warning and then a supervisor reports on what we are doing.opentelemetry_exporter
if your package depends on it (very likely). This produces the top warning. We do not care, we do not need it for this package, but it is not in the way afteropentelemetry
was reconfigured.