Skip to content

chore(deps): replace the unmaintained uptrace opentelemetry-go-extra modules - #1753

Merged
mbrandenburger merged 1 commit into
hyperledger-labs:mainfrom
mbrandenburger:otel-drop-uptrace
Sep 7, 2026
Merged

mbrandenburger merged 1 commit into
hyperledger-labs:mainfrom
mbrandenburger:otel-drop-uptrace

Conversation

@mbrandenburger

@mbrandenburger mbrandenburger commented Sep 7, 2026 •

Copy link
Copy Markdown
Member

What and why

FSC depended on three github.com/uptrace/opentelemetry-go-extra modules — otelzap and otelsql directly, otelutil transitively. The suite is unmaintained: v0.3.2 is its newest tag and upstream's last commit is 2024-11-18.

That became blocking in #1747. go.opentelemetry.io/otel/log v0.21.0 deleted keyvalue.go, and with it log.Value and every log.XxxValue constructor. otelutil@v0.3.2 still calls them, so the v0.20.0 → v0.22.0 bump in that PR stops the root module compiling — which is why Analyze, all three golangci jobs, every utest-* and every itest-* are red there:

otelutil@v0.3.2/attribute.go:68:38: undefined: log.Value
otelutil@v0.3.2/attribute.go:71:14: undefined: log.StringValue

Pinning otel/log at v0.20.0 fixes #1747, and would have to hold forever. This removes the constraint instead.

otelzap turns out not to have been needed at all. It was configured with a LoggerProvider wrapping noop.NewLoggerProvider(), and spanLogger.Emit discarded every part of the record except the body:

func (l *spanLogger) Emit(ctx context.Context, record log.Record) {
	trace.SpanFromContext(ctx).AddEvent(record.Body().AsString(), ...)
}

So each context-aware call built a log.Record, set its severity, ran otelutil.LogValue over the fields — the code path that needs the removed API — and did a runtime.Caller lookup, and all of it was thrown away to keep one string. Only two behaviours were ever consumed, and both are now produced directly in ctxFieldLogger over a plain *zap.SugaredLogger:

  • span.AddEvent(msg, logger.name=…) at or above the logger's level
  • span.SetStatus(codes.Error, msg) for Error and above

spanLoggerProvider, spanLogger and sanitizedSpanLogger are gone, and with them the go.opentelemetry.io/otel/log dependency. Because nothing is computed when the span in ctx is not recording, fmt.Sprintf and the sanitizer no longer run on the untraced path — the common case in production:

InfowContext, enabled, no fields   before  1378 ns/op  1785 B/op  11 allocs/op
                                    after   453 ns/op  1221 B/op   3 allocs/op

go.opentelemetry.io/contrib/bridges/otelzap is deliberately not used: it is a zapcore.Core emitting real log records to a LoggerProvider, with no *Context methods and no span events, so it would be more code for something FSC does not want. It is the right choice only if FSC later wants the log signal rather than span events.

otelsql has no contrib counterpart — the suite carries no database/sql instrumentation — so it moves to github.com/XSAM/otelsql, the implementation the OpenTelemetry registry lists. Open and WithAttributes are signature-identical, so it is a one-line import swap in each of the two call sites.

Closes #1752

How it was verified

  • go build ./... in all four buildable modules
  • make unit-tests-root — pass
  • go test ./platform/view/services/storage/... ./platform/common/services/logging/... — 14 packages, pass
  • make tidy clean; no uptrace and no otel/log left in any of the five go.mod files
  • golangci-lint run on both changed package trees — 0 issues
  • Benchmarks above from go test -bench 'Infow|Infof|Debugf' ./platform/common/services/logging/

New tests, since the span-event path had no coverage before: otel_test.go asserts the event name and logger.name attribute, printf message formatting, SetStatus on error, suppression below level, the OtelSanitize path, and no-span-in-ctx — over tracetest.SpanRecorder and the real trace SDK.

Postgres-backed tests need Docker and were not run locally; utest-postgres covers them.

Notes for reviewers

…modules

FSC depended on three github.com/uptrace/opentelemetry-go-extra modules:
otelzap and otelsql directly, otelutil transitively. Upstream's last commit
is 2024-11-18 and v0.3.2 is its newest tag, so the suite no longer tracks the
OpenTelemetry Go API.

That came due in hyperledger-labs#1747. go.opentelemetry.io/otel/log v0.21.0 deleted
keyvalue.go, and with it log.Value and every log.XxxValue constructor.
otelutil v0.3.2 still calls them, so bumping otel/log past v0.20.0 stops the
module compiling:

	otelutil@v0.3.2/attribute.go:68:38: undefined: log.Value
	otelutil@v0.3.2/attribute.go:71:14: undefined: log.StringValue

Pinning otel/log at v0.20.0 would work, and would have to hold forever.

otelzap turns out not to be needed at all. It was configured with a
LoggerProvider wrapping noop.NewLoggerProvider(), and spanLogger.Emit
discarded every part of the record it received except the body:

	trace.SpanFromContext(ctx).AddEvent(record.Body().AsString(), ...)

So each context-aware call built a log.Record, set its severity, ran
otelutil.LogValue over the fields -- the code path that needs the removed
API -- and looked up runtime.Caller, and all of it was thrown away to keep one
string. Only two behaviours were ever consumed:

  - span.AddEvent(msg, logger.name=...) at or above the logger's level
  - span.SetStatus(codes.Error, msg) for Error and above

Both are now produced directly in ctxFieldLogger over a plain
zap.SugaredLogger, and the log-signal plumbing -- spanLoggerProvider,
spanLogger, sanitizedSpanLogger -- is gone along with the otel/log dependency
itself. Nothing is computed when the span in ctx is not recording, so
fmt.Sprintf and the sanitizer no longer run on the common untraced path:

	InfowContext, enabled, no fields   before  1378 ns/op  1785 B/op  11 allocs/op
	                                    after   453 ns/op  1221 B/op   3 allocs/op

contrib/bridges/otelzap is not the replacement: it is a zapcore.Core emitting
real log records to a LoggerProvider, with no *Context methods and no span
events, so adopting it would mean writing more code to get something FSC does
not want. It is the right choice only if FSC later wants the log signal.

otelsql has no contrib counterpart -- the suite carries no database/sql
instrumentation -- so it moves to github.com/XSAM/otelsql, the implementation
the OpenTelemetry registry lists, whose Open and WithAttributes signatures are
identical. Its otel v1.46.0 requirement pulls the root module's otel core
along with it.

Dropping one wrapper frame from the call chain takes the otel logger's caller
skip from 2 to 1, which TestContextLogFields_CallerAccuracy covers. The span
event path had no test at all, so otel_test.go adds one per behaviour, over
tracetest.SpanRecorder and the real trace SDK.

Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
@mbrandenburger mbrandenburger added dependencies Pull requests that update a dependency file cleanup Something needs some cleanup go Pull requests that update go code labels Sep 7, 2026
@github-actions

github-actions Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

Hey @mbrandenburger 👋 thanks for the PR!
I'm your friendly PR Helper Bot 🤖 and I'll be riding shotgun on this one, keeping track of your PR's status to help you get it approved and merged.

This comment updates automatically as you push changes -- think of it as your PR's live scoreboard!
Here's the latest:


PR Checks

✅ DCO Sign-off -- All commits have valid sign-offs. Nice work!


✅ GPG Signature -- All commits have verified GPG signatures. Locked and loaded!


✅ Merge Conflicts -- No merge conflicts detected. Smooth sailing!


❌ Issue Link -- Almost there! You are not assigned to the following linked issues: #1747.

Please ensure you are assigned to all linked issues before opening a PR. You can comment /assign on the issue to grab it!


⏳ All checks must pass before this PR can be reviewed. You've got this!

@github-actions github-actions Bot added the status: needs revision The pull request requires changes from the author before it can be reviewed or merged label Sep 7, 2026
@mbrandenburger mbrandenburger added this to the 26Q3 milestone Sep 7, 2026

@adecaro adecaro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review: does this address #1752?

Checked out at 59458e167dd8c240c525e0665bd7c5531e21d868 (up to date with main).

$ go build ./... && go vet ./platform/common/services/logging/... ./platform/view/services/storage/driver/sql/{postgres,sqlite}/...
(clean)

$ go test -count=1 --skip '(Postgres)' ./platform/common/services/logging/... ./platform/view/services/storage/driver/sql/{postgres,sqlite}/...
ok  .../platform/common/services/logging
ok  .../platform/common/services/logging/testlogger
ok  .../platform/view/services/storage/driver/sql/postgres
ok  .../platform/view/services/storage/driver/sql/sqlite

$ golangci-lint run ./platform/common/services/logging/... ./platform/view/services/storage/driver/sql/{postgres,sqlite}/...
0 issues.

$ grep -rn "uptrace\|otel/log" (every go.mod/go.sum in the repo)
(no matches — fully removed)

go mod tidy in a scratch copy of all four affected modules (., integration/, libp2p/, cc/query/) produced zero diff.

What it fixes / adds

Claim Verified how
otelzap was only ever used for AddEvent/SetStatus(codes.Error,...), nothing else Read pre-PR otel.go + vendored otelzap@v0.3.2 source (otelzap.go:161-168) — confirmed the new ctxFieldLogger.addEvent reproduces both effects with the same sanitize/status ordering
XSAM/otelsql's Open/WithAttributes are drop-in for uptrace/otelsql Both call sites unchanged except import path; builds and tests clean
otel 1.45→1.46 / testify 1.12.0→1.12.1 are pulled in by XSAM/otelsql, not chosen Confirmed in the go.mod diff — no other version changes present
New otel_test.go covers the issue's stated gap (event name+attr, printf formatting, error status, level suppression, sanitize path, no-span-in-ctx) One test per item, all pass

Blocking

None.

Non-blocking

  • The bot's Issue Link check currently FAILs (status: needs revision) because the PR body mentions #1747 in prose (as the PR this unblocks) without a closing keyword, and checkIssueLink requires assignment on every mentioned issue, not just the one actually being closed (Fixes #1752, which the author is assigned to). That's a known bot limitation, not something to fix in this PR's code.

Recommendation

Merge after the Issue Link check is resolved (get assigned to #1747, or drop/rephrase the mention) — the code itself is clean: build/vet/lint/tests all pass, go mod tidy is a no-op everywhere, and every claim in the PR description checked out against the diff and the removed library's source.

@adecaro
adecaro self-requested a review September 7, 2026 13:48

@adecaro adecaro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@mergify

mergify Bot commented Sep 7, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@mbrandenburger
mbrandenburger merged commit c93e054 into hyperledger-labs:main Sep 7, 2026
43 checks passed
@mbrandenburger
mbrandenburger deleted the otel-drop-uptrace branch September 7, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup Something needs some cleanup dependencies Pull requests that update a dependency file go Pull requests that update go code status: needs revision The pull request requires changes from the author before it can be reviewed or merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace the unmaintained uptrace opentelemetry-go-extra dependencies

2 participants