Skip to content
CAI
Software that uses CAICheck a score

go-kratos/kratos

59.0

Adequate · 24 September 2026

18.7k

lines of production code

Go

primary language

5

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

This system is a comprehensive Go-based microservices framework (Kratos v3) that provides a complete lifecycle for building distributed applications. It offers a modular architecture for transport (HTTP, gRPC, MCP), service discovery, and configuration management across various backends like Consul, Nacos, and Kubernetes. The framework also includes extensive middleware support for observability, security, and traffic control, alongside robust code generation tools for Protobuf and CLI utilities.

How it got here

2019–2021 — Kratos v3 architecture and ecosystem

70 changes.

This period focused on the comprehensive development of the Kratos v3 framework, introducing a new application lifecycle, transport layer, and configuration system. It also expanded the CLI tooling and added extensive middleware, encoding, and service discovery implementations to support the new architecture.

2022–2026 — observability and service mesh integration

12 changes.

This period focused on expanding the framework's ecosystem by adding support for multiple service mesh platforms, specifically Tencent Polaris, OpenSergo, and Servicecomb. The team also introduced comprehensive observability features through OpenTelemetry integration and added new middleware for JWT authentication, validation, and error tracking.

Features

Add 'kratos run' command to execute project code

Introduces the 'kratos run' subcommand, which locates the 'cmd' directory within the project, allows the user to select a specific command directory if multiple are found, and executes the project's Go code from that directory. The command supports passing arguments to the program and includes a '--work' flag to specify an alternative working directory.

cmd/kratos/internal/run · high confidence

Add Apollo config source and watcher implementation

Users can now integrate with the Apollo config center using the new \contrib/config/apollo\ package. This adds a \config.Source\ implementation that supports reading configuration from Apollo namespaces, with options for app ID, cluster, endpoint, and secret. The implementation handles JSON, YAML, and properties formats, supports configuration hot-reloading via a watcher, and includes backup and original config retrieval features.

contrib/config/apollo · high confidence

Add Consul as a config provider

Users can now use Consul as a configuration source in Kratos. The new \contrib/config/consul\ module provides a \config.Source\ implementation that reads key-value pairs from a specified Consul path. It supports automatic format detection based on file extensions (e.g., \.json\, \.yaml\) and includes a watcher for real-time configuration updates. The implementation includes a README with usage examples, unit tests, and a dedicated watcher component that handles Consul KV prefix changes.

contrib/config/consul, contrib/config/etcd · high confidence

Add Discovery registry implementation for service registration and discovery

The \contrib/registry/discovery\ module now provides a \registry.Registrar\ and \registry.Discovery\ implementation based on \bilibili/discovery\. Users can initialize a discovery client with region, zone, and environment configuration to register services, watch for changes, and discover service instances via HTTP polling. The module includes a README with quick-start examples for both service registration and discovery.

contrib/registry/discovery · high confidence

Add HTTP content-type utility functions

The internal/httputil package now provides two new utility functions for handling HTTP content types. The ContentType function constructs a full content-type string by prepending the 'application/' prefix to a given subtype. The ContentSubtype function extracts the subtype from a full content-type header, handling edge cases like missing separators or malformed headers. Tests have been added to verify the correct behavior of both functions.

internal/httputil · high confidence

Add HTTP to gRPC status code conversion

A new status converter has been introduced to map HTTP status codes to gRPC codes and vice versa. The implementation includes a default converter that maps standard HTTP error codes (such as 400, 401, 403, 404, 409, 429, 500, 501, 503, 504) to their corresponding gRPC status codes (e.g., InvalidArgument, Unauthenticated, NotFound, Aborted, ResourceExhausted, Internal, Unimplemented, Unavailable, DeadlineExceeded). It also supports the non-standard 499 (ClientClosed) mapping to Canceled, and maps gRPC codes like FailedPrecondition to HTTP 412 (Precondition Failed). This allows for seamless error handling and translation between HTTP and gRPC error states.

transport/http/status · high confidence

Add JSON and MessagePack encoding codecs

Users can now serialize and deserialize data using JSON and MessagePack formats. The JSON codec supports standard Go types, custom JSON marshalers, and Google Protobuf messages, while the new MessagePack codec provides a binary serialization alternative. Both are automatically registered with the framework's encoding registry.

contrib/encoding · high confidence

Add JSON encoding/decoding codec

The \encoding/json\ package now provides a \json\ codec that registers with the framework's encoding registry. This enables automatic JSON serialization and deserialization for HTTP and other transports, supporting both standard structs and custom \json.Marshaler\/\json.Unmarshaler\ interfaces.

encoding/json · high confidence

Add JWT and protovalidate middleware implementations

The \contrib/middleware/jwt\ package introduces a new JWT authentication middleware for both server and client sides, supporting custom signing methods, claims, and parser options. Additionally, the \contrib/middleware/validate\ package provides a new validation middleware that supports both the modern \protovalidate\ library and legacy \protoc-gen-validate\ generated validators, enabling request parameter validation via \.proto\ schema definitions.

contrib/middleware · high confidence

Add Kratos CLI upgrade command

Users can now run 'kratos upgrade' to update the Kratos tooling. The new command installs the latest versions of the Kratos CLI, gRPC/HTTP/Errors code generators, and the OpenAPI generator via 'go install'.

cmd/kratos/internal/upgrade · high confidence

Add Kubernetes Config Source for Config Management

Users can now load configuration from Kubernetes ConfigMaps using the new \contrib/config/kubernetes\ package. This feature allows applications to read configuration data from Kubernetes resources, supporting both in-cluster and out-of-cluster (kubeconfig) authentication. The implementation includes a \NewSource\ function that accepts options for namespace, label/field selectors, and kubeconfig paths, and provides a \Watch\ capability to monitor ConfigMap changes in real-time.

contrib/config/kubernetes · high confidence

Add Kubernetes service registry implementation

Introduces a new Kubernetes-based service registry for the Kratos framework. The \contrib/registry/kubernetes\ package provides a \Registry\ that discovers and registers services by reading Pod labels and annotations (e.g., \kratos-service-id\, \kratos-service-app\). It utilizes Kubernetes informers to watch for pod changes and exposes unit tests to verify the registration, discovery, and deregistration workflows.

contrib/registry/eureka, contrib/registry/kubernetes · high confidence

Add MCP transport support for Kratos

Users can now expose services using the Model Context Protocol (MCP) via a new \contrib/transport/mcp\ module. This addition provides an HTTP server implementation that supports SSE (Server-Sent Events) and allows registering tools with handlers, enabling Kratos applications to serve MCP endpoints directly.

contrib/transport · high confidence

Add Nacos config source and watcher

Users can now load and watch configuration from a Nacos server. The \contrib/config/nacos\ package provides a \config.Source\ implementation that supports specifying a data ID and group, and enables hot-reloading of configuration changes via a \config.Watcher\.

contrib/config/nacos · high confidence

Add OpenSergo integration for service metadata reporting

Users can now integrate OpenSergo with Kratos to automatically report service metadata. The new \contrib/opensergo\ package provides a \New\ constructor that connects to an OpenSergo endpoint and exposes a \ReportMetadata\ method. This method scans the application's gRPC and HTTP service descriptors, extracting details such as service names, method signatures, HTTP paths, and message types, then sends this information to the OpenSergo server for discovery and management.

contrib/opensergo · high confidence

Add OpenTelemetry integration modules for logging, metrics, and tracing

The Kratos framework now includes new OpenTelemetry (OTel) contrib modules for logging, metrics, and tracing. The \contrib/otel/log\ package provides a \slog\ handler bridge that automatically injects trace and span IDs into log records. The \contrib/otel/metrics\ package offers server and client middleware for collecting request counts and latencies. The \contrib/otel/tracing\ package provides server and client middleware for creating and managing spans, along with a metadata propagator for service name propagation. These additions enable comprehensive observability across the application.

(repo-wide) · high confidence

Add P2C (Pick of 2 Choices) load balancer

A new P2C load balancer implementation has been added to the selector package. It provides a 'pick of two choices' strategy that selects between two distinct nodes based on their weights, with a fallback mechanism to force-pick a node if it hasn't been selected within a 3-second window. The implementation includes a builder pattern for construction and is accompanied by unit tests verifying selection distribution and edge cases.

selector/p2c · high confidence

Add Polaris config source and watcher for Kratos v3

Users can now load and watch configuration from a Polaris server using the v3 API. The new \contrib/config/polaris\ package provides a \config.Source\ and \config.Watcher\ that fetch a specific config file (namespace, fileGroup, fileName) and subscribe to changes, allowing applications to dynamically update their configuration at runtime.

contrib/config/polaris · high confidence

Add Polaris integration for configuration, service governance, and rate limiting

The contrib/polaris package now provides a unified interface to the Polaris service mesh platform. Users can load and watch configuration files via the new Config source, register and discover services with the Registry component, apply dynamic routing rules through the NodeFilter selector, and enforce rate limits using the Limiter middleware. This adds support for Polaris-based config management, service governance, and request throttling within the Kratos framework.

contrib/polaris · high confidence

Add Sentry error tracking middleware for Kratos

A new Sentry integration is added to the \contrib/errortracker/sentry\ package, providing HTTP and gRPC server middleware that automatically captures panic errors and reports them to Sentry. The implementation includes configuration options for tags, context-based metadata, and delivery behavior, accompanied by unit tests for the new middleware options.

contrib/errortracker · high confidence

Add Servicecomb registry implementation

Introduces a new Servicecomb registry provider for the Kratos framework, enabling service registration, discovery, and health-check heartbeats via the go-chassis/sc-client. The implementation includes the core registry logic (registry.go), a watcher for service instance changes (watcher.go), and corresponding unit tests (registry\_test.go).

contrib/registry/servicecomb · high confidence

Add Tencent Polaris service registry implementation

Users can now register and discover services using the Tencent Polaris service mesh platform. This new registry implementation supports configuring namespace, service tokens, protocol, weight, priority, health status, isolation, TTL, timeout, retry count, and heartbeat settings, enabling seamless integration with Polaris for service discovery and registration.

contrib/registry/polaris · high confidence

Add Weighted Round Robin (WRR) load balancing algorithm

The selector/wrr package introduces a new Weighted Round Robin balancer that distributes traffic to backend nodes based on their assigned weights. The implementation tracks each node's current weight and selects the node with the highest cumulative weight, then reduces its weight by the total weight of all available nodes to ensure fair distribution over time. The code includes logic to clean up stale entries in the weight map when the set of available nodes changes, preventing memory leaks and ensuring accurate load balancing as services scale up or down.

selector/wrr · high confidence

Add XML encoding/decoding support

Users can now encode and decode data to and from XML format. The new XML codec registers itself with the encoding framework, allowing seamless serialization and deserialization of Go structs to and from XML strings, with tests confirming correct handling of plain values, nested structures, and nil unmarshalling.

encoding/xml, encoding/yaml · high confidence

Add changelog command to Kratos CLI

A new 'changelog' subcommand has been added to the Kratos CLI, allowing users to retrieve release notes or commit information for the Kratos repository. The command supports fetching the latest release or a specific version, and can also display development commits. It parses GitHub release data and commit messages, grouping them into categories such as 'Breaking Changes', 'Dependencies', 'New Features', 'Bug Fixes', 'Builds', 'Chores', and 'Others' for a structured output.

cmd/kratos/internal/change · high confidence

Add client-side circuit breaker middleware

Introduces a new circuit breaker middleware for client-side requests. The middleware intercepts requests and, when the circuit breaker is triggered, rejects the request with a 503 error (ErrNotAllowed) without invoking the underlying handler. It tracks success and failure states to manage the circuit breaker's condition, supporting custom breaker factories and grouping by operation.

middleware/circuitbreaker · high confidence

Add direct node implementation for service selection

A new direct node implementation is introduced in the selector/node/direct package, providing a concrete Node and Builder that wrap underlying selector nodes. Users can now construct direct nodes that track pick timestamps and expose weight and elapsed time information, with tests confirming default and custom weight handling.

selector/node/direct · medium confidence

Add encoding package with Codec interface and registration

The encoding package introduces a new Codec interface that defines how messages are encoded and decoded for transport, requiring thread-safe Marshal, Unmarshal, and Name methods. It provides a global registry for codecs, allowing users to register custom codecs via RegisterCodec and retrieve them by content-subtype using GetCodec. The package includes a README with usage instructions for the msgpack codec and comprehensive tests verifying that registering nil or invalid codecs panics with specific error messages, and that valid codecs can be registered and retrieved correctly.

encoding · high confidence

Add environment variable configuration source

The config/env package now provides a new Source that loads configuration from environment variables. Users can pass optional prefixes to filter environment variables and strip them from keys, allowing structured configuration from the environment to be merged with file-based sources.

config/env · high confidence

Add file-based configuration source with hot-reload support

The \config/file\ package now provides a \file\ implementation of the \config.Source\ interface, allowing applications to load configuration from local files or directories. The \NewSource\ function creates a source that can read JSON, YAML, or other formats based on file extension, and the \Watch\ method enables hot-reload capabilities by monitoring file system changes via \fsnotify\. This introduces a new way to manage configuration that automatically updates when the underlying files are modified.

config/file · high confidence

Add form encoding/decoding support for Protobuf messages

Users can now encode and decode Protobuf messages to and from \application/x-www-form-urlencoded\ format. The new \encoding/form\ package provides a codec that handles standard Go types, Protobuf messages, and well-known types (such as \Timestamp\, \Duration\, \FieldMask\, and \BytesValue\). This enables seamless binding of form data to Protobuf structures in HTTP handlers.

encoding/form · high confidence

Add host address extraction utilities

The internal/host package now provides functions to extract host and port from addresses, validate IP addresses, and retrieve the port from a listener. The Extract function returns a private address and port, preferring IPv4 over IPv6, and iterates through network interfaces to find the minimum index IP that is valid and not a loopback or multicast address. Tests are added to verify the behavior of these new functions.

internal/host · high confidence

Add metadata middleware for propagating and injecting HTTP headers

Introduces a new \middleware/metadata\ package that provides server and client middleware functions (\Server\ and \Client\) to manage metadata propagation. The server-side middleware extracts headers with specific prefixes (defaulting to \x-md-\) and adds them to the context. The client-side middleware injects metadata from the context into outgoing request headers, supporting both constant values and propagated prefixes. This enables consistent header handling across service boundaries.

middleware/metadata · high confidence

Add middleware chaining support

A new middleware package has been introduced, providing a \Chain\ function that allows multiple middleware functions to be composed into a single handler. This enables the application of a sequence of HTTP or gRPC transport middleware in a configurable order, with corresponding tests verifying the chained execution order and state updates.

middleware · high confidence

Add middleware selector for conditional middleware application

A new \middleware/selector\ package has been introduced, providing a builder pattern to conditionally apply middleware based on operation name, path, or a custom function. Users can now configure server or client middleware to activate only for specific routes or via a provided \MatchFunc\, enabling more granular control over middleware execution in Kratos applications.

middleware/selector · high confidence

Add pprof HTTP handler for debugging

A new pprof HTTP handler has been added to the transport layer, exposing standard Go profiling endpoints (index, cmdline, profile, symbol, and trace) under the /debug/pprof/ path. This provides users with immediate access to runtime profiling data for debugging and performance analysis.

transport/http/pprof · high confidence

Add protobuf codec implementation and tests

The \encoding/proto\ package now provides a \proto\ codec that registers itself with the encoding framework, enabling serialization and deserialization of protobuf messages. The implementation includes the core \Marshal\ and \Unmarshal\ logic along with comprehensive unit tests verifying the codec's behavior with test data models.

encoding/proto · high confidence

Add random load balancer selector

Introduces a new random load balancer implementation in the \selector/random\ package, providing a \Balancer\ that selects nodes using \math/rand/v2\. The change includes the core \random.go\ implementation and \random\_test.go\ which validates the random selection logic with statistical bounds.

selector/random · high confidence

Add rate-limiting middleware to Kratos

A new rate-limiting middleware is introduced for the Kratos framework. It provides a server-side middleware that enforces request limits using a configurable Limiter interface. When the rate limit is exceeded, the middleware returns a 429 error with the message "service unavailable due to rate limit exceeded". Users can customize the rate-limiting behavior by providing their own Limiter implementation via the \WithLimiter\ option.

middleware/ratelimit · high confidence

Add recovery middleware with panic handling and latency tracking

Introduces a new recovery middleware that catches panics during request processing, logs the error details including a stack trace, and records the recovery latency in the request context. Users can now configure a custom error handler and a custom logger for panic events, with the default behavior returning an Internal Server Error.

middleware/recovery · high confidence

Add validation middleware supporting custom validators and self-validating types

A new validation middleware has been added to the framework, allowing requests to be validated before they reach the handler. The middleware supports two validation strategies: types implementing a \Validate() error\ method (e.g., for Google AIP field behavior checks) and custom \ValidatorFunc\ functions (e.g., for protovalidate or other external validation libraries). This provides a flexible way to enforce request constraints, with validation failures returning a \BAD\_REQUEST\ error.

middleware/validate · high confidence

Add version-based node filtering for service selectors

Users can now filter service nodes by version using the new \Version\ filter in the selector package. This allows routing or selection logic to target specific service versions, as demonstrated by the new \version.go\ implementation and its corresponding unit test \version\_test.go\.

selector/filter · high confidence

Added EWMA-based node weighting for load balancing

The EWMA (Exponentially Weighted Moving Average) node implementation has been added to the selector package. This introduces a new weighted node strategy that calculates node weights based on recent latency and error rates, allowing the load balancer to prefer healthier and faster endpoints. The change includes the core node logic and its associated unit tests.

selector/node/ewma · high confidence

Added Google API and Protobuf descriptor protos to third\_party

Added Google API and Protobuf descriptor proto files (annotations, client, field\_behavior, http, httpbody, and descriptor) to the third\_party/google directory. These files define standard Google API configurations and Protobuf reflection structures, enabling support for HTTP/gRPC transcoding, field behavior annotations, and service/client options in API definitions.

_third\party/google · medium confidence

Added context merging utility

The internal context package now provides a Merge function that combines two parent contexts into a single context. This new utility allows callers to wait for the cancellation or timeout of either parent context, with the merged context's deadline set to the earliest of the two parents' deadlines.

internal/context · high confidence

Added direct gRPC resolver for connecting to specific addresses

Users can now use a 'direct' scheme (e.g., direct://127.0.0.1:9000) to connect to specific addresses. This new resolver parses the target URL path to extract a list of addresses and updates the client connection state accordingly.

transport/grpc/resolver/direct · high confidence

Added helloworld testdata with generated Go code for the Greeter service

New files were added to internal/testdata/helloworld, including the helloworld.proto definition, the generated Go code (helloworld.pb.go, helloworld\_grpc.pb.go, helloworld\_http.pb.go), and a generate.go script. This provides a complete, self-contained example of a gRPC and HTTP service implementation for testing purposes.

internal/testdata/helloworld · high confidence

Added internal lazy-load container for object pooling

A new internal package, internal/group, has been introduced to provide a thread-safe, lazy-loading container. This component caches created objects by key, ensuring that each unique key triggers the factory function only once. It supports resetting the factory and clearing all cached objects, offering a reusable pattern for lazy initialization within the codebase.

internal/group · high confidence

Added proto server code generation command

The \kratos proto server\ command has been added to the Kratos CLI, allowing users to generate Go server-side implementations from \.proto\ files. This new feature parses the proto definitions and produces structured Go code templates for services, including support for unary, client, server, and bi-directional streaming RPCs, with automatic handling of \google.protobuf.Empty\ types.

cmd/kratos/internal/proto/server · high confidence

Added protoc-gen-validate (PGV) proto definitions

The repository now includes the \validate.proto\ file and a README for \protoc-gen-validate\ (PGV) in the \third\_party/validate\ directory. This adds the standard protobuf definitions for field-level validation rules (such as \FloatRules\, \Int32Rules\, \StringRules\, etc.), enabling downstream code generators to produce validation logic based on these proto annotations.

_third\party/validate · high confidence

Added selector-based middleware matching

The internal/matcher package now provides a new middleware matching mechanism that allows registering specific or prefix-based selectors to apply different sets of middleware to different operations. This enables more granular control over middleware execution based on operation names or path prefixes, with support for both exact matches and wildcard prefix matching.

internal/matcher · high confidence

Consul registry implementation added

The Consul registry implementation has been added to the codebase, providing full support for service registration, discovery, and health checks. Users can now configure the Consul registry with options for datacenter selection, heartbeat management, custom service checks, and service resolvers. The implementation supports both single and multi-datacenter service discovery, allowing users to retrieve services from multiple datacenters. Additionally, the registry supports custom tags for service registration and provides options to control health check intervals and deregistration of critical services.

contrib/registry/consul, contrib/registry/zookeeper · high confidence

Introduce 'kratos proto client' command for generating proto client code

A new 'client' subcommand has been added to the Kratos CLI, allowing users to generate Go client code from .proto files. The command automatically checks for and installs required protoc plugins (such as protoc-gen-go, protoc-gen-go-grpc, and protoc-gen-openapi) if they are missing, and supports generating code for HTTP, gRPC, and error types. It also integrates with the validate plugin when the proto file imports 'validate/validate.proto'.

cmd/kratos/internal/proto/client · high confidence

Introduce Kratos v3 application lifecycle and configuration

The repository now includes the core application lifecycle manager (\App\), its configuration options, and associated tests. This introduces the \App\ struct which manages the application's start, stop, and signal handling, along with options for service name, version, metadata, endpoints, and lifecycle hooks (BeforeStart, AfterStart, BeforeStop, AfterStop). The change also adds the \version.go\ file setting the release version to \v3.0.0\, signaling the v3 release.

(repo-wide) · high confidence

Introduce \`kratos new\` and \`kratos add\` commands for project scaffolding

The \cmd/kratos\ CLI now supports creating new projects and adding services via \kratos new\ and \kratos add\ commands. Users can generate a new service or admin template from remote repositories, with support for custom layout repos, branch selection, and a \--nomod\ flag to retain existing Go modules. The implementation includes platform-specific tests for path handling on Linux and Windows.

cmd/kratos/internal/project · high confidence

Introduce \`kratos proto add\` command for generating proto API templates

Users can now use the \kratos proto add\ command to generate a standard proto API template. The command accepts a hierarchical path to a \.proto\ file, validates that the path is hierarchical, and generates the corresponding Go and Java package structures. The implementation includes a test suite verifying the correct conversion of underscore-separated names to upper camel case.

cmd/kratos/internal/proto/add · high confidence

Introduce automated linting and testing infrastructure for multi-module project

Added new shell scripts (tools.sh, resolve-modules.sh, util.sh) and configuration files (.lintcheck\_failures, .test\_ignored\_files) to automate running golangci-lint and Go tests across all Go modules in the repository. The system identifies modules with known lint failures or test issues and excludes them from automated checks, allowing the project to incrementally improve code quality without blocking the entire CI pipeline.

hack · high confidence

Introduce gRPC transport implementation with client/server, balancer, and codec support

The gRPC transport layer is now implemented in the \transport/grpc\ package, providing a complete set of components for gRPC communication. This includes a \Client\ with options for endpoint, timeout, middleware, TLS, and discovery, as well as a \Server\ supporting unary and stream interceptors, middleware, and health checks. A custom load balancer (\selector\) is registered to integrate with the global selector, and a JSON codec is registered for protobuf message serialization. The implementation also includes a \Transport\ struct that exposes transport metadata and headers, along with comprehensive unit tests for all components.

transport/grpc · high confidence

Introduce new config package with generic Get and observer-based watching

The \config\ package has been refactored to provide a cleaner, more robust configuration API. Users can now use the generic \Get\[T\]\ function to retrieve typed configuration values directly, and the \Watch\ method now supports observer-based notifications when configuration values change. The internal \reader\ and \merge\ logic have been restructured to support deep merging of configuration sources and resolution of placeholders (e.g., \${key:default}\) with improved type conversion and error handling.

config · high confidence

Introduce new discovery resolver implementation for gRPC

The gRPC transport layer now includes a new discovery resolver implementation located in \transport/grpc/resolver/discovery\. This adds \builder.go\ and \resolver.go\ files that handle service discovery by watching for endpoint changes and updating the gRPC resolver state. The implementation supports configurable timeouts, insecure mode, and subset selection, and includes corresponding unit tests in \builder\_test.go\ and \resolver\_test.go\.

transport/grpc/resolver/discovery · high confidence

Introduce new errors package with HTTP/gRPC status mapping

The \errors\ package now provides a structured \Error\ type that maps between HTTP status codes, gRPC status codes, and standard Go errors. It includes helper functions like \BadRequest\, \Unauthorized\, and \IsNotFound\ to create and check specific HTTP error codes, as well as \FromError\ to convert gRPC or standard errors into the structured format. The package also re-exports \Is\, \As\, and \Unwrap\ from the standard library for error chain handling.

errors · high confidence

Introduce new structured logging middleware with request/response redaction

The logging middleware has been rewritten to use Go's standard \log/slog\ library, providing structured logging for both server and client requests. The middleware now extracts and logs transport details (kind, operation), request arguments, latency, and error information. A new \Redacter\ interface allows sensitive data in request objects to be safely redacted in logs, while the \extractArgs\ helper safely stringifies request parameters. Tests confirm that the middleware correctly logs HTTP and gRPC requests, handling both success and error states with appropriate log levels.

middleware/logging · high confidence

Introduce protoc-gen-go-errors for automatic error code generation

The \cmd/protoc-gen-go-errors\ plugin is introduced to automatically generate Go code for handling gRPC/HTTP error codes defined in Protobuf enums. It adds a new code generator that reads \errors.code\ and \errors.default\_code\ extensions from \.proto\ files and produces Go functions (e.g., \IsSystemError\, \ErrorSystemError\) to check and create typed errors. The change includes the plugin's Go source (\main.go\, \errors.go\, \template.go\), the associated Protobuf definitions (\errors.proto\), and configuration files (\buf.gen.yaml\, \buf.yaml\, \buf.lock\) to support the new generator.

cmd/protoc-gen-go-errors · high confidence

Introduce the 'proto' command for generating Protocol Buffer files

The 'proto' command has been added to the Kratos CLI, allowing users to generate Protocol Buffer files. This command serves as a parent command that aggregates subcommands for adding, client generation, and server generation, all imported from the internal proto package.

cmd/kratos/internal/proto · high confidence

Introduce weighted node selection and global selector configuration

The selector package now supports weighted node selection through a new \WeightedNode\ interface and \Balancer\ abstraction, allowing the default selector to filter and pick nodes based on calculated weights. A \NodeFilter\ mechanism is added to the \SelectOptions\, enabling runtime filtering of candidate nodes before selection. Additionally, a global selector builder is introduced via \SetGlobalSelector\ and \GlobalSelector\ to allow overriding the default selector implementation globally.

selector · high confidence

Introduced etcd registry implementation for service discovery

Added a new etcd-based registry implementation that enables service registration, deregistration, and discovery via etcd. The registry uses the service namespace, name, and ID to form unique keys, manages lease-based heartbeats to maintain service availability, and provides a watcher to monitor service instance changes. This adds a new backend for service discovery in the contrib/registry/etcd module.

contrib/registry/etcd · high confidence

Introduces a new metadata package for handling request headers

A new \metadata\ package has been added to the codebase, providing a \Metadata\ type that maps string keys to multiple string values. This component supports standard header operations such as \Add\, \Set\, \Get\, and \Values\, along with context-based storage for both client and server metadata. The implementation includes deep-copying capabilities via \Clone\ and context integration functions like \NewServerContext\ and \AppendToClientContext\.

metadata · high confidence

Introduces core transport abstractions and context helpers

The transport package now defines the foundational interfaces for transport behavior: Server, Endpointer, Header, and Transporter. The Transporter interface provides access to transport-specific details such as Kind (e.g., 'grpc', 'http'), Endpoint, Operation, and request/reply headers. Additionally, context helpers (NewServerContext, FromServerContext, NewClientContext, FromClientContext) are added to store and retrieve the Transporter in the context. This change establishes the core data structures and context mechanisms used by the transport layer.

transport · high confidence

Migrate protoc-gen-go-http to Kratos v3 with new code generation architecture

The \protoc-gen-go-http\ plugin has been rewritten to target the Kratos v3 framework, replacing the previous implementation. This introduces a new code generation structure with dedicated files for the plugin entry point, template execution, and HTTP handler generation. The generator now produces Go code that registers HTTP routes and client stubs compatible with Kratos v3's transport layer, including support for streaming methods via WebSocket and server-sent events, while maintaining backward compatibility flags like \omitempty\. The plugin version is set to v3.0.0.

cmd/protoc-gen-go-http · high confidence

Nacos registry integration for service discovery and registration

The Nacos registry implementation has been added to the Kratos framework, enabling service registration, deregistration, and discovery via the Nacos service registry. The \contrib/registry/nacos\ package provides a \Registry\ struct that implements \registry.Registrar\ and \registry.Discovery\ interfaces, allowing applications to register themselves with a Nacos server and watch for service instance changes. The implementation includes a \watcher\ that subscribes to Nacos service updates and returns the latest list of service instances. A fake client and mock are also provided for testing purposes. This change adds a new feature for integrating with Nacos for service discovery.

contrib/registry/nacos · high confidence

New HTTP transport implementation with client, context, and encoding support

The HTTP transport layer has been refactored to provide a complete, modernized interface for HTTP-based communication. This includes a new \Client\ implementation that supports service discovery, middleware, and custom encoders/decoders. A new \Context\ wrapper provides convenient methods for binding request data (query, form, vars) and returning responses (JSON, XML, string, blob). The update also introduces robust path template building for request construction, a \Redirector\ interface for handling HTTP redirects, and a \FilterChain\ for middleware composition. These changes collectively replace the previous, simpler HTTP transport with a more feature-rich and extensible architecture.

transport/http · high confidence

New base utilities for Go module and repository management

The \cmd/kratos/internal/base\ package now includes new helper functions to manage Go modules and Git repositories. \GoInstall\ allows installing Go packages via \go install\. \ModulePath\ and \ModuleVersion\ read \go.mod\ files to extract module paths and versions. \KratosMod\ locates the local cache for the Kratos framework. \Repo\ provides methods to clone, pull, and copy Git repositories, including support for SCP-style URLs (e.g., \[e-mail redacted]:...\). Tests are added for these new capabilities.

cmd/kratos/internal/base · high confidence

New endpoint parsing and URL construction utilities

Added new internal endpoint utilities to simplify endpoint management. The \NewEndpoint\ function constructs URL objects from a scheme and host, while \ParseEndpoint\ extracts the host from a list of endpoint strings matching a specific scheme. Additionally, the \Scheme\ helper function appends 's' to a base scheme (e.g., 'http' to 'https', 'grpc' to 'grpcs') based on a secure flag. These changes provide a standardized way to handle endpoint URLs and scheme transformations within the application.

internal/endpoint · medium confidence

Behavioural changes

Add third-party error definitions for Kratos v3

A new Protobuf definition file is added to the project, introducing standard error code extensions for the Kratos framework. This change adds proto3 definitions that map error codes to both Go and Java packages, enabling structured error handling consistent with Kratos v3 conventions.

_third\party/errors · medium confidence

Log package refactored to use Go's standard library slog

The log package has been rewritten to wrap the standard library's \log/slog\ instead of a custom implementation. This introduces a new builder API (\NewHandler\, \NewLogger\) that supports text or JSON output, context-aware attributes, and a filter mechanism to redact sensitive keys or drop records. Global helpers (\Info\, \Debug\, etc.) now mirror \slog\ signatures, and context attributes are automatically propagated through log calls.

log · high confidence

Migrate validation library from PGV to protovalidate

The project has replaced the deprecated protobuf-go-validation (PGV) library with the new protovalidate library. This update brings a new set of validation constraints and rules defined in the \buf.validate\ package, allowing for more robust and modern validation of incoming messages using Common Expression Language (CEL) expressions.

_third\party/buf · medium confidence

Registry package introduces ServiceInstance equality and documentation

The registry package now includes a README.md file documenting the available service discovery implementations (Consul, Etcd, Zookeeper, Nacos, Kubernetes, and Polaris) and their corresponding Go module paths. Additionally, the ServiceInstance struct in registry.go now implements an Equal method that compares instances by sorting and comparing endpoints and metadata, ensuring consistent equality checks for gRPC attributes.

registry · high confidence

Test coverage

Add complex protobuf test data; Added test data for binding field mask and optional fields; Added test data for encoding with protobuf Struct support.

Dependencies

Kratos CLI upgraded to v3

The Kratos command-line interface has been upgraded to version 3.0.0. This update introduces new subcommands for managing project scaffolding, generating Protobuf clients and servers, performing upgrades, viewing changelogs, and running applications, all accessible through the updated CLI tool.

cmd/kratos · high confidence

Update Go toolchain and dependencies for the Kratos CLI and code generators

The \cmd/kratos\ CLI tool, along with \protoc-gen-go-errors\ and \protoc-gen-go-http\ code generators, have been updated to use Go 1.25.0 and upgraded to the Kratos v3 module structure. This includes updating dependencies such as \google.golang.org/protobuf\ to v1.36.11, \github.com/spf13/cobra\ to v1.10.2, and \golang.org/x/text\ to v0.37.0, ensuring compatibility with the latest Go toolchain and modernizing the command-line interface.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 57 → 59 (+1.9)
  • Rubric changed (rubric-2026.08.19 → rubric-2026.09.15) — scores are not directly comparable.

Lenses

  • Code Health 83 → 90 (+6.4)
  • Architecture 99 → 84 (-15.1)
  • Maturity 57 → 57 (-0.1)
  • Readiness 91 → 75 (-16.5)
  • Security 40 → 49 (+8.8)

Resolved (50)

  • Change coupling: version.go ↔ version.go (cmd/kratos/version.go)
  • Change coupling: version.go ↔ version.go (cmd/protoc-gen-go-errors/version.go)
  • Change coupling: version.go ↔ version.go (cmd/protoc-gen-go-http/version.go)
  • Coverage not included — suite not readable by the collector
  • Critical CVE: [GHSA redacted] (contrib/registry/nacos/go.mod)
  • Dependency hygiene not measured — dependency manifest found but not parsed for hygiene
  • Duplicated block (10 lines × 2) (middleware/logging/logging.go)
  • Duplicated block (12 lines × 2) (cmd/kratos/internal/project/add.go)
  • Duplicated block (13 lines × 2) (transport/grpc/server.go)
  • Duplicated block (13 lines × 4) (contrib/polaris/registry.go)
  • Duplicated block (14 lines × 2) (contrib/otel/metrics/metrics.go)
  • Duplicated block (14 lines × 2) (middleware/logging/logging.go)
  • Duplicated block (18 lines × 2) (contrib/polaris/registry.go)
  • Duplicated block (7 lines × 2) (cmd/kratos/internal/project/add.go)
  • Duplicated block (7 lines × 2) (middleware/logging/logging.go)
  • Duplicated block (8 lines × 2) (contrib/otel/tracing/span.go)
  • Duplicated block (8 lines × 2) (contrib/registry/eureka/register.go)
  • Duplicated block (8 lines × 2) (log/log.go)
  • Duplicated block (8 lines × 2) (transport/http/client.go)
  • Duplicated block (8 lines × 2) (transport/http/stream.go)
  • …and 30 more

New (130)

  • Base-context workflow trigger runs with an unscoped token
  • Change-coupling hub: version.go → version.go, version.go, version.go (version.go)
  • Critical CVE: [GHSA redacted] (contrib/registry/nacos/go.mod)
  • Dependency pinned to a stale untagged commit: github.com/opensergo/opensergo-go
  • Documentation: no installation or build instructions (README.md)
  • Duplicated block (10 lines × 2) (middleware/logging/logging.go)
  • Duplicated block (10 lines × 2) (selector/random/random.go)
  • Duplicated block (11 lines × 2) (contrib/otel/tracing/span.go)
  • Duplicated block (11 lines × 4) (transport/grpc/client.go)
  • Duplicated block (12 lines × 2) (cmd/kratos/internal/project/add.go)
  • Duplicated block (12 lines × 6) (contrib/polaris/registry.go)
  • Duplicated block (13 lines × 2) (middleware/logging/logging.go)
  • Duplicated block (14 lines × 2) (transport/grpc/server.go)
  • Duplicated block (16 lines × 2) (middleware/logging/logging.go)
  • Duplicated block (18 lines × 2) (contrib/polaris/registry.go)
  • Duplicated block (32 lines × 2) (contrib/otel/metrics/metrics.go)
  • Duplicated block (5 lines × 2) (cmd/kratos/internal/proto/add/add.go)
  • Duplicated block (7 lines × 2) (contrib/registry/discovery/discovery.go)
  • Duplicated block (7 lines × 2) (transport/grpc/balancer.go)
  • Duplicated block (8 lines × 2) (cmd/kratos/internal/project/add.go)
  • …and 110 more

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

go-kratos/kratos was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 24 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 668db92c2c001e9552594ba5a8aede8456af6d7e — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-5f8d0eb43fd7.