Skip to content

Commit

Permalink
fix: span filtering (traceloop#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomer-friedman authored Feb 22, 2023
1 parent e8c3193 commit 25cc18d
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@ import { opentelemetry } from '@traceloop/otel-proto';
import { stringCompare, CompareOptions } from '../matchers/utils';

const flatten = (
serviceResourceSpans: opentelemetry.proto.trace.v1.IResourceSpans | undefined,
) => serviceResourceSpans?.scopeSpans?.flatMap((ss) => ss.spans || []);
serviceResourceSpans:
| opentelemetry.proto.trace.v1.IResourceSpans[]
| undefined,
) =>
(
serviceResourceSpans?.flatMap((srs) => {
return srs.scopeSpans?.flatMap((ss) => ss.spans || []);
}) || []
).filter((s) => !!s) as opentelemetry.proto.trace.v1.ISpan[];

const filterByTraceId = (
spans: opentelemetry.proto.trace.v1.ISpan[] | undefined = [],
Expand All @@ -29,7 +36,7 @@ export const byCustomAttribute = (
traceId: string | undefined,
options?: CompareOptions,
) => {
const serviceResourceSpans = traceData?.resourceSpans?.find((rs) =>
const serviceResourceSpans = traceData?.resourceSpans?.filter((rs) =>
rs.resource?.attributes?.find(
(a) =>
a.key === attName &&
Expand Down

0 comments on commit 25cc18d

Please sign in to comment.