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

Fix: error logged on empty OTEL_TRACES_SAMPLER_ARG #6511

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

matthewhughes934
Copy link

We were noticing errors like:

time=2024-12-18T15:00:02.080Z level=ERROR
source=/go/pkg/mod/go.opentelemetry.io/contrib/samplers/[email protected]/sampler_remote_options.go:112 msg="env variable parsing failure" err="argument is not of type '='"

In applications using the Jaeger sampler but had not set the OTEL_TRACES_SAMPLER_ARG environment variable. The issue was:

  • os.Getenv would return "" when this var was not set, and
  • strings.Split("", ",") would return []string{""}

since "" does not contain = an error is emitted.

@matthewhughes934 matthewhughes934 requested review from yurishkuro and a team as code owners December 18, 2024 17:36
Copy link
Contributor

@MrAlias MrAlias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this looks good. Thank you for adding tests to cover your issue. The last remaining thing is a changelog entry for the fix your adding needs to be included.

Copy link

codecov bot commented Dec 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.5%. Comparing base (13b1cc5) to head (f77bd1e).
Report is 12 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #6511     +/-   ##
=======================================
- Coverage   68.5%   68.5%   -0.1%     
=======================================
  Files        200     200             
  Lines      16768   16772      +4     
=======================================
+ Hits       11493   11494      +1     
- Misses      4931    4933      +2     
- Partials     344     345      +1     
Files with missing lines Coverage Δ
samplers/jaegerremote/sampler_remote_options.go 97.2% <100.0%> (-2.8%) ⬇️

... and 1 file with indirect coverage changes

@matthewhughes934
Copy link
Author

Overall, this looks good. Thank you for adding tests to cover your issue. The last remaining thing is a changelog entry for the fix your adding needs to be included.

Thanks! Changelog entry added with 4d72fb9

We were noticing errors like:

> time=2024-12-18T15:00:02.080Z level=ERROR
source=/go/pkg/mod/go.opentelemetry.io/contrib/samplers/[email protected]/sampler_remote_options.go:112
msg="env variable parsing failure" err="argument  is not of type
'<key>=<value>'"

In applications using the Jaeger sampler but had not set the
`OTEL_TRACES_SAMPLER_ARG` environment variable. The issue was:

* `os.Getenv` would return `""` when this var was not set, and
* `strings.Split("", ",")` would return `[]string{""}`

since `""` does not contain `=` an error is emitted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants