MCPcopy Create free account
hub / github.com/cortexproject/cortex / Sign

Method Sign

pkg/cortexpb/extensions.go:65–100  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

63}
64
65func (w *WriteRequest) Sign(ctx context.Context) (string, error) {
66 u, err := users.TenantID(ctx)
67 if err != nil {
68 return "", err
69 }
70
71 s := signerPool.Get().(*signer)
72 defer func() {
73 s.Reset()
74 signerPool.Put(s)
75 }()
76 s.WriteString(u)
77
78 for _, md := range w.Metadata {
79 s.WriteString(strconv.Itoa(int(md.Type)))
80 s.WriteString(md.MetricFamilyName)
81 s.WriteString(md.Help)
82 s.WriteString(md.Unit)
83 }
84
85 for _, ts := range w.Timeseries {
86 for _, lbl := range ts.Labels {
87 s.WriteString(lbl.Name)
88 s.WriteString(lbl.Value)
89 }
90
91 for _, ex := range ts.Exemplars {
92 for _, lbl := range ex.Labels {
93 s.WriteString(lbl.Name)
94 s.WriteString(lbl.Value)
95 }
96 }
97 }
98
99 return fmt.Sprintf("%v/%v", signVersion, s.Sum64()), nil
100}

Callers 2

VerifySignMethod · 0.95
TestUnarySigningHandlerFunction · 0.95

Calls 6

ResetMethod · 0.95
TenantIDFunction · 0.92
WriteStringMethod · 0.80
Sum64Method · 0.80
GetMethod · 0.65
PutMethod · 0.65

Tested by 1

TestUnarySigningHandlerFunction · 0.76