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

Error messages from otel builder inappropriately quoted/escaped #6591

Closed
mattsains opened this issue Nov 21, 2022 · 1 comment · Fixed by #6603
Closed

Error messages from otel builder inappropriately quoted/escaped #6591

mattsains opened this issue Nov 21, 2022 · 1 comment · Fixed by #6603
Labels
bug Something isn't working

Comments

@mattsains
Copy link
Contributor

Describe the bug
When the custom collector builder fails, its error message includes an underlying error which usually is the actual content of the error. For example:

2022-11-21T09:56:12.767-0800    INFO    internal/command.go:125 OpenTelemetry Collector Builder {"version": "dev", "date": "unknown"}
2022-11-21T09:56:12.771-0800    INFO    internal/command.go:158 Using config file       {"path": "./cmd/otelcontribcol/manifest.yaml"}
2022-11-21T09:56:12.771-0800    INFO    builder/config.go:107   Using go        {"go-executable": "/usr/bin/go"}
2022-11-21T09:56:12.778-0800    INFO    builder/main.go:76      Sources created {"path": "./bin"}
2022-11-21T09:56:13.564-0800    INFO    builder/main.go:118     Getting go modules
2022-11-21T09:56:13.800-0800    INFO    builder/main.go:87      Compiling
Error: failed to compile the OpenTelemetry Collector distribution: exit status 2. Output: "# github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsxrayexporter/internal/translator\n../exporter/awsxrayexporter/internal/translator/segment.go:193:41: undefined: traceutil.SpanIDToHexOrEmptyString\n../exporter/awsxrayexporter/internal/translator/segment.go:198:41: undefined: traceutil.SpanIDToHexOrEmptyString\n# github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter\n../exporter/alibabacloudlogserviceexporter/logsdata_to_logservice.go:181:33: undefined: traceutil.TraceIDToHexOrEmptyString\n../exporter/alibabacloudlogserviceexporter/logsdata_to_logservice.go:186:33: 
<snipped>

As you can see, the error is quoted and escaped, so it's very difficult to read.

I plan to fix this myself soon because it's quite easy, but I need to write it down because I'm working on something else first.

Steps to reproduce
An easy way to reproduce this problem is to create a manifest yaml that describes an unresoveable dependency. For example, include a replace directive that can't be evaluated.

What did you expect to see?
The error message should be formatted as intended. In the example above:

2022-11-21T09:56:12.767-0800    INFO    internal/command.go:125 OpenTelemetry Collector Builder {"version": "dev", "date": "unknown"}
2022-11-21T09:56:12.771-0800    INFO    internal/command.go:158 Using config file       {"path": "./cmd/otelcontribcol/manifest.yaml"}
2022-11-21T09:56:12.771-0800    INFO    builder/config.go:107   Using go        {"go-executable": "/usr/bin/go"}
2022-11-21T09:56:12.778-0800    INFO    builder/main.go:76      Sources created {"path": "./bin"}
2022-11-21T09:56:13.564-0800    INFO    builder/main.go:118     Getting go modules
2022-11-21T09:56:13.800-0800    INFO    builder/main.go:87      Compiling
Error: failed to compile the OpenTelemetry Collector distribution: exit status 2. Output:
# github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsxrayexporter/internal/translator
../exporter/awsxrayexporter/internal/translator/segment.go:193:41: undefined: traceutil.SpanIDToHexOrEmptyString
../exporter/awsxrayexporter/internal/translator/segment.go:198:41: undefined: traceutil.SpanIDToHexOrEmptyString
# github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter
../exporter/alibabacloudlogserviceexporter/logsdata_to_logservice.go:181:33: undefined: traceutil.TraceIDToHexOrEmptyString
../exporter/alibabacloudlogserviceexporter/logsdata_to_logservice.go:186:33: undefined: 
<snipped>

What did you see instead?
See description, I saw \n instead of newlines, etc

What version did you use?
4565692

Environment
OS: Ubuntu

Additional context
The problem is here:

return fmt.Errorf("failed to compile the OpenTelemetry Collector distribution: %w. Output: %q", err, out)
but I think there are also other instances in that file.

@mattsains mattsains added the bug Something isn't working label Nov 21, 2022
@jpkrohling
Copy link
Member

It has annoyed me as well, thanks for taking care of this!

mattsains added a commit to mattsains/opentelemetry-collector that referenced this issue Nov 22, 2022
jaronoff97 pushed a commit to lightstep/opentelemetry-collector that referenced this issue Dec 14, 2022
jaronoff97 pushed a commit to lightstep/opentelemetry-collector that referenced this issue Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants