Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions .changesets/config_telemetry_config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### Add basic config file options to otel telemetry - @swcollard PR #330

Adds new Configuration options for setting up configuration beyond the standard OTEL environment variables needed before.

* Renames trace->telemetry
* Adds OTLP options for metrics and tracing to choose grpc or http upload protocols and setting the endpoints
* This configuration is all optional, so by default nothing will be logged
23 changes: 23 additions & 0 deletions Cargo.lock

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

8 changes: 7 additions & 1 deletion crates/apollo-mcp-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ jwks = "0.4.0"
lz-str = "0.2.1"
opentelemetry = "0.30.0"
opentelemetry-appender-log = "0.30.0"
opentelemetry-otlp = "0.30.0"
opentelemetry-otlp = { version = "0.30.0", features = [
"grpc-tonic",
"tonic",
"http-proto",
"metrics",
"trace",
] }
opentelemetry-resource-detectors = "0.9.0"
opentelemetry-semantic-conventions = "0.30.0"
opentelemetry-stdout = "0.30.0"
Expand Down
40 changes: 20 additions & 20 deletions crates/apollo-mcp-server/src/graphql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,27 +447,27 @@ mod test {
.find(|scope_metrics| scope_metrics.scope().name() == "apollo.mcp")
{
for metric in scope_metrics.metrics() {
if metric.name() == "apollo.mcp.operation.count" {
if let AggregatedMetrics::U64(MetricData::Sum(data)) = metric.data() {
for point in data.data_points() {
let attributes = point.attributes();
let mut attr_map = std::collections::HashMap::new();
for kv in attributes {
attr_map.insert(kv.key.as_str(), kv.value.as_str());
}
assert_eq!(
attr_map.get("operation.id").map(|s| s.as_ref()),
Some("mock_operation")
);
assert_eq!(
attr_map.get("operation.type").map(|s| s.as_ref()),
Some("persisted_query")
);
assert_eq!(
attr_map.get("success"),
Some(&std::borrow::Cow::Borrowed("false"))
);
if metric.name() == "apollo.mcp.operation.count"
&& let AggregatedMetrics::U64(MetricData::Sum(data)) = metric.data()
{
for point in data.data_points() {
let attributes = point.attributes();
let mut attr_map = std::collections::HashMap::new();
for kv in attributes {
attr_map.insert(kv.key.as_str(), kv.value.as_str());
}
assert_eq!(
attr_map.get("operation.id").map(|s| s.as_ref()),
Some("mock_operation")
);
assert_eq!(
attr_map.get("operation.type").map(|s| s.as_ref()),
Some("persisted_query")
);
assert_eq!(
attr_map.get("success"),
Some(&std::borrow::Cow::Borrowed("false"))
);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/apollo-mcp-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async fn main() -> anyhow::Result<()> {
None => runtime::read_config_from_env().unwrap_or_default(),
};

let _guard = runtime::trace::init_tracing_subscriber(&config)?;
let _guard = runtime::telemetry::init_tracing_subscriber(&config)?;

info!(
"Apollo MCP Server v{} // (c) Apollo Graph, Inc. // Licensed under MIT",
Expand Down
7 changes: 6 additions & 1 deletion crates/apollo-mcp-server/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mod operation_source;
mod overrides;
mod schema_source;
mod schemas;
pub mod trace;
pub mod telemetry;

use std::path::Path;

Expand Down Expand Up @@ -243,6 +243,11 @@ mod test {
path: None,
rotation: Hourly,
},
telemetry: Telemetry {
exporters: None,
service_name: None,
version: None,
},
operations: Infer,
overrides: Overrides {
disable_type_description: false,
Expand Down
5 changes: 4 additions & 1 deletion crates/apollo-mcp-server/src/runtime/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use url::Url;

use super::{
OperationSource, SchemaSource, endpoint::Endpoint, graphos::GraphOSConfig,
introspection::Introspection, logging::Logging, overrides::Overrides,
introspection::Introspection, logging::Logging, overrides::Overrides, telemetry::Telemetry,
};

/// Configuration for the MCP server
Expand Down Expand Up @@ -40,6 +40,9 @@ pub struct Config {
/// Logging configuration
pub logging: Logging,

/// Telemetry configuration
pub telemetry: Telemetry,

/// Operations
pub operations: OperationSource,

Expand Down
Loading