prometheus/storage/remote
Oleg Zaytsev beb7d3b80f
remote.Client: store urlString
During remote write, we call url.String() twice:
- to add the Endpoint() to the span
- to actually know where whe should send the request

This value does not change over time, and it's not really that
lightweight to calculate. I wrote this simple benchmark:

    func BenchmarkURLString(b *testing.B) {
        u, err := url.Parse("https://remote.write.com/api/v1")
        require.NoError(b, err)

        b.Run("string", func(b *testing.B) {
            count := 0
            for i := 0; i < b.N; i++ {
                count += len(u.String())
            }
        })
    }

And the results are ~200ns/op, 80B/op, 3 allocs/op.

Yes, we're going to go to the network here, which is a huge amount of
resources compared to this, but still, on agents that send 500 requests
per second, that is 1500 wasteful allocations per second.

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
2023-03-16 09:53:10 +01:00
..
chunked.go (storage): move from github.com/pkg/errors to 'errors' and 'fmt' (#10946) 2022-07-01 18:59:50 +02:00
chunked_test.go Testify: move to require (#8122) 2020-10-29 09:43:23 +00:00
client.go remote.Client: store urlString 2023-03-16 09:53:10 +01:00
client_test.go remote: Convert to RecoverableError using errors.As (#12103) 2023-03-08 13:58:09 -07:00
codec.go Mark Histogram.(Positive|Negative)Spans as non-nullable. 2023-02-03 13:49:22 +11:00
codec_test.go Mark Histogram.(Positive|Negative)Spans as non-nullable. 2023-02-03 13:49:22 +11:00
ewma.go Replace sync/atomic with uber-go/atomic (#7683) 2020-07-30 13:15:42 +05:30
intern.go Move away from testutil, refactor imports (#8087) 2020-10-22 11:00:08 +02:00
intern_test.go Testify: move to require (#8122) 2020-10-29 09:43:23 +00:00
max_timestamp.go Remote: Do not collect non-initialized timestamp metrics (#8060) 2020-10-15 23:53:59 +02:00
metadata_watcher.go (storage): move from github.com/pkg/errors to 'errors' and 'fmt' (#10946) 2022-07-01 18:59:50 +02:00
metadata_watcher_test.go (storage): move from github.com/pkg/errors to 'errors' and 'fmt' (#10946) 2022-07-01 18:59:50 +02:00
queue_manager.go remote: Improve some comments (#12102) 2023-03-09 11:05:24 +00:00
queue_manager_test.go histograms: Add remote-write support for Float Histograms (#11817) 2023-01-13 16:39:20 +05:30
read.go Update package storage/remote for new labels.Labels type 2022-12-19 15:22:09 +00:00
read_handler.go remote/read_handler: pool input to Marshal() (#11357) 2022-11-15 16:29:16 +01:00
read_handler_test.go Use errors.Is to check for a specific error 2022-12-29 23:23:07 +08:00
read_test.go Update package storage/remote tests for new labels.Labels type 2022-12-19 15:22:09 +00:00
storage.go storage/remote: in tests use labels.FromStrings 2022-09-09 13:34:49 +02:00
storage_test.go Update package storage/remote tests for new labels.Labels type 2022-12-19 15:22:09 +00:00
write.go Support FloatHistogram in TSDB (#11522) 2022-12-28 14:25:07 +05:30
write_handler.go histograms: Add remote-write support for Float Histograms (#11817) 2023-01-13 16:39:20 +05:30
write_handler_test.go Attempt to append ooo sample at the end first (#11615) 2023-01-13 19:00:50 +05:30
write_test.go Update package storage/remote tests for new labels.Labels type 2022-12-19 15:22:09 +00:00