News for hackers. Stuff that matters.
Re:Discussion: structured, leveled logging by tptacek on Sunday September 11, 2022 @02:41PM (#32802141)
The otel trace API is nowhere near ergonomic enough to replace logging. I think people mostly tolerate otel because the idiomatic way to use it is just a funcall and a defer at the top of a subset of your functions, and because if you're otel-instrumenting, you're probably already passing a context.

https://pkg.go.dev/go.opentelemetry.io/otel/trace

Re:Discussion: structured, leveled logging by phillipcarter on Sunday September 11, 2022 @03:22PM (#32802447)
FWIW tracing in Go is primarily made more difficult by having explicit context propagation and no helper to auto-close a span based on scope. If you use Python or .NET for example, it's implicit and you can "just create some spans" like you would a structured log somewhere in your app, then use built-in language constructs to have it handle closing for you.
Re:Discussion: structured, leveled logging by tptacek on Sunday September 11, 2022 @03:32PM (#32802533)
Sure. If it was a different language, or a different otel library, my opinion would probably be different. I do not think it's realistic to replace logging with otel in Go, though.
Re:Discussion: structured, leveled logging by phillipcarter on Sunday September 11, 2022 @03:50PM (#32802654)
I think it's an inclusive OR here. When logging stabilizes in the Go SDK (which will be a while, perhaps a year) the idea will be that you can keep all your existing logging and then start to add tracing judiciously so they're easily correlated with requests. I think the juice is worth that particular squeeze for more folks at least.

From there I would personally advocate for adding more manual traces rather than more logs, but it's understandable if it's a heavier lift to pass context around all the time. The more options the better.

Re:Discussion: structured, leveled logging by glenjamin on Sunday September 11, 2022 @06:26PM (#32803859)
For web-style application code my experience writing Go code says that you totally can stop using logs and just use traces and have just as much visibility into a running process, if not more.

For library code or other deployment models I’m not sure - it’s not something I’ve had a need to experiment with

Re:Discussion: structured, leveled logging by Rapzid on Sunday September 11, 2022 @04:57PM (#32803203)
.Net has task-local storage which is pretty amazing and Seri log made great use of it(my all-time fav structured log lib).

But iirc task local is a perf concern, and JavaScript has yet to have anything comparable that's ubiquitous(nodejs async hooks though so one day maybe).

So, explicit contexts for Go and JavaScript unfortunately.

Re:Discussion: structured, leveled logging by phillipcarter on Sunday September 11, 2022 @05:18PM (#32803366)
JS does have convenience APIs in the form of startActiveSpan and getActiveSpan that take care of most of the pains here. There's likely some scenarios where you can't use these (e.g., instrumenting a tool must use the sdk-trace-base package) but I think in most cases they help a lot. Go doesn't have these kinds of convenience APIs though.
Re:Discussion: structured, leveled logging by xani_ on Sunday September 11, 2022 @05:25PM (#32803419)
...the helper like WithCancel/WithDeadline ?
Re:Discussion: structured, leveled logging by enobrev on Monday September 12, 2022 @12:54AM (#32806230)
What annoys me about otel is that it seems to require direct live connections. I'd much rather just add the tracking keys / spans / whatever to my logs and parse them out of there later, but no standard lib / app / process seems to like that idea. I have no intention of adding extra sockets to my requests when I can just dump everything to the logs as JSON.

So that's what I do, but instead of relying on otel tools, I have custom queries I run against elasticsearch (or grep syslog) using my trace tags. Works great. No multi-process visualizations but i can make my way through a process chain quickly enough

Re:Discussion: structured, leveled logging by wdb on Monday September 12, 2022 @07:28AM (#32808551)
Re:Discussion: structured, leveled logging by henvic on Sunday September 11, 2022 @03:33PM (#32802545)
I've played with trying to create an idiomatic wrapper for their Go module precisely because of this reason, but then didn't find time to continue with this.

https://github.com/henvic/tel