Skip to content

Commit

Permalink
feat(receiver-mock): add querying the spans and traces by span name
Browse files Browse the repository at this point in the history
  • Loading branch information
aboguszewski-sumo committed Sep 9, 2022
1 parent 601884b commit e672ea4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/rust/receiver-mock/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ The following endpoints provide information about received traces:
have to fullfil in order to be returned.
Attribute values can be omitted in which case only presence of a particular attribute
will be checked.
`__name__` is handled specially as it will be matched against the span name.

Exemplary output:

Expand Down Expand Up @@ -103,6 +104,7 @@ The following endpoints provide information about received traces:
If any span in a trace contains all of these attributes, this trace will be in the list.
Attribute values can be omitted in which case only presence of a particular attribute
will be checked.
Similarly as in `/spans-list`, `__name__` is handled specially as it will be matched against the name of any span.

Exemplary output:

Expand Down
11 changes: 10 additions & 1 deletion src/rust/receiver-mock/src/traces/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,17 @@ impl std::fmt::Display for Span {
}

fn is_span_ok(span: &Span, params: &HashMap<String, String>) -> bool {
// TODO: This can be expanded to query by other parameters. As for now, it only filters by label.
for (key, value) in params.iter() {
// Identically as in the metric's case,
// we use "__name__" as key for span's name
// to keep the querying simple.
if key == "__name__" {
if value.is_empty() || span.name == *value {
continue;
}
return false;
}

if let Some(val) = span.attributes.get(key) {
if val.eq(value) {
continue;
Expand Down

0 comments on commit e672ea4

Please sign in to comment.