Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

trace: several tracing improvements #9153

Merged
merged 9 commits into from
Mar 20, 2020
Merged

Conversation

keegancsmith
Copy link
Member

See individual commits.

@codecov
Copy link

codecov bot commented Mar 20, 2020

Codecov Report

Merging #9153 into master will increase coverage by <.01%.
The diff coverage is 50%.

@@            Coverage Diff             @@
##           master    #9153      +/-   ##
==========================================
+ Coverage   41.51%   41.52%   +<.01%     
==========================================
  Files        1312     1312              
  Lines       71393    71400       +7     
  Branches     6581     6581              
==========================================
+ Hits        29642    29650       +8     
+ Misses      39018    39017       -1     
  Partials     2733     2733
Impacted Files Coverage Δ
cmd/frontend/graphqlbackend/search_symbols.go 10.62% <0%> (-0.28%) ⬇️
cmd/repo-updater/repoupdater/server.go 58.41% <100%> (+0.4%) ⬆️
cmd/frontend/db/repos.go 73.8% <100%> (ø) ⬆️
cmd/frontend/graphqlbackend/textsearch.go 49.19% <100%> (+0.23%) ⬆️
shared/src/api/client/api/extensions.ts 44.44% <0%> (-5.56%) ⬇️
cmd/server/shared/shared.go 0% <0%> (ø) ⬆️
shared/src/api/client/services.ts 100% <0%> (ø) ⬆️
lsif/src/server/server.ts 0% <0%> (ø) ⬆️
lsif/src/shared/api/init.ts 0% <0%> (ø) ⬆️
lsif/src/dump-manager/dump-manager.ts
... and 21 more

LazyLog wouldn't log to opentracing. So we remove it and add a LazyLogger for
fmt.Stringers such that we can update call sites of LazyLog.
LazyPrintf is used quite extensively in our codebase. I wanted to update all
to LogFields, but it is too many callsites. Instead I have made LazyPrintf
call LogFields, but still preserve the lazy behaviour. Follow-up commits will
clean up call sites of LazyPrintf.
One callsite updated to use LogFields instead. I wanted to update lots, but
stopped when I realised how much effort that would be. Going forward the
updates will be much more targetted.
This adds a new opentracing Field which emits much nicer SQL logs.
I found this quite convenient to just click on, instead of assuming the admin
knows to check localhost.
Only logged to opentracing currently. This will allow us to also log to
net/trace.
go lint now knows to check the printf args which is cool, so it picked up this misuse.
otlog.Field.String() just marshals the function for Lazy fields, instead of
actually calling the function to emit its values. This lead to the net/trace
logs to just log the function pointer numbers, instead of the values you want.
@keegancsmith keegancsmith merged commit 63b1d4e into master Mar 20, 2020
@keegancsmith keegancsmith deleted the core/trace-lazy-log branch March 20, 2020 06:06
keegancsmith added a commit that referenced this pull request Mar 24, 2020
* trace: replace LazyLog with LogFields

LazyLog wouldn't log to opentracing. So we remove it and add a LazyLogger for
fmt.Stringers such that we can update call sites of LazyLog.

* trace: LazyPrintf logs to opentracing

LazyPrintf is used quite extensively in our codebase. I wanted to update all
to LogFields, but it is too many callsites. Instead I have made LazyPrintf
call LogFields, but still preserve the lazy behaviour. Follow-up commits will
clean up call sites of LazyPrintf.

* search: use LogFields for searchSymbols

One callsite updated to use LogFields instead. I wanted to update lots, but
stopped when I realised how much effort that would be. Going forward the
updates will be much more targetted.

* trace: add SQL for better lazy logging

This adds a new opentracing Field which emits much nicer SQL logs.

* doc: mention jaeger URL when port forwarding

I found this quite convenient to just click on, instead of assuming the admin
knows to check localhost.

* db: use internal/trace for sql tracing

Only logged to opentracing currently. This will allow us to also log to
net/trace.

* fix lint warning

go lint now knows to check the printf args which is cool, so it picked up this misuse.

* trace: include sql query in title

* trace: correctly marshal lazy otlog.Fields

otlog.Field.String() just marshals the function for Lazy fields, instead of
actually calling the function to emit its values. This lead to the net/trace
logs to just log the function pointer numbers, instead of the values you want.
@unknwon unknwon mentioned this pull request Mar 25, 2020
16 tasks
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.

3 participants