Repository: prometheus/prometheus
File: storage/remote/write_test.go (Go)

Code before:
				TranslationStrategy: config.NoUTF8EscapingWithSuffixes,
			},
			expectedSamples: []mockSample{
				{
					l: labels.New(labels.Label{Name: "__name__", Value: "test.counter_total"},
						labels.Label{Name: "foo.bar", Value: "baz"},
						labels.Label{Name: "instance", Value: "test-instance"},
						labels.Label{Name: "job", Value: "test-service"}),
					t: timestamp.UnixMilli(),
					v: 10.0,
				},
				{
					l: labels.New(
						labels.Label{Name: "__name__", Value: "target_info"},
						labels.Label{Name: "host.name", Value: "test-host"},
						labels.Label{Name: "instance", Value: "test-instance"},
						labels.Label{Name: "job", Value: "test-service"},
					),
					t: timestamp.UnixMilli(),
					v: 1,
				},
			},
		},
	} {
		t.Run(testCase.name, func(t *testing.T) {
			appendable := handleOtlp(t, exportRequest, testCase.otlpCfg)
			for _, sample := range testCase.expectedSamples {
				requireContainsSample(t, appendable.samples, sample)
			}
			require.Len(t, appendable.samples, 12)   // 1 (counter) + 1 (gauge) + 1 (target_info) + 7 (hist_bucket) + 2 (hist_sum, hist_count)
			require.Len(t, appendable.histograms, 1) // 1 (exponential histogram)
			require.Len(t, appendable.exemplars, 1)  // 1 (exemplar)
		})
	}
}

func handleOtlp(t *testing.T, exportRequest pmetricotlp.ExportRequest, otlpCfg config.OTLPConfig) *mockAppendable {
	buf, err := exportRequest.MarshalProto()
	require.NoError(t, err)

	req, err := http.NewRequest("", "", bytes.NewReader(buf))
	require.NoError(t, err)
	req.Header.Set("Content-Type", "application/x-protobuf")

	appendable := &mockAppendable{}
	handler := NewOTLPWriteHandler(nil, nil, appendable, func() config.Config {
		return config.Config{
			OTLPConfig: otlpCfg,
		}
	}, OTLPOptions{})
	recorder := httptest.NewRecorder()

Review comment (suggestion):
[Nit] The Go idiom is consistent casing of [initialisms](https://go.dev/wiki/CodeReviewComments#initialisms). It's also how we case OTLP otherwise in this file.
```suggestion
			appendable := handleOTLP(t, exportRequest, testCase.otlpCfg)
```

Code after:
				TranslationStrategy: config.NoUTF8EscapingWithSuffixes,
			},
			expectedSamples: []mockSample{
				{
					l: labels.New(labels.Label{Name: "__name__", Value: "test.counter_total"},
						labels.Label{Name: "foo.bar", Value: "baz"},
						labels.Label{Name: "instance", Value: "test-instance"},
						labels.Label{Name: "job", Value: "test-service"}),
					t: timestamp.UnixMilli(),
					v: 10.0,
				},
				{
					l: labels.New(
						labels.Label{Name: "__name__", Value: "target_info"},
						labels.Label{Name: "host.name", Value: "test-host"},
						labels.Label{Name: "instance", Value: "test-instance"},
						labels.Label{Name: "job", Value: "test-service"},
					),
					t: timestamp.UnixMilli(),
					v: 1,
				},
			},
		},
	} {
		t.Run(testCase.name, func(t *testing.T) {
			appendable := handleOTLP(t, exportRequest, testCase.otlpCfg)
			for _, sample := range testCase.expectedSamples {
				requireContainsSample(t, appendable.samples, sample)
			}
			require.Len(t, appendable.samples, 12)   // 1 (counter) + 1 (gauge) + 1 (target_info) + 7 (hist_bucket) + 2 (hist_sum, hist_count)
			require.Len(t, appendable.histograms, 1) // 1 (exponential histogram)
			require.Len(t, appendable.exemplars, 1)  // 1 (exemplar)
		})
	}
}

func requireContainsSample(t *testing.T, actual []mockSample, expected mockSample) {
	t.Helper()

	for _, got := range actual {
		if labels.Equal(expected.l, got.l) && expected.t == got.t && expected.v == got.v {
			return
		}
	}
	require.Fail(t, fmt.Sprintf("Sample not found: \n"+
		"expected: %v\n"+
		"actual  : %v", expected, actual))
}

func handleOTLP(t *testing.T, exportRequest pmetricotlp.ExportRequest, otlpCfg config.OTLPConfig) *mockAppendable {
	buf, err := exportRequest.MarshalProto()