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

Introduce sampling package as reference implementation for OTEP 235 #29720

Merged
merged 42 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
2741a32
Add comments, README, metadata.yaml relative to #24811
jmacd Dec 8, 2023
91f6909
add new package
jmacd Dec 8, 2023
2834241
crosslink
jmacd Dec 8, 2023
12530ec
doc
jmacd Dec 8, 2023
4a83262
more place
jmacd Dec 8, 2023
b4c9b78
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
jmacd Dec 11, 2023
53ac105
changelog
jmacd Dec 11, 2023
910beac
no change here
jmacd Dec 11, 2023
5997a19
more linty
jmacd Dec 11, 2023
2e9ddeb
lintier than thou
jmacd Dec 11, 2023
1909040
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
jmacd Dec 11, 2023
3de01cc
fix that
jmacd Dec 11, 2023
1307b1d
hmm
jmacd Dec 11, 2023
28ea1e4
delint
jmacd Dec 11, 2023
5661ced
do what it says
jmacd Dec 11, 2023
95ac7f0
Comment on why must() and mustNot() are here
jmacd Dec 19, 2023
47ddb07
more comments
jmacd Dec 19, 2023
0042984
more comment
jmacd Dec 19, 2023
b9513d8
un-export a few things
jmacd Dec 20, 2023
b33ceeb
document the API
jmacd Dec 20, 2023
0feb399
typos
jmacd Jan 10, 2024
9f4d577
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
jmacd Jan 10, 2024
6204743
update pdata dep
jmacd Jan 10, 2024
ebc99ef
several testable examples
jmacd Jan 23, 2024
0302872
Apply suggestions from code review
jmacd Jan 23, 2024
be84226
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
jmacd Jan 25, 2024
efb3992
move probability test
jmacd Jan 25, 2024
c76b345
small prob examples
jmacd Jan 25, 2024
dbb04d2
improve probability testing; add comments to the example tests for re…
jmacd Jan 25, 2024
8fc6004
more testing
jmacd Jan 26, 2024
554c351
doc comments
jmacd Jan 26, 2024
c8c196d
Add higher-level example in doc comment
jmacd Jan 26, 2024
e294124
test for no-error, fix test as called out by jpk
jmacd Jan 26, 2024
f48df39
Apply suggestions from code review
jmacd Jan 26, 2024
637a787
lcAlphanum
jmacd Jan 26, 2024
f4e4d7a
Apply suggestions from code review
jmacd Jan 26, 2024
c7c796b
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
jmacd Jan 26, 2024
c565f3c
tidy
jmacd Jan 26, 2024
231c3e4
Update pkg/sampling/doc.go
jmacd Jan 30, 2024
896f4b8
Remove most of the Has methods
jmacd Jan 30, 2024
ba64e94
Merge branch 'jmacd/pkgsampl' of github.com:jmacd/opentelemetry-colle…
jmacd Jan 30, 2024
a3844ca
update/tidy
jmacd Jan 30, 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
Prev Previous commit
Next Next commit
more comments
  • Loading branch information
jmacd committed Dec 19, 2023
commit 47ddb076038f17237bf4d96213d380186a5bd675
18 changes: 9 additions & 9 deletions pkg/sampling/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,10 @@ func (cts commonTraceState) ExtraValues() []KV {
}

// trimOws removes optional whitespace on both ends of a string.
// this uses the strict definition for optional whitespace tiven
// in https://www.w3.org/TR/trace-context/#tracestate-header-field-values
func trimOws(input string) string {
jmacd marked this conversation as resolved.
Show resolved Hide resolved
// Hard-codes the value of owsCharset
for len(input) > 0 && (input[0] == ' ' || input[0] == '\t') {
input = input[1:]
}
for len(input) > 0 && (input[len(input)-1] == ' ' || input[len(input)-1] == '\t') {
input = input[:len(input)-1]
}
return input
return strings.Trim(input, " \t")
}

// scanKeyValues is common code to scan either W3C or OTel tracestate
Expand Down Expand Up @@ -98,7 +93,12 @@ func (s keyValueScanner) scanKeyValues(input string, f func(key, value string) e

eq := strings.IndexByte(member, s.equality)
if eq < 0 {
// A regexp should have rejected this input.
// We expect to find the `s.equality`
// character in this string because we have
// already validated the whole input syntax
// before calling this parser. I.e., this can
// never happen, and if it did, the result
// would be to skip malformed entries.
continue
}
if err := f(member[:eq], member[eq+1:]); err != nil {
Expand Down
14 changes: 11 additions & 3 deletions pkg/sampling/oteltracestate.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,18 @@
}

// ErrInconsistentSampling is returned when a sampler update
// is illogical. It is safe to ignore. Samplers should avoid
// this condition using a ThresholdLessThan() test.
// is illogical, indicating that the tracestate was not
// modified. Preferrably Samplers will avoid seeing this

Check failure on line 61 in pkg/sampling/oteltracestate.go

View workflow job for this annotation

GitHub Actions / lint-matrix (pkg)

"Preferrably" is a misspelling of "Preferably"
// error by using a ThresholdGreater() test, which allows them
// to report a more clear error to the user. For example, if
// data arrives sampled at 1/100 and an eqalizing sampler is
jmacd marked this conversation as resolved.
Show resolved Hide resolved
// configureed for 1/2 sampling, the Sampler should detect the
// illogical condition itself and skip the call to
// UpdateTValueWithSampling. This condition should be
// avoided, but if it arises it is safe to ignore. In the example,
// the span will continue to indicate it was sampled at 1/100 even
// after passing through the 1/2 equalizing sampler.
ErrInconsistentSampling = fmt.Errorf("cannot raise existing sampling probability")
ErrInconsistentZero = fmt.Errorf("cannot zero sampling probability")
)

// NewOTelTraceState returns a parsed reprseentation of the
jmacd marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading