Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Expand exception logs #168

Merged
merged 6 commits into from
Feb 26, 2018
Merged

Conversation

pavolloffay
Copy link
Member

No description provided.

@@ -389,6 +397,17 @@ public Builder withZipkinSharedRpcSpan() {
return this;
}

/**
* If the exception is logged and 'message', 'stack' or 'error.kind' is missing. Tracer will
Copy link
Member Author

Choose a reason for hiding this comment

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

message, error.kind could be done automatically, and stack could be optional for perf reasons.

Copy link
Member

Choose a reason for hiding this comment

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

Nit: comma after "missing"

@codecov-io
Copy link

codecov-io commented May 4, 2017

Codecov Report

Merging #168 into master will increase coverage by 0.15%.
The diff coverage is 95.65%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #168      +/-   ##
============================================
+ Coverage     84.28%   84.43%   +0.15%     
- Complexity      575      583       +8     
============================================
  Files            92       92              
  Lines          2246     2268      +22     
  Branches        260      266       +6     
============================================
+ Hits           1893     1915      +22     
  Misses          251      251              
  Partials        102      102
Impacted Files Coverage Δ Complexity Δ
...ger-core/src/main/java/com/uber/jaeger/Tracer.java 87.06% <100%> (+0.22%) 21 <2> (+1) ⬆️
...aeger-core/src/main/java/com/uber/jaeger/Span.java 84.67% <94.44%> (+2.6%) 46 <5> (+7) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1fa8d12...b86f307. Read the comment docs.

Copy link
Contributor

@black-adder black-adder left a comment

Choose a reason for hiding this comment

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

Tests to come?

* @return logged fields
*/
private static Map<String, Object> exceptionLogs(Map<String, ?> fields) {
Object ex = fields.get("error.object");
Copy link
Contributor

Choose a reason for hiding this comment

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

are "error.object", "stack", "message", and "error.kind" defined in opentracing Java? If not, should we make them public consts for jaeger-client-java?

Copy link
Member Author

Choose a reason for hiding this comment

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

They are defined in the spec, but not in API artifact, I will open PR to ot-java.

if (!errorFields.isEmpty()) {
errorFields.putAll(fields);
}
fields = errorFields;
Copy link
Contributor

Choose a reason for hiding this comment

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

it looks like if the fields don't contain "error.object", we throw out all the fields the user passed in?

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch, this should be inside, the if above

logs.add(new LogData(timestampMicroseconds, fields));
}
return this;
}
}


Copy link
Contributor

Choose a reason for hiding this comment

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

nit: double newline uncessecary

@pavolloffay
Copy link
Member Author

PR updated, added some tests

Map<String, Object> errorFields = exceptionLogs(fields);
if (!errorFields.isEmpty()) {
errorFields.putAll(fields);
fields = errorFields;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not overly familiar with certain Java things, but given that we do errorFields.putAll(fields) above, is it still necessary for fields = errorFields;?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is necessary because of line 237.

Copy link
Contributor

Choose a reason for hiding this comment

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

ohhh, putAll puts fields into errorFields and not the other way round (duhhh).

Given that, this means if the user specifically added a "error.object", "stack", "message", and "error.kind", that will overwrite the k,v in errorFields? sounds right.

Copy link
Member Author

Choose a reason for hiding this comment

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

Tracer does not change explicitly logged items ( "error.object", "stack", "message" ..). It only derives new fields if are not logged.

@black-adder
Copy link
Contributor

LGTM, I wonder if we should wait until the tags are specified in ot-java before landing this though.

@jpkrohling
Copy link
Collaborator

Is this still relevant ?

@pavolloffay
Copy link
Member Author

Yes I will rebase it

@pavolloffay
Copy link
Member Author

Rebased, it can be reviewed. The last review comment was to wait for Fields to be defined in OT. They have been added in 0.31.0

@@ -228,6 +231,13 @@ public Span log(long timestampMicroseconds, Map<String, ?> fields) {
return this;
}
if (context.isSampled()) {
if (tracer.isExpandExceptionLogs()) {
Map<String, Object> errorFields = exceptionLogs(fields);
Copy link
Member

Choose a reason for hiding this comment

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

minor point, but couldn't we move all the logic into exceptionLogs() so that here we only have

fields = exceptionLogs(fields);

?

Internally it could do Map<String, Object> errorFields = new HashMap<String, Object>(fields);

Copy link
Member Author

Choose a reason for hiding this comment

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

I have changed it to ^^. I will merge or green

@pavolloffay
Copy link
Member Author

pavolloffay commented Feb 23, 2018

Coverage is odd, there are no changes to that class/tests in this PR.

screenshot of compare jaegertracing_jaeger-client-java

Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
@pavolloffay pavolloffay merged commit e152db4 into jaegertracing:master Feb 26, 2018
@ghost ghost removed the review label Feb 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants