diff --git a/internal/fingerprint/types.go b/internal/fingerprint/types.go index 82d5f3e3..f1bc8b04 100644 --- a/internal/fingerprint/types.go +++ b/internal/fingerprint/types.go @@ -61,7 +61,7 @@ type ( } ) -func Map[K comparable, V any, H Hashable](m map[K]V, fn func(K, V) (string, H)) Hashable { +func Map[K comparable, V any, H Hashable](m map[K]V, fn func(K, V) (string, H)) mapped[H] { res := make(mapped[H], 0, len(m)) for key, val := range m { diff --git a/internal/injector/aspect/advice/code/template.go b/internal/injector/aspect/advice/code/template.go index f72588c7..226652b3 100644 --- a/internal/injector/aspect/advice/code/template.go +++ b/internal/injector/aspect/advice/code/template.go @@ -226,6 +226,7 @@ func (t *Template) Hash(h *fingerprint.Hasher) error { "template", fingerprint.Map(t.Imports, func(k string, v string) (string, fingerprint.String) { return k, fingerprint.String(v) }), fingerprint.String(t.Source), + t.Lang, ) } diff --git a/internal/injector/aspect/context/golang.go b/internal/injector/aspect/context/golang.go index 0e239c0d..7d72e938 100644 --- a/internal/injector/aspect/context/golang.go +++ b/internal/injector/aspect/context/golang.go @@ -9,6 +9,7 @@ import ( "fmt" "go/version" + "github.com/DataDog/orchestrion/internal/fingerprint" "gopkg.in/yaml.v3" ) @@ -53,6 +54,12 @@ func Compare(left GoLangVersion, right GoLangVersion) int { return version.Compare(version.Lang(left.label), version.Lang(right.label)) } +var _ fingerprint.Hashable = (*GoLangVersion)(nil) + +func (g GoLangVersion) Hash(h *fingerprint.Hasher) error { + return h.Named("GoLangVersion", fingerprint.String(g.label)) +} + var _ yaml.Unmarshaler = (*GoLangVersion)(nil) func (g *GoLangVersion) UnmarshalYAML(node *yaml.Node) error { diff --git a/internal/injector/aspect/join/join.go b/internal/injector/aspect/join/join.go index 4dd2b875..53ceedc0 100644 --- a/internal/injector/aspect/join/join.go +++ b/internal/injector/aspect/join/join.go @@ -9,7 +9,6 @@ package join import ( "bytes" - "errors" "fmt" "regexp" @@ -155,9 +154,5 @@ func (n TypeName) AsCode() jen.Code { } func (n TypeName) Hash(h *fingerprint.Hasher) error { - return errors.Join( - h.Named("path", fingerprint.String(n.path)), - h.Named("name", fingerprint.String(n.name)), - h.Named("pointer", fingerprint.Bool(n.pointer)), - ) + return h.Named("type-name", fingerprint.String(n.name), fingerprint.String(n.path), fingerprint.Bool(n.pointer)) } diff --git a/internal/injector/aspect/join/struct.go b/internal/injector/aspect/join/struct.go index ab141b5d..dddf1530 100644 --- a/internal/injector/aspect/join/struct.go +++ b/internal/injector/aspect/join/struct.go @@ -164,7 +164,7 @@ func (s *structLiteral) AsCode() jen.Code { } func (s *structLiteral) Hash(h *fingerprint.Hasher) error { - return h.Named("struct-literal", s.TypeName, fingerprint.String(s.Field), fingerprint.Int(s.Match)) + return h.Named("struct-literal", s.TypeName, fingerprint.String(s.Field), s.Match) } func init() { @@ -259,3 +259,7 @@ func (s StructLiteralMatch) asCode() jen.Code { } return jen.Qual(pkgPath, constName) } + +func (s StructLiteralMatch) Hash(h *fingerprint.Hasher) error { + return h.Named("struct-literal-match", fingerprint.Int(s)) +}