Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add conditions on custom attributes for spans + a new selector for graphql error #4987

Merged
merged 47 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
fb2d0b6
wip
bnjjj Apr 3, 2024
ae546b8
add support of events
bnjjj Apr 5, 2024
62d400d
add tests for events
bnjjj Apr 11, 2024
28d93cd
fix test
bnjjj Apr 12, 2024
5bc0287
fix test and ordering of attributes and headers
bnjjj Apr 15, 2024
2e56947
fix lint
bnjjj Apr 15, 2024
4ac8833
Merge branch 'dev' of github.com:apollographql/router into bnjjj/feat…
bnjjj Apr 15, 2024
8ef1a15
delete useless commment
bnjjj Apr 15, 2024
9bba758
update metrics
bnjjj Apr 15, 2024
3235c57
wip
bnjjj Apr 15, 2024
c3151bf
wip
bnjjj Apr 15, 2024
3f73f8b
refactor event attributes
bnjjj Apr 15, 2024
91402d7
tests wip
bnjjj Apr 16, 2024
d3d7740
Merge branch 'dev' of github.com:apollographql/router into bnjjj/feat…
bnjjj Apr 16, 2024
81f7e87
fix custom event detection in otel
bnjjj Apr 16, 2024
6a82c3e
add tests
bnjjj Apr 17, 2024
c83c6d9
improve handling of object as an otel attribute
bnjjj Apr 17, 2024
b513b51
fix snapshot
bnjjj Apr 17, 2024
84d3655
Merge branch 'bnjjj/feat_4320' of github.com:apollographql/router int…
bnjjj Apr 18, 2024
7c41055
add more tests for events
bnjjj Apr 18, 2024
6d0c232
fix otel value test
bnjjj Apr 18, 2024
60ca42e
Merge branch 'dev' of github.com:apollographql/router into bnjjj/feat…
bnjjj Apr 18, 2024
080ef4c
fixes
bnjjj Apr 19, 2024
c9ce9bd
fix lint
bnjjj Apr 19, 2024
514092f
add conditions on custom attributes for spans + a new selector for gr…
bnjjj Apr 19, 2024
566cd51
add static field selector
bnjjj Apr 19, 2024
f27bbf1
update docs
bnjjj Apr 19, 2024
0f5d6bd
fix lint
bnjjj Apr 19, 2024
1ef4b2e
Merge dev
Apr 22, 2024
a7b3a56
Condition attribute schema
Apr 22, 2024
af2ad47
Move condition attribute to separate module
Apr 22, 2024
5f43729
Rename `ConditionAttribute` to `Conditional` to match `Extendable`
Apr 22, 2024
340d779
Add tests, add deserializer.
Apr 22, 2024
5978025
Fix test. The issue is that you may have a selector on request that h…
Apr 22, 2024
fb8bc4c
Improve condition logic to avoid computation unless absolutely necess…
Apr 22, 2024
875036b
Add tests
Apr 22, 2024
da40912
Schema update
Apr 22, 2024
8e99b39
Add more tests
Apr 22, 2024
58f9b17
Allow non-object selectors
Apr 22, 2024
4895316
Remove commented out code and add comment
Apr 22, 2024
5c87015
Add failing test: `test_extendable_serde_conditional`
Apr 23, 2024
1bcfcc2
Fix deserialization, modify test to exercise multiple fields on attri…
Apr 23, 2024
c518504
changing config test
bnjjj Apr 23, 2024
6330719
Merge branch 'bnjjj/ROUTER_226' of github.com:apollographql/router in…
bnjjj Apr 23, 2024
81d81df
don't lock in a match branch
bnjjj Apr 23, 2024
fdee7d1
Merge branch 'dev' of github.com:apollographql/router into bnjjj/ROUT…
bnjjj Apr 23, 2024
47115a1
fix tests
bnjjj Apr 23, 2024
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
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3960,6 +3960,7 @@ checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16"
dependencies = [
"autocfg",
"scopeguard",
"serde",
]

[[package]]
Expand Down
2 changes: 1 addition & 1 deletion apollo-router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ tokio-tungstenite = { version = "0.20.1", features = [
tokio-rustls = "0.24.1"
http-serde = "1.1.3"
hmac = "0.12.1"
parking_lot = "0.12.1"
parking_lot = { version = "0.12.1", features = ["serde"] }
memchr = "2.7.1"
brotli = "3.4.0"
zstd = "0.13.0"
Expand Down

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions apollo-router/src/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pub(crate) mod extensions;
pub(crate) const OPERATION_NAME: &str = "operation_name";
/// The key of the resolved operation kind. This is subject to change and should not be relied on.
pub(crate) const OPERATION_KIND: &str = "operation_kind";
/// The key to know if the response body contains at least 1 GraphQL error
pub(crate) const CONTAINS_GRAPHQL_ERROR: &str = "apollo::telemetry::contains_graphql_error";

/// Holds [`Context`] entries.
pub(crate) type Entries = Arc<DashMap<String, Value>>;
Expand Down
67 changes: 35 additions & 32 deletions apollo-router/src/plugins/telemetry/config_new/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,27 +78,28 @@ pub(crate) enum DefaultAttributeRequirementLevel {
}

#[derive(Deserialize, JsonSchema, Clone, Default, Debug)]
#[cfg_attr(test, derive(PartialEq))]
#[serde(deny_unknown_fields, default)]
pub(crate) struct RouterAttributes {
/// The datadog trace ID.
/// This can be output in logs and used to correlate traces in Datadog.
#[serde(rename = "dd.trace_id")]
datadog_trace_id: Option<bool>,
pub(crate) datadog_trace_id: Option<bool>,

/// The OpenTelemetry trace ID.
/// This can be output in logs.
#[serde(rename = "trace_id")]
trace_id: Option<bool>,
pub(crate) trace_id: Option<bool>,

/// All key values from trace baggage.
baggage: Option<bool>,
pub(crate) baggage: Option<bool>,

/// Http attributes from Open Telemetry semantic conventions.
#[serde(flatten)]
common: HttpCommonAttributes,
pub(crate) common: HttpCommonAttributes,
/// Http server attributes from Open Telemetry semantic conventions.
#[serde(flatten)]
server: HttpServerAttributes,
pub(crate) server: HttpServerAttributes,
}

impl DefaultForLevel for RouterAttributes {
Expand All @@ -113,29 +114,29 @@ impl DefaultForLevel for RouterAttributes {
}

#[derive(Deserialize, JsonSchema, Clone, Default, Debug)]
#[cfg_attr(test, derive(Serialize))]
#[cfg_attr(test, derive(Serialize, PartialEq))]
#[serde(deny_unknown_fields, default)]
pub(crate) struct SupergraphAttributes {
/// The GraphQL document being executed.
/// Examples:
/// * query findBookById { bookById(id: ?) { name } }
/// Requirement level: Recommended
#[serde(rename = "graphql.document")]
graphql_document: Option<bool>,
pub(crate) graphql_document: Option<bool>,
/// The name of the operation being executed.
/// Examples:
/// * findBookById
/// Requirement level: Recommended
#[serde(rename = "graphql.operation.name")]
graphql_operation_name: Option<bool>,
pub(crate) graphql_operation_name: Option<bool>,
/// The type of the operation being executed.
/// Examples:
/// * query
/// * subscription
/// * mutation
/// Requirement level: Recommended
#[serde(rename = "graphql.operation.type")]
graphql_operation_type: Option<bool>,
pub(crate) graphql_operation_type: Option<bool>,
}

impl DefaultForLevel for SupergraphAttributes {
Expand Down Expand Up @@ -227,6 +228,7 @@ impl DefaultForLevel for SubgraphAttributes {
/// Common attributes for http server and client.
/// See https://opentelemetry.io/docs/specs/semconv/http/http-spans/#common-attributes
#[derive(Deserialize, JsonSchema, Clone, Default, Debug)]
#[cfg_attr(test, derive(PartialEq))]
#[serde(deny_unknown_fields, default)]
pub(crate) struct HttpCommonAttributes {
/// Describes a class of error the operation ended with.
Expand All @@ -236,14 +238,14 @@ pub(crate) struct HttpCommonAttributes {
/// * 500
/// Requirement level: Conditionally Required: If request has ended with an error.
#[serde(rename = "error.type")]
error_type: Option<bool>,
pub(crate) error_type: Option<bool>,

/// The size of the request payload body in bytes. This is the number of bytes transferred excluding headers and is often, but not always, present as the Content-Length header. For requests using transport encoding, this should be the compressed size.
/// Examples:
/// * 3495
/// Requirement level: Recommended
#[serde(rename = "http.request.body.size")]
http_request_body_size: Option<bool>,
pub(crate) http_request_body_size: Option<bool>,

/// HTTP request method.
/// Examples:
Expand All @@ -252,7 +254,7 @@ pub(crate) struct HttpCommonAttributes {
/// * HEAD
/// Requirement level: Required
#[serde(rename = "http.request.method")]
http_request_method: Option<bool>,
pub(crate) http_request_method: Option<bool>,

/// Original HTTP method sent by the client in the request line.
/// Examples:
Expand All @@ -261,29 +263,29 @@ pub(crate) struct HttpCommonAttributes {
/// * foo
/// Requirement level: Conditionally Required (If and only if it’s different than http.request.method)
#[serde(rename = "http.request.method.original", skip)]
http_request_method_original: Option<bool>,
pub(crate) http_request_method_original: Option<bool>,

/// The size of the response payload body in bytes. This is the number of bytes transferred excluding headers and is often, but not always, present as the Content-Length header. For requests using transport encoding, this should be the compressed size.
/// Examples:
/// * 3495
/// Requirement level: Recommended
#[serde(rename = "http.response.body.size")]
http_response_body_size: Option<bool>,
pub(crate) http_response_body_size: Option<bool>,

/// HTTP response status code.
/// Examples:
/// * 200
/// Requirement level: Conditionally Required: If and only if one was received/sent.
#[serde(rename = "http.response.status_code")]
http_response_status_code: Option<bool>,
pub(crate) http_response_status_code: Option<bool>,

/// OSI application layer or non-OSI equivalent.
/// Examples:
/// * http
/// * spdy
/// Requirement level: Recommended: if not default (http).
#[serde(rename = "network.protocol.name")]
network_protocol_name: Option<bool>,
pub(crate) network_protocol_name: Option<bool>,

/// Version of the protocol specified in network.protocol.name.
/// Examples:
Expand All @@ -293,23 +295,23 @@ pub(crate) struct HttpCommonAttributes {
/// * 3
/// Requirement level: Recommended
#[serde(rename = "network.protocol.version")]
network_protocol_version: Option<bool>,
pub(crate) network_protocol_version: Option<bool>,

/// OSI transport layer.
/// Examples:
/// * tcp
/// * udp
/// Requirement level: Conditionally Required
#[serde(rename = "network.transport")]
network_transport: Option<bool>,
pub(crate) network_transport: Option<bool>,

/// OSI network layer or non-OSI equivalent.
/// Examples:
/// * ipv4
/// * ipv6
/// Requirement level: Recommended
#[serde(rename = "network.type")]
network_type: Option<bool>,
pub(crate) network_type: Option<bool>,
}

impl DefaultForLevel for HttpCommonAttributes {
Expand Down Expand Up @@ -362,96 +364,97 @@ impl DefaultForLevel for HttpCommonAttributes {
/// Attributes for Http servers
/// See https://opentelemetry.io/docs/specs/semconv/http/http-spans/#http-server
#[derive(Deserialize, JsonSchema, Clone, Default, Debug)]
#[cfg_attr(test, derive(PartialEq))]
#[serde(deny_unknown_fields, default)]
pub(crate) struct HttpServerAttributes {
/// Client address - domain name if available without reverse DNS lookup, otherwise IP address or Unix domain socket name.
/// Examples:
/// * 83.164.160.102
/// Requirement level: Recommended
#[serde(rename = "client.address", skip)]
client_address: Option<bool>,
pub(crate) client_address: Option<bool>,
/// The port of the original client behind all proxies, if known (e.g. from Forwarded or a similar header). Otherwise, the immediate client peer port.
/// Examples:
/// * 65123
/// Requirement level: Recommended
#[serde(rename = "client.port", skip)]
client_port: Option<bool>,
pub(crate) client_port: Option<bool>,
/// The matched route (path template in the format used by the respective server framework).
/// Examples:
/// * /graphql
/// Requirement level: Conditionally Required: If and only if it’s available
#[serde(rename = "http.route")]
http_route: Option<bool>,
pub(crate) http_route: Option<bool>,
/// Local socket address. Useful in case of a multi-IP host.
/// Examples:
/// * 10.1.2.80
/// * /tmp/my.sock
/// Requirement level: Opt-In
#[serde(rename = "network.local.address")]
network_local_address: Option<bool>,
pub(crate) network_local_address: Option<bool>,
/// Local socket port. Useful in case of a multi-port host.
/// Examples:
/// * 65123
/// Requirement level: Opt-In
#[serde(rename = "network.local.port")]
network_local_port: Option<bool>,
pub(crate) network_local_port: Option<bool>,
/// Peer address of the network connection - IP address or Unix domain socket name.
/// Examples:
/// * 10.1.2.80
/// * /tmp/my.sock
/// Requirement level: Recommended
#[serde(rename = "network.peer.address")]
network_peer_address: Option<bool>,
pub(crate) network_peer_address: Option<bool>,
/// Peer port number of the network connection.
/// Examples:
/// * 65123
/// Requirement level: Recommended
#[serde(rename = "network.peer.port")]
network_peer_port: Option<bool>,
pub(crate) network_peer_port: Option<bool>,
/// Name of the local HTTP server that received the request.
/// Examples:
/// * example.com
/// * 10.1.2.80
/// * /tmp/my.sock
/// Requirement level: Recommended
#[serde(rename = "server.address")]
server_address: Option<bool>,
pub(crate) server_address: Option<bool>,
/// Port of the local HTTP server that received the request.
/// Examples:
/// * 80
/// * 8080
/// * 443
/// Requirement level: Recommended
#[serde(rename = "server.port")]
server_port: Option<bool>,
pub(crate) server_port: Option<bool>,
/// The URI path component
/// Examples:
/// * /search
/// Requirement level: Required
#[serde(rename = "url.path")]
url_path: Option<bool>,
pub(crate) url_path: Option<bool>,
/// The URI query component
/// Examples:
/// * q=OpenTelemetry
/// Requirement level: Conditionally Required: If and only if one was received/sent.
#[serde(rename = "url.query")]
url_query: Option<bool>,
pub(crate) url_query: Option<bool>,

/// The URI scheme component identifying the used protocol.
/// Examples:
/// * http
/// * https
/// Requirement level: Required
#[serde(rename = "url.scheme")]
url_scheme: Option<bool>,
pub(crate) url_scheme: Option<bool>,

/// Value of the HTTP User-Agent header sent by the client.
/// Examples:
/// * CERN-LineMode/2.15
/// * libwww/2.17b3
/// Requirement level: Recommended
#[serde(rename = "user_agent.original")]
user_agent_original: Option<bool>,
pub(crate) user_agent_original: Option<bool>,
}

impl DefaultForLevel for HttpServerAttributes {
Expand Down
Loading
Loading