mirror of
https://github.com/SigNoz/signoz.git
synced 2026-09-22 03:10:41 +01:00
<!--A few plain bullets saying what changed and why, for a reviewer skimming it - not a wall of text, not a restatement of the diff, not generated boilerplate.--> #### Description Until now every org started with no span mapper groups and we had to create `llm`, `agent` and `tool` by hand. This PR ships them as defaults. - The three groups live as JSON in the binary. On startup and when a new org is created, they get seeded. When we change a definition and bump its version, the next release updates the org's copy in place. - Anything SigNoz ships is marked `origin: system` and can only be switched on or off. Users can't rename or delete these groups and mappers, and can't take their names. Anything the user adds is theirs to edit or remove, including new mappers in a shipped group or new sources on a shipped mapper. - Upgrades keep the user's on/off choices and never touch their items. - Condition substrings and sources now carry `enabled` and `origin`, so a substring is an object instead of a plain string. Disabled ones are left out of the collector config. - - Migration 127 only adds the `origin` and `version` columns. Stored JSON is not rewritten because these tables are empty on every instance. - Fixes creating a group or mapper with `enabled: false` being saved as true (the bun `default:true` tag turned false into SQL `DEFAULT`) Frontend: no UI changes. Generated client regenerated; drafts carry `enabled` and `origin` so saves from the existing screens round-trip shipped items intact. <!--Reference issues using `Closes #issue-number` to enable automatic closure on merge. --> #### Issues closed by this PR Closes https://github.com/SigNoz/engineering-pod/issues/5329 <!--Anything reviewers should keep in mind while reviewing --> #### Additional Information * Frontend follow-up: toggles for sources and substrings, "Default" badge and read-only rows for shipped items, hide rename/delete on system groups and mappers. * Deferred: per-group upgrade changelog ( will come back to this later) --------- Co-authored-by: Gaurav Tewari <gauravtewari111@gmail.com> Co-authored-by: Gaurav Tewari <tewarig@users.noreply.github.com>
47 lines
1.4 KiB
Go
47 lines
1.4 KiB
Go
package implspanmapper
|
|
|
|
import (
|
|
"embed"
|
|
"io/fs"
|
|
"path"
|
|
|
|
"github.com/SigNoz/signoz/pkg/errors"
|
|
"github.com/SigNoz/signoz/pkg/types/spantypes"
|
|
)
|
|
|
|
const definitionsRoot = "fs/definitions"
|
|
|
|
//go:embed fs/definitions/*.json
|
|
var definitionFiles embed.FS
|
|
|
|
// NewSystemGroupRegistry parses every embedded definition. Definitions are
|
|
// build-time assets validated by a test, so a failure here means the binary
|
|
// shipped broken JSON.
|
|
func NewSystemGroupRegistry() (spantypes.SpanMapperGroupRegistry, error) {
|
|
entries, err := fs.ReadDir(definitionFiles, definitionsRoot)
|
|
if err != nil {
|
|
return spantypes.SpanMapperGroupRegistry{}, errors.WrapInternalf(err, errors.CodeInternal, "couldn't read span mapper group definitions")
|
|
}
|
|
|
|
definitions := make([]spantypes.SpanMapperGroupDefinition, 0, len(entries))
|
|
for _, entry := range entries {
|
|
if entry.IsDir() {
|
|
continue
|
|
}
|
|
|
|
file := path.Join(definitionsRoot, entry.Name())
|
|
raw, err := definitionFiles.ReadFile(file)
|
|
if err != nil {
|
|
return spantypes.SpanMapperGroupRegistry{}, errors.WrapInternalf(err, errors.CodeInternal, "couldn't read %s", file)
|
|
}
|
|
|
|
definition, err := spantypes.NewSpanMapperGroupDefinition(raw)
|
|
if err != nil {
|
|
return spantypes.SpanMapperGroupRegistry{}, errors.Wrapf(err, errors.TypeInternal, errors.CodeInternal, "couldn't parse %s", file)
|
|
}
|
|
definitions = append(definitions, definition)
|
|
}
|
|
|
|
return spantypes.NewSpanMapperGroupRegistry(definitions)
|
|
}
|