Skip to content

Commit

Permalink
fix: traceFlags test in isHeadSampled function
Browse files Browse the repository at this point in the history
The flag wasn't tested as a bit, but as a whole value
For now, since there is only one flag in TraceFlags, it works,
but it won't in the future if a flag is added
  • Loading branch information
hakkanicko committed Aug 2, 2024
1 parent c721cb7 commit bcceaac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ Tail Sampling on the other hand is done at the end. Because we record every sing
Example:

```typescript
const tailSampler = (localTrace: LocalTrace): boolean => {
const tailSampler = (traceInfo: LocalTrace): boolean => {
const localRootSpan = traceInfo.localRootSpan as unknown as ReadableSpan
return localRootSpan.spanContext().traceFlags === TraceFlags.SAMPLED
return (localRootSpan.spanContext().traceFlags & TraceFlags.SAMPLED) === TraceFlags.SAMPLED
}
```

Expand Down
2 changes: 1 addition & 1 deletion src/sampling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function multiTailSampler(samplers: TailSampleFn[]): TailSampleFn {

export const isHeadSampled: TailSampleFn = (traceInfo) => {
const localRootSpan = traceInfo.localRootSpan as unknown as ReadableSpan
return localRootSpan.spanContext().traceFlags === TraceFlags.SAMPLED
return (localRootSpan.spanContext().traceFlags & TraceFlags.SAMPLED) === TraceFlags.SAMPLED
}

export const isRootErrorSpan: TailSampleFn = (traceInfo) => {
Expand Down

0 comments on commit bcceaac

Please sign in to comment.