-
Notifications
You must be signed in to change notification settings - Fork 287
Add a wrapper to log spans and span interactions #502
Conversation
- Add zap fields to encode spans - [TODO] Add a wrapped Tracer Signed-off-by: Prithvi Raj <p.r@uber.com>
Codecov Report
@@ Coverage Diff @@
## master #502 +/- ##
==========================================
+ Coverage 88.43% 88.62% +0.18%
==========================================
Files 59 60 +1
Lines 3581 3745 +164
==========================================
+ Hits 3167 3319 +152
- Misses 303 309 +6
- Partials 111 117 +6
Continue to review full report at Codecov.
|
Signed-off-by: Prithvi Raj <p.r@uber.com>
Signed-off-by: Prithvi Raj <p.r@uber.com>
This reverts commit c53c8de. Signed-off-by: Prithvi Raj <p.r@uber.com>
a64a144
to
8f56a55
Compare
Signed-off-by: Prithvi Raj <p.r@uber.com>
|
||
type span struct { | ||
span opentracing.Span | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest keeping consistent with the rest and use type span opentracing.Span
Also might consider type-checking for *jaeger.Span
in the following function rather than in MarshalLogObject
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opentracing.Span
is an interface. We can typedef it, but go doesn't allow implementing methods on interfaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The approach of declaring a new type, and then converting it to use the old type seems pretty contrived to me. What are the benefits of doing this, as opposed to a plain or embedded struct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New structs cause memory allocations as they are converted to interface{}
when passing through Zap API. stdlib also usually uses type aliases instead of creating wrappers, so you could say it's more idiomatic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ty for the explanation!
package zap | ||
|
||
import ( | ||
"github.com/golang/mock/gomock" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I strongly prefer not to introduce mock dependencies into this library. The goal of the logging wrapper is to log, the tests should be checking for log content, rather than mock expectations. Zap provides very good testing facilities, including checking for structured JSON.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests in this file already verify the log message and in cases where appropriate whether the logger contains the specific log field. e.g., context
. They don't look at the contents of the the key because that logic is tested in field_test.go
.
I agree that the purpose of the logging wrapper is to log - but it is crucial that it forwards calls and responses to and from the delegate. I think it is important to test this functionality.
I don't see a way of using purely the logs in the loggingWrapper to verify that the delegate methods have been called with the correct arguments. What are you proposing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
Signed-off-by: Prithvi Raj <p.r@uber.com>
Signed-off-by: Prithvi Raj <p.r@uber.com>
Signed-off-by: Prithvi Raj <p.r@uber.com>
Part of #501
Signed-off-by: Prithvi Raj p.r@uber.com