Repository navigation
Conversation
Service gains a MeterProvider field, defaulting to the global provider, mirroring TracerProvider. It records lfs.batch.objects by operation, and lfs.proxied, the bytes of content transferred through the server rather than directly with a presigning storage. Downloads are counted from the result of io.Copy in Serve rather than by wrapping the content reader, which would stop io.Copy from using sendfile.
Add a [metrics] section whose LISTEN_ADDRESS (127.0.0.1:3357 by default, empty to disable) serves /metrics apart from the LFS endpoints. The global meter provider exports to the default Prometheus registry, which also collects the Go runtime and process metrics. - HTTP: route handlers set Request.Pattern, which otelhttp reads to name the server span and to label the request metrics with http.route. - Forge API calls get client request metrics from otelhttp. - Database: the GORM plugin now reports the connection pool stats. - lfsd_auth_cache_lookups_total counts auth cache hits and misses. - lfsd_janitor_objects_total counts swept objects by pass and result.
unknwon
force-pushed
the
otel-metrics
branch
from
November 13, 2026 04:02
8b807fd to
58c67c0
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
Exposes Prometheus metrics. Stacked on #26 (tracing) and reuses its OpenTelemetry setup and HTTP middleware.
[metrics] LISTEN_ADDRESS(default127.0.0.1:3357, empty to disable) serves/metricson a separate listener, so metrics are not public along with the LFS endpoints. The global meter provider exports to the default Prometheus registry, which also collects the Go runtime and process metrics.lfsmodule:Service.MeterProvider(nil means global) mirrorsTracerProvider, so servers embedding the module plug in their own provider. It recordslfs.batch.objectsandlfs.proxied(bytes of content that went through the server rather than directly between the client and a presigning storage), both bylfs.operation.Request.Pattern, ashttp.ServeMuxdoes.otelhttpreads it to name the server span and to labelhttp_server_*metrics withhttp_route. Forge API calls gethttp_client_*metrics.go_sql_connections_*).lfsd_auth_cache_lookups_totalbylfs_auth_cache_hit, andlfsd_janitor_objects_totalbyjanitor_passandjanitor_result.The README lists every metric with its labels.
Test plan
moon run :lintandgo test -race ./...for both projects.lfs: proxied transfers count upload and download bytes (a rejected forged upload does not), presigned transfers count none, and batch objects count by operation.lfsd:http_server_request_duration_secondsis labeled with the route.git-lfspush and pull: scraped/metricson:3357(404 on the LFS port), with route-labeled request metrics, 200000 proxied bytes each way, auth cache lookups, forge client metrics, DB pool, and Go runtime metrics. The token does not appear in the scrape.