SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
docs(go): require descriptive receiver names (#13391)
Vikrant Gupta1b8451650ac3
diff --git a/docs/contributing/go/abstractions.md b/docs/contributing/go/abstractions.mdindex 70185d70bc..4366e0f33f 100644--- a/docs/contributing/go/abstractions.md+++ b/docs/contributing/go/abstractions.md@@ -28,7 +28,7 @@ func ConvertConfig(src ExternalConfig) (InternalConfig, error)// Over this:type ConfigAdapter struct { ... }func NewConfigAdapter(src ExternalConfig) *ConfigAdapter-func (a *ConfigAdapter) ToInternal() (InternalConfig, error)+func (adapter *ConfigAdapter) ToInternal() (InternalConfig, error)```The two-step version is only justified when `ConfigAdapter` has multiple distinct consumers that use it in different ways.@@ -66,10 +66,10 @@ A method on a structured type should not strip meaning from the structure it bel```go// Problematic: callers cannot distinguish how items were related.-func (o *Order) AllLineItems() []LineItem { ... }+func (order *Order) AllLineItems() []LineItem { ... }// Better: the validation logic operates on the full structure.-func ValidateOrder(o *Order) error { ... }+func ValidateOrder(order *Order) error { ... }```Public methods shape how a type is used. Once a lossy accessor exists, callers will depend on it, and the lost information becomes unrecoverable at those call sites.diff --git a/docs/contributing/go/dslfilteringtosql.md b/docs/contributing/go/dslfilteringtosql.mdindex 1c2d968c27..e53dc426d2 100644--- a/docs/contributing/go/dslfilteringtosql.md+++ b/docs/contributing/go/dslfilteringtosql.md@@ -74,7 +74,7 @@ The `*Visitor` passed in provides everything needed to build predicates. Use theIn the simplest case, keys map straight to columns and the resolver is a switch. The doc's running example, an imaginary `sample_entity` table:```go-func (r sampleEntityFieldResolver) ResolveComparison(v *sqlcompiler.Visitor, key string, operation qbtypesv5.FilterOperator, ctx *grammar.ComparisonContext) string {+func (resolver sampleEntityFieldResolver) ResolveComparison(v *sqlcompiler.Visitor, key string, operation qbtypesv5.FilterOperator, ctx *grammar.ComparisonContext) string {switch key {case "created_by":return v.BuildStringOperation(v.Sb, ctx, operation, "sample_entity.created_by", key)diff --git a/docs/contributing/go/handler.md b/docs/contributing/go/handler.mdindex 4db1dbc7d9..a5a63bc1d5 100644--- a/docs/contributing/go/handler.md+++ b/docs/contributing/go/handler.md@@ -82,7 +82,7 @@ In the module implementation, implement the new method. A typical implementation- Uses the `render` package to write responses or errors```go-func (h *handler) CreateThing(rw http.ResponseWriter, req *http.Request) {+func (handler *handler) CreateThing(rw http.ResponseWriter, req *http.Request) {// Extract authentication and organization context from req.Context()claims, err := authtypes.ClaimsFromContext(req.Context())if err != nil {@@ -98,7 +98,7 @@ func (h *handler) CreateThing(rw http.ResponseWriter, req *http.Request) {}// Call module functions- out, err := h.module.CreateThing(req.Context(), claims.OrgID, &in)+ out, err := handler.module.CreateThing(req.Context(), claims.OrgID, &in)if err != nil {render.Error(rw, err)returndiff --git a/docs/contributing/go/packages.md b/docs/contributing/go/packages.mdindex e359a7d5f5..d2c0cc58a8 100644--- a/docs/contributing/go/packages.md+++ b/docs/contributing/go/packages.md@@ -59,7 +59,8 @@ Follow these rules:### Unexported symbols-- Struct receivers: one or two characters (`c`, `f`, `br`).+- Struct receivers: the lowercase name of the role the type plays, the same on every method of the type (`provider`, `module`, `handler`, `store`, `middleware`, `migration`). Never one or two characters: `c`, `h`, `m` say nothing at the call site and collide with local variables.+- When the receiver name would shadow an imported package, alias the import, not the receiver (`pkghandler "github.com/SigNoz/signoz/pkg/http/handler"` with a `handler` receiver).- Helper functions: descriptive lowercase names (`parseToken`, `buildQuery`).### Constantsdiff --git a/docs/contributing/go/service.md b/docs/contributing/go/service.mdindex 8b6e9d1560..a1e4af71e1 100644--- a/docs/contributing/go/service.md+++ b/docs/contributing/go/service.md@@ -70,16 +70,16 @@ The instrumentation SDK (`pkg/instrumentation/sdk.go`) is idle while running but```go// pkg/instrumentation/sdk.go-func (i *SDK) Start(ctx context.Context) error {- <-i.startCh+func (sdk *SDK) Start(ctx context.Context) error {+ <-sdk.startChreturn nil}-func (i *SDK) Stop(ctx context.Context) error {- close(i.startCh)+func (sdk *SDK) Stop(ctx context.Context) error {+ close(sdk.startCh)return errors.Join(- i.sdk.Shutdown(ctx),- i.meterProviderShutdownFunc(ctx),+ sdk.sdk.Shutdown(ctx),+ sdk.meterProviderShutdownFunc(ctx),)}```@@ -197,8 +197,8 @@ A standalone service only has the `factory.Service` lifecycle i.e it does not se}}- func (s *service) Start(ctx context.Context) error { ... }- func (s *service) Stop(ctx context.Context) error { ... }+ func (service *service) Start(ctx context.Context) error { ... }+ func (service *service) Stop(ctx context.Context) error { ... }```### Provider that is also a servicediff --git a/docs/contributing/go/types.md b/docs/contributing/go/types.mdindex 85289c984b..6d7a34e99e 100644--- a/docs/contributing/go/types.md+++ b/docs/contributing/go/types.md@@ -17,7 +17,7 @@ Two rules shape how the core type behaves:func NewGettableAuthDomainFromAuthDomain(d *AuthDomain, info *AuthNProviderInfo) *GettableAuthDomain// Receiver form- func (m *PlannedMaintenanceWithRules) ToPlannedMaintenance() *PlannedMaintenance+ func (maintenance *PlannedMaintenanceWithRules) ToPlannedMaintenance() *PlannedMaintenance```- **`X` can double as the storage row** when the DB shape would be identical. `Channel` embeds `bun.BaseModel` directly, and there is no `StorableChannel`. This is the preferred shape when it works.@@ -175,10 +175,10 @@ The rules that make the envelope work:```go// Domain invariants: every write path re-runs these.- func (x *X) Validate() error { ... }+ func (entity *X) Validate() error { ... }// Request-shape-only: checks that do not apply once the value is persisted.- func (p *PostableX) Validate() error { ... }+ func (postable *PostableX) Validate() error { ... }```- **Type aliases, not wrappers**, when two shapes are identical. `type GettableChannels = []*Channel` is correct because it adds no semantics beyond the underlying type.- **Serialization tags** follow [handler.md](handler.md): `required:"true"` means the JSON key must be present, `nullable:"true"` is required on any slice or map that may serialize as `null`, and types with a fixed value set must implement `Enum() []any`.