Skip to content

Commit

Permalink
fix: use %q instead of "%s" for free quote escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
nadiamoe authored and Nadia Santalla committed Dec 4, 2024
1 parent de8e948 commit 6bfec89
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/adhoc/adhoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ func (r *runner) Run(ctx context.Context, tenantId model.GlobalID, publisher pus
tenantId: tenantId,
streams: Streams{
{
Labels: fmt.Sprintf(`{probe="%s",source="synthetic-monitoring",type="adhoc"}`, r.probe),
Labels: fmt.Sprintf(`{probe=%q,source="synthetic-monitoring",type="adhoc"}`, r.probe),
Entries: []logproto.Entry{
{
Timestamp: start,
Expand Down
2 changes: 1 addition & 1 deletion internal/scraper/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func addMetricToIndex(mf *dto.MetricFamily, index map[string]struct{}) {
for _, metric := range mf.GetMetric() {
labels := make([]string, 0, len(metric.GetLabel()))
for _, label := range metric.GetLabel() {
labels = append(labels, fmt.Sprintf(`"%s"="%s"`, label.GetName(), label.GetValue()))
labels = append(labels, fmt.Sprintf(`%q=%q`, label.GetName(), label.GetValue()))
}
sort.Strings(labels)
index[mf.GetName()+"{"+strings.Join(labels, ",")+"}"] = struct{}{}
Expand Down

0 comments on commit 6bfec89

Please sign in to comment.