Repository navigation
Conversation
Move the transfer logic of lfsd into a separate Go module, unknwon.dev/git-lfs-server/lfs, so that other Git servers can serve LFS with the same storage backends. The module has an lfs.Service that answers batch, upload, download, and verify requests on top of an lfs.Store for metadata and a storage.Backend for content, and leaves routing, authentication, and response encoding to the caller. lfsd now builds one lfs.Service per forge host and keeps its HTTP responses, except that a proxied upload of an already stored object must send matching content before the object is linked to another repository. Previously, any body was accepted in that case, so a writer of one repository could gain read access to any object of another repository by its OID and size.
Windows cannot remove the test's temp dir while the object file is open.
Add Service.Serve, which handles the batch, upload, download, and verify requests of a repository given an Access that the caller resolved after authenticating the request. It dispatches on the method and the last path segment, so it works with any router that runs net/http handlers and any URL layout. lfsd now only maps its forge permissions to an Access and hands requests to it. Upload actions now set Content-Type to application/octet-stream so the Git LFS client does not send a type detected from the file content.
4 tasks done
Service gains a TracerProvider field, defaulting to the global provider, and starts a span for each of Batch, Upload, Download, and Verify, with a child span for every call to the storage backend. Instrumenting the calls in Service traces any plugged-in backend without changes to it. The module depends only on the OpenTelemetry API. Client errors (*Error) are recorded as lfs.error.code and leave the span status unset. Internal errors fail the span.
Add a [tracing] section (ENABLED, ENDPOINT, SAMPLE_RATIO) that installs a global tracer provider with a parent-based ratio sampler and W3C trace context propagation. Disabled by default, which keeps every tracer no-op. - HTTP: otelhttp wraps the router, spans are named after the matched LFS route, and /healthz is not traced. - Auth: an authorize span records cache hits and the permission, never credentials. Forge API calls are client spans, and the trace context is not sent to the forge. - Database: the GORM OpenTelemetry plugin traces queries without bound values. Startup queries share a database.New trace. - Janitor: each sweep is a janitor.Sweep trace with deleted and failed counts per pass. - Logs: records in a traced context carry traceID and spanID, and error records are attached to the span as events.
unknwon
force-pushed
the
otel-tracing
branch
from
November 13, 2026 04:02
73c9068 to
8853467
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds OpenTelemetry tracing across lfsd and the
lfsmodule. Stacked on #23.[tracing]config:ENABLED(defaultfalse),ENDPOINT(OTLP/HTTP, empty falls back to the standardOTEL_EXPORTER_OTLP_*env vars),SAMPLE_RATIO(parent-based, default1). When disabled, the global tracer provider stays no-op. Spans are flushed on shutdown.otelhttpwraps the router. Each LFS route names its server span, e.g.,POST /{host}/{**}/info/lfs/objects/batch, withlfs.forge.hostandlfs.repo. An incoming W3Ctraceparentis continued./healthzis not traced.authorizespan records whether the permission came from the cache and the resulting permission. It never records credentials. Forge API calls are client spans, and the trace context is not sent to the forge.lfsmodule: depends only on the OpenTelemetry API.Service.TracerProvider(nil means global) getslfs.Batch,lfs.Upload,lfs.Download, andlfs.Verifyspans, with a child span for every storage call (storage.Put,storage.Head, etc.). The storage calls are instrumented inService, so any plugged-in backend is traced without changes. Client errors (*lfs.Error) are recorded aslfs.error.codeand do not fail the span.database.Newtrace.janitor.Sweeptrace with a child per pass and its deleted and failed counts.traceIDandspanID. Error records are added to the span as events and fail it.Test plan
moon run :lintandgo test -race ./...for both projects.lfs: spans go to the injected provider, storage spans are children of the operation, client errors leave the status unset, and internal errors fail it.forge: notraceparentreaches the forge even with a global propagator installed. The test fails when the empty propagator is removed. The token does not appear in any span attribute.logx: trace and span IDs on records, error-only span events and status.lfsd: route span names andhttp.route.git-lfs3.6.1 push and pull, an upstreamtraceparentcontinued, a bad GitHub token traced throughauthorizeto the API call, and spans flushed on SIGTERM. The token and theAuthorizationheader appear nowhere in the exported spans.