Skip to content

Commit 9f421b1

Browse files
authored
Merge pull request #319 from apollographql/feature/telemetry
feat: Open Telemetry Integration
2 parents f54463e + 1fb1b30 commit 9f421b1

35 files changed

+2480
-371
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
### Add basic config file options to otel telemetry - @swcollard PR #330
2+
3+
Adds new Configuration options for setting up configuration beyond the standard OTEL environment variables needed before.
4+
5+
* Renames trace->telemetry
6+
* Adds OTLP options for metrics and tracing to choose grpc or http upload protocols and setting the endpoints
7+
* This configuration is all optional, so by default nothing will be logged
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
### feat: adding ability to omit attributes for traces and metrics - @alocay PR #358
2+
3+
Adding ability to configure which attributes are omitted from telemetry traces and metrics.
4+
5+
1. Using a Rust build script (`build.rs`) to auto-generate telemetry attribute code based on the data found in `telemetry.toml`.
6+
2. Utilizing an enum for attributes so typos in the config file raise an error.
7+
3. Omitting trace attributes by filtering it out in a custom exporter.
8+
4. Omitting metric attributes by indicating which attributes are allowed via a view.
9+
5. Created `telemetry_attributes.rs` to map `TelemetryAttribute` enum to a OTEL `Key`.
10+
11+
The `telemetry.toml` file includes attributes (both for metrics and traces) as well as list of metrics gathered. An example would look like the following:
12+
```
13+
[attributes.apollo.mcp]
14+
my_attribute = "Some attribute info"
15+
16+
[metrics.apollo.mcp]
17+
some.count = "Some metric count info"
18+
```
19+
This would generate a file that looks like the following:
20+
```
21+
/// All TelemetryAttribute values
22+
pub const ALL_ATTRS: &[TelemetryAttribute; 1usize] = &[
23+
TelemetryAttribute::MyAttribute
24+
];
25+
#[derive(Debug, ::serde::Deserialize, ::schemars::JsonSchema,, Clone, Eq, PartialEq, Hash, Copy)]
26+
pub enum TelemetryAttribute {
27+
///Some attribute info
28+
#[serde(alias = "my_attribute")]
29+
MyAttribute,
30+
}
31+
impl TelemetryAttribute {
32+
/// Supported telemetry attribute (tags) values
33+
pub const fn as_str(&self) -> &'static str {
34+
match self {
35+
TelemetryAttribute::MyAttribute => "apollo.mcp.my_attribute",
36+
}
37+
}
38+
}
39+
#[derive(Debug, ::serde::Deserialize, ::schemars::JsonSchema,, Clone, Eq, PartialEq, Hash, Copy)]
40+
pub enum TelemetryMetric {
41+
///Some metric count info
42+
#[serde(alias = "some.count")]
43+
SomeCount,
44+
}
45+
impl TelemetryMetric {
46+
/// Converts TelemetryMetric to &str
47+
pub const fn as_str(&self) -> &'static str {
48+
match self {
49+
TelemetryMetric::SomeCount => "apollo.mcp.some.count",
50+
}
51+
}
52+
}
53+
```
54+
An example configuration that omits `tool_name` attribute for metrics and `request_id` for tracing would look like the following:
55+
```
56+
telemetry:
57+
exporters:
58+
metrics:
59+
otlp:
60+
endpoint: "http://localhost:4317"
61+
protocol: "grpc"
62+
omitted_attributes:
63+
- tool_name
64+
tracing:
65+
otlp:
66+
endpoint: "http://localhost:4317"
67+
protocol: "grpc"
68+
omitted_attributes:
69+
- request_id
70+
```

.changesets/feat_otel_metrics.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
### Implement metrics for mcp tool and operation counts and durations - @swcollard PR #297
2+
3+
This PR adds metrics to count and measure request duration to events throughout the MCP server
4+
5+
* apollo.mcp.operation.duration
6+
* apollo.mcp.operation.count
7+
* apollo.mcp.tool.duration
8+
* apollo.mcp.tool.count
9+
* apollo.mcp.initialize.count
10+
* apollo.mcp.list_tools.count
11+
* apollo.mcp.get_info.count

.changesets/feat_otel_prototype.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
### Prototype OpenTelemetry Traces in MCP Server - @swcollard PR #274
2+
3+
Pulls in new crates and SDKs for prototyping instrumenting the Apollo MCP Server with Open Telemetry Traces.
4+
5+
* Adds new rust crates to support OTel
6+
* Annotates excecute and call_tool functions with trace macro
7+
* Adds Axum and Tower middleware's for OTel tracing
8+
* Refactors Logging so that all the tracing_subscribers are set together in a single module.
9+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
### Telemetry: Trace operations and auth - @swcollard PR #375
2+
3+
* Adds traces for the MCP server generating Tools from Operations and performing authorization
4+
* Includes the HTTP status code to the top level HTTP trace
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
### feat: adding config option for trace sampling - @alocay PR #366
2+
3+
Adding configuration option to sample traces. Can use the following options:
4+
1. Ratio based samples (ratio >= 1 is always sample)
5+
2. Always on
6+
3. Always off
7+
8+
Defaults to always on if not provided.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### fix: Include the cargo feature and TraceContextPropagator to send otel headers downstream - @swcollard PR #307
2+
3+
Inside the reqwest middleware, if the global text_map_propagator is not set, it will no op and not send the traceparent and tracestate headers to the Router. Adding this is needed to correlate traces from the mcp server to the router or other downstream APIs

0 commit comments

Comments
 (0)