Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
239baaf
working
DanielLacina Jun 26, 2026
59c3f41
working
DanielLacina Jun 26, 2026
6911fba
figuring out how spans work
DanielLacina Jun 26, 2026
3979b0b
merged branch into db_v4
DanielLacina Jul 9, 2026
8474e09
working
DanielLacina Jul 9, 2026
3d1aac9
working on making the code developer friendly
DanielLacina Jul 10, 2026
0678121
created 3 open telemetry tests where each test corresponds to one of …
DanielLacina Jul 10, 2026
fa34b60
merge branch
DanielLacina Jul 11, 2026
745de1a
finished open telemetry span tests except there's an issue when runni…
DanielLacina Jul 12, 2026
9a70aa7
switch to single exporters for testing
DanielLacina Jul 13, 2026
1cabb7f
fixing up tests
DanielLacina Jul 13, 2026
bcf8e0c
fixed logging and span issues with tests
DanielLacina Jul 14, 2026
78f96f7
got rid of debug assertion
DanielLacina Jul 14, 2026
e1a58e8
enable dev dependency raphtory-graphql default-feature to false
DanielLacina Jul 14, 2026
ce64a26
enable dev dependency raphtory-graphql default-feature to false
DanielLacina Jul 14, 2026
dd44c2f
merged into db_v4
DanielLacina Jul 14, 2026
cd032b3
Update raphtory-graphql/Cargo.toml
DanielLacina Jul 14, 2026
818c414
added comment
DanielLacina Jul 14, 2026
2c661b0
Merge branch 'open_telemetry_tests' of https://github.com/DanielLacin…
DanielLacina Jul 14, 2026
225f045
made exporters reusable across multiple tracing tests
DanielLacina Jul 14, 2026
a5ae2ac
added open telemetry end to end test
DanielLacina Jul 14, 2026
7cfc354
add comments and semantics to make the code more interpretable and re…
DanielLacina Jul 15, 2026
85ed554
format code
DanielLacina Jul 15, 2026
23f8e50
Update raphtory-graphql/tests/open_telemetry.rs
DanielLacina Jul 15, 2026
e21accb
Update raphtory-graphql/tests/open_telemetry.rs
DanielLacina Jul 15, 2026
1395129
Update raphtory-graphql/src/server.rs
DanielLacina Jul 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 114 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions raphtory-graphql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,15 @@ tempfile = { workspace = true }
pretty_assertions = { workspace = true }
arrow = { workspace = true }
parquet = { workspace = true }
# Self-reference lets cargo test compile this crate with the `integration-test` feature enabled.
raphtory-graphql = { workspace = true, default-features = false, features = ["integration-test"] }
opentelemetry_sdk = { version = "0.32.1", features = ["rt-tokio", "testing"] }
mock-collector = "0.2"

[features]
default = []
vectors = ["raphtory/vectors"]
integration-test = []
python = ["dep:pyo3", "dep:pythonize", "raphtory/python"]
search = ["raphtory/search"]
panic-on-drop = ["raphtory/panic-on-drop"]
69 changes: 68 additions & 1 deletion raphtory-graphql/src/config/otlp_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use opentelemetry_appender_tracing::layer::{
OpenTelemetryTracingBridge, OpenTelemetryTracingBridgeBuilder,
};
use opentelemetry_otlp::{LogExporter, Protocol, SpanExporter, WithExportConfig, WithHttpConfig};
#[cfg(feature = "integration-test")]
use opentelemetry_sdk::{logs::InMemoryLogExporter, trace::InMemorySpanExporter};
use opentelemetry_sdk::{
logs::SdkLoggerProvider,
trace::{Sampler, SdkTracerProvider},
Expand All @@ -15,7 +17,9 @@ use opentelemetry_sdk::{
use raphtory_api::core::storage::arc_str::OptionAsStr;
use reqwest::{blocking::ClientBuilder, Certificate};
use serde::Deserialize;
use std::{collections::HashMap, env, fs::File, io::Read, path::PathBuf, time::Duration};
use std::{
collections::HashMap, env, fs::File, io::Read, path::PathBuf, sync::LazyLock, time::Duration,
};
use strum::IntoEnumIterator;
use strum_macros::{Display, EnumIter, EnumString, IntoStaticStr};

Expand Down Expand Up @@ -80,6 +84,8 @@ pub enum TracingProtocol {
TONIC,
HTTP,
STDOUT,
#[cfg(feature = "integration-test")]
IN_MEMORY,
}

impl TryFrom<String> for TracingProtocol {
Expand Down Expand Up @@ -109,6 +115,28 @@ pub const DEFAULT_OTLP_TRANSPORT_PROTOCOL: TracingProtocol = TracingProtocol::TO
pub const DEFAULT_OTLP_AGENT_PORT_TONIC: u16 = 4317;
pub const DEFAULT_OTLP_TRACING_SERVICE_NAME: &'static str = "Raphtory";

#[cfg(feature = "integration-test")]
// in-memory exporters to retrieve spans and logs in tests.
#[derive(Clone)]
pub struct GlobalExporters {
pub span: InMemorySpanExporter,
pub log: InMemoryLogExporter,
}

#[cfg(feature = "integration-test")]
/* GraphServer registers span and log exporters
across the entire process, which can conflict
when starting up servers with their own exporters.
Making in-memory exporters global allows them to be
initialized once and reused across multiple tests
allowing the tests to retrieve spans and logs
without conflicts.
*/
pub static GLOBAL_EXPORTERS: LazyLock<GlobalExporters> = LazyLock::new(|| GlobalExporters {
span: InMemorySpanExporter::default(),
log: InMemoryLogExporter::default(),
});

#[derive(Clone, Deserialize, Debug, PartialEq, serde::Serialize, FieldName)]
pub struct TracingConfig {
pub enabled: bool,
Expand Down Expand Up @@ -163,6 +191,34 @@ impl TracingConfig {
(tracer, logger)
}

#[cfg(feature = "integration-test")]
fn with_simple_exporter<
E: opentelemetry_sdk::trace::SpanExporter + 'static,
L: opentelemetry_sdk::logs::LogExporter + 'static,
>(
&self,
span_exporter: E,
log_exporter: L,
) -> (SdkTracerProvider, SdkLoggerProvider) {
let resource = Resource::builder()
.with_attributes(vec![KeyValue::new(
"service.name",
self.service_name.clone(),
)])
.build();
let tracer = SdkTracerProvider::builder()
.with_simple_exporter(span_exporter)
.with_sampler(Sampler::AlwaysOn)
.with_resource(resource.clone())
.build();

let logger = SdkLoggerProvider::builder()
.with_simple_exporter(log_exporter)
.with_resource(resource)
.build();
(tracer, logger)
}

pub async fn tracer_provider(
&self,
) -> Result<Option<(SdkTracerProvider, SdkLoggerProvider)>, ServerError> {
Expand Down Expand Up @@ -265,6 +321,17 @@ impl TracingConfig {
opentelemetry_stdout::LogExporter::default(),
))
}
#[cfg(feature = "integration-test")]
TracingProtocol::IN_MEMORY => {
eprintln!(
"Sending traces to in-memory exporter with tracing level `{}`",
self.level
);
Ok(self.with_simple_exporter(
GLOBAL_EXPORTERS.span.clone(),
GLOBAL_EXPORTERS.log.clone(),
))
}
};

match providers {
Expand Down
Loading
Loading