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

Fixing Span status when exporting span #1751

Merged
merged 7 commits into from Dec 17, 2020

Conversation

obecny
Copy link
Member

@obecny obecny commented Dec 14, 2020

Recently statuscode of span has been updated but not everything has been fixed. It was missing conversion from api status to collector status and proto needs to be updated to ver. 0.6

Which problem is this PR solving?

Short description of the changes

  • updated proto to ver 0.6
  • updated status of span when exporting
  • updated collector docker version
  • updated readme

@codecov
Copy link

codecov bot commented Dec 14, 2020

Codecov Report

Merging #1751 (45e763e) into master (c478cc1) will decrease coverage by 0.02%.
The diff coverage is 73.68%.

@@            Coverage Diff             @@
##           master    #1751      +/-   ##
==========================================
- Coverage   92.12%   92.09%   -0.03%     
==========================================
  Files         166      166              
  Lines        5573     5593      +20     
  Branches     1194     1199       +5     
==========================================
+ Hits         5134     5151      +17     
- Misses        439      442       +3     
Impacted Files Coverage Δ
.../opentelemetry-exporter-collector/src/transform.ts 85.47% <66.66%> (-2.65%) ⬇️
...ages/opentelemetry-exporter-collector/src/types.ts 100.00% <100.00%> (ø)
...kages/opentelemetry-node/src/NodeTracerProvider.ts 100.00% <0.00%> (+3.44%) ⬆️
...emetry-core/src/platform/node/RandomIdGenerator.ts 93.75% <0.00%> (+6.25%) ⬆️

packages/opentelemetry-exporter-collector/src/transform.ts Outdated Show resolved Hide resolved
const spanStatus: opentelemetryProto.trace.v1.Status = {
code: toCollectorCode(status.code),
};
if (typeof status.message !== 'undefined') {
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better to directly test for undefined value instead of using typeof

if(status.message !== undefined)

Copy link
Member Author

Choose a reason for hiding this comment

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

not really, if message is set to anything I just pass it through, this is not validation but just checking if the message was set or not and then pass it through exactly as it was

Copy link
Member

Choose a reason for hiding this comment

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

Yes but to check it you are using typeof and then compare the result to a string 'undefined'.
What is the benefit of it over testing directly for equality to undefined?

@blumamir
Copy link
Member

It's also worth noting that plugins dependent on @opentelemetry/api version <0.13.0 will still use the old CanonicalCode. If exported via the new exported, the wrong enum will be populated for those spans into the status code field which will be misunderstood by new collectors.

Also, using the new exporter with an old collector in grpc will cause collector to not parse the status code from the new field, thus marking all spans as OK.

* An enumeration of status codes.
* https://github.com/open-telemetry/opentelemetry-proto/blob/master/opentelemetry/proto/trace/v1/trace.proto#L304
*/
export enum StatusCode {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make this (and all enums) const?

Again for better minification as during "compiliation" to JS, typescript converts all usages to the numeric value only.

The downside is that if you have code to convert "string" names back to an the enum value its not possible without adding your own extra "lookups"

@obecny obecny merged commit c5cbc49 into open-telemetry:master Dec 17, 2020
@obecny obecny deleted the span_status branch December 17, 2020 10:13
@obecny obecny added bug Something isn't working and removed enhancement New feature or request labels Dec 17, 2020
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 this pull request may close these issues.

Bug: new span StatusCode is being exported to collector with wrong value in v0.13.0
6 participants