Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
46fe85e
feat: adding ability to omit attributes for traces and metrics
alocay Sep 12, 2025
9a197bf
chore: adding changeset
alocay Sep 12, 2025
6ed890a
chore: updating changeset text
alocay Sep 12, 2025
d968c44
chore: removing unused file
alocay Sep 12, 2025
4bf5779
chore: renaming exporter file
alocay Sep 12, 2025
29e6ed9
chore: renaming module
alocay Sep 12, 2025
d1322b9
re-running checks
alocay Sep 12, 2025
0245966
chore: auto-gen the as_str function using enums instead of constants
alocay Sep 15, 2025
99349e3
chore: updating changeset entry and fixing fields in instruemnt attri…
alocay Sep 15, 2025
9866f71
chore: adding description as a doc string
alocay Sep 15, 2025
0986bba
chore: updating changeset entry
alocay Sep 15, 2025
1a97f1b
chore: updating operation attribute descriptions
alocay Sep 15, 2025
85e85cb
chore: updating operation_type attribute to operation_source
alocay Sep 15, 2025
67e78ba
chore: skipping request from instrumentation
alocay Sep 15, 2025
274799c
chore: fixing clippy issues
alocay Sep 15, 2025
d57f96f
re-running nix build
alocay Sep 16, 2025
55b640c
updating unit test snapshot
alocay Sep 16, 2025
7e2c0b2
chore: fixing toml formatting issues
alocay Sep 16, 2025
1be317f
test: removing asserts on constants
alocay Sep 16, 2025
db29544
chore: format issues
alocay Sep 16, 2025
fe924cb
test: adjusting unit test to not use local envar
alocay Sep 16, 2025
e9afe18
revert: undoing accidental commit
alocay Sep 16, 2025
a2b4f44
test: removing unnecessary assert
alocay Sep 16, 2025
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
70 changes: 70 additions & 0 deletions .changesets/feat_allow_attribute_configuration_alocay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
### feat: adding ability to omit attributes for traces and metrics - @alocay PR #358

Adding ability to configure which attributes are omitted from telemetry traces and metrics.

1. Using a Rust build script (`build.rs`) to auto-generate telemetry attribute code based on the data found in `telemetry.toml`.
2. Utilizing an enum for attributes so typos in the config file raise an error.
3. Omitting trace attributes by filtering it out in a custom exporter.
4. Omitting metric attributes by indicating which attributes are allowed via a view.
5. Created `telemetry_attributes.rs` to map `TelemetryAttribute` enum to a OTEL `Key`.

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:
```
[attributes.apollo.mcp]
my_attribute = "Some attribute info"

[metrics.apollo.mcp]
some.count = "Some metric count info"
```
This would generate a file that looks like the following:
```
/// All TelemetryAttribute values
pub const ALL_ATTRS: &[TelemetryAttribute; 1usize] = &[
TelemetryAttribute::MyAttribute
];
#[derive(Debug, ::serde::Deserialize, ::schemars::JsonSchema,, Clone, Eq, PartialEq, Hash, Copy)]
pub enum TelemetryAttribute {
///Some attribute info
#[serde(alias = "my_attribute")]
MyAttribute,
}
impl TelemetryAttribute {
/// Supported telemetry attribute (tags) values
pub const fn as_str(&self) -> &'static str {
match self {
TelemetryAttribute::MyAttribute => "apollo.mcp.my_attribute",
}
}
}
#[derive(Debug, ::serde::Deserialize, ::schemars::JsonSchema,, Clone, Eq, PartialEq, Hash, Copy)]
pub enum TelemetryMetric {
///Some metric count info
#[serde(alias = "some.count")]
SomeCount,
}
impl TelemetryMetric {
/// Converts TelemetryMetric to &str
pub const fn as_str(&self) -> &'static str {
match self {
TelemetryMetric::SomeCount => "apollo.mcp.some.count",
}
}
}
```
An example configuration that omits `tool_name` attribute for metrics and `request_id` for tracing would look like the following:
```
telemetry:
exporters:
metrics:
otlp:
endpoint: "http://localhost:4317"
protocol: "grpc"
omitted_attributes:
- tool_name
tracing:
otlp:
endpoint: "http://localhost:4317"
protocol: "grpc"
omitted_attributes:
- request_id
```
66 changes: 65 additions & 1 deletion Cargo.lock

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

12 changes: 11 additions & 1 deletion crates/apollo-mcp-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ license-file.workspace = true
repository.workspace = true
rust-version.workspace = true
version.workspace = true
build = "build.rs"

default-run = "apollo-mcp-server"

Expand Down Expand Up @@ -41,7 +42,7 @@ opentelemetry-otlp = { version = "0.30.0", features = [
opentelemetry-resource-detectors = "0.9.0"
opentelemetry-semantic-conventions = "0.30.0"
opentelemetry-stdout = "0.30.0"
opentelemetry_sdk = "0.30.0"
opentelemetry_sdk = { version = "0.30.0", features = ["spec_unstable_metrics_views"] }
regex = "1.11.1"
reqwest-middleware = "0.4.2"
reqwest-tracing = { version = "0.5.8", features = ["opentelemetry_0_30"] }
Expand All @@ -65,6 +66,7 @@ tracing-opentelemetry = "0.31.0"
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
tracing.workspace = true
url.workspace = true
async-trait = "0.1.89"

[dev-dependencies]
chrono = { version = "0.4.41", default-features = false, features = ["now"] }
Expand All @@ -76,6 +78,14 @@ rstest.workspace = true
tokio.workspace = true
tracing-test = "0.2.5"

[build-dependencies]
cruet = "0.15.0"
prettyplease = "0.2.37"
quote = "1.0.40"
serde.workspace = true
syn = "2.0.106"
toml = "0.9.5"

[lints]
workspace = true

Expand Down
Loading
Loading