util/tracing/detect: separate from bklog package#4469
Conversation
| var err error | ||
| var detectErr error |
There was a problem hiding this comment.
Hmf!
637.8 util/tracing/detect/detect.go:37:5: the variable name `detectErr` should conform to the `errXxx` format (errname)
637.8 var detectErr error
637.8 ^
This error is used to persist errors that occurred during detection (ran in a sync.Once). Using `err` as variable name for this error made it more likely to be inadvertently shadowed. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The otlp detector was registered unconditionally; looks like no init() function is needed for that. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Separate detection from BuildKit's logger, with the potential to separate this package from the BuildKit module. This patch introduces a new "tracelogger" package, which allows decorating an existing logger with trace- and span-ID's. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
f29bb14 to
57deb01
Compare
There was a problem hiding this comment.
What's the use-case for the 2nd/3rd commit? This behavior is already opt-in with user needing to define that tracing is enabled. I don't think we need double opt-in.
I can't imagine a configuration when tracing is enabled but otlp is not a valid implementation. When tracing is enabled then all buildkit logs should have tracing IDs, not sure why there would need to be a way to disable it.
|
The intent here was to see if we could separate the detect package from BuildKit; this was with the assumption that we need to use the same detection logic in BuildKit, Engine, and the CLI (possibly elsewhere), and that the "bklog" package is deeply engrained in BuildKit, so cannot be moved out. Currently; the PR in docker/cli also pulls in that package, and as a result we have a circular dependency on BuildKit again (undesirable). Having the package separate could POSSIBLY also mean that different versions of the package / module could exist with different "semconv" versions, so that moby could move to a version that's compatible with containerd (if BuildKit 0.12 stays on the old version) All that said, @milas may have found an alternative to all of this, that would mean the detect package is no longer needed at all (see the thread in the maintainers channel) |
|
detect package is a hard requirement for tracing to work in buildkit. It is also how |
|
Yes, we need some form of a detect package, but for tracing to work across moby, buildkit (vendored), and containerd, the semconv versions must match. That's currently the problem, because they don't, and they cannot be updated by updating a module (the version is in a "versioned" package name, not a module 😫) IIUC alternative that @milas found is to use the detect package that's now provided by OTEL itself (in some recent release); that would keep versions out of both BuildKit and Moby (other than picking a version of the modules) (or at least; that's my understanding) |
|
@tonistiigi looks like work in progress on that in containerd/containerd#9480 (on my phone right now, but PTAL if that makes sense; also /cc @dmcgowan ) |
|
BuildKit uses the detect package also for recorder capability https://github.com/moby/buildkit/blob/master/util/tracing/detect/recorder.go and needs to capture the exporter. |
|
Closing this because it is quite old and in draft. If this is still important, please contact me and I can probably try to pick this up or someone else can pick it up and create a new PR. |
util/tracing/detect: rename package-level "err" var
This error is used to persist errors that occurred during detection
(ran in a sync.Once). Using
erras variable name for this errormade it more likely to be inadvertently shadowed.
util/tracing/detect: don't use init() to register default otlp detector
The otlp detector was registered unconditionally; looks like no init()
function is needed for that.
util/tracing/detect: separate from bklog package
Separate detection from BuildKit's logger, with the potential to
separate this package from the BuildKit module.
This patch introduces a new "tracelogger" package, which allows
decorating an existing logger with trace- and span-ID's.