Repository: prometheus/prometheus (language: go)

Issue:
Prometheus logging lots of `superfluous response.WriteHeader call from go.opentelemetry.io/contrib/instrumentation...` errors
### What did you do?

Build and run Prometheus from current `main` with any config (a completely empty file will do).

### What did you expect to see?

No errors being logged.

### What did you see instead? Under which circumstances?

The terminal is being flooded with lots of errors like:

```
ts=2024-09-07T19:25:28.219Z caller=stdlib.go:105 level=error component=web caller="http: superfluous response.WriteHeader call from go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/internal/request.(*RespWriterWrapper).writeHeader (resp_writer_wrapper.go:78" msg=)
ts=2024-09-07T19:25:28.219Z caller=stdlib.go:105 level=error component=web caller="http: superfluous response.WriteHeader call from go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/internal/request.(*RespWriterWrapper).writeHeader (resp_writer_wrapper.go:78" msg=)
ts=2024-09-07T19:25:28.219Z caller=stdlib.go:105 level=error component=web caller="http: superfluous response.WriteHeader call from go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/internal/request.(*RespWriterWrapper).writeHeader (resp_writer_wrapper.go:78" msg=)
ts=2024-09-07T19:25:28.219Z caller=stdlib.go:105 level=error component=web caller="http: superfluous response.WriteHeader call from go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/internal/request.(*RespWriterWrapper).writeHeader (resp_writer_wrapper.go:78" msg=)
ts=2024-09-07T19:25:28.219Z caller=stdlib.go:105 level=error component=web caller="http: superfluous response.WriteHeader call from go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/internal/request.(*RespWriterWrapper).writeHeader (resp_writer_wrapper.go:78" msg=)
ts=2024-09-07T19:25:28.219Z caller=stdlib.go:105 level=error component=web caller="http: superfluous response.WriteHeader call from go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/internal/request.(*RespWriterWrapper).writeHeader (resp_writer_wrapper.go:78" msg=)
ts=2024-09-07T19:25:28.219Z caller=stdlib.go:105 level=error component=web caller="http: superfluous response.WriteHeader call from go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/internal/request.(*RespWriterWrapper).writeHeader (resp_writer_wrapper.go:78" msg=)
ts=2024-09-07T19:25:28.219Z caller=stdlib.go:105 level=error component=web caller="http: superfluous response.WriteHeader call from go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/internal/request.(*RespWriterWrapper).writeHeader (resp_writer_wrapper.go:78" msg=)
ts=2024-09-07T19:25:28.219Z caller=stdlib.go:105 level=error component=web caller="http: superfluous response.WriteHeader call from go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/internal/request.(*RespWriterWrapper).writeHeader (resp_writer_wrapper.go:78" msg=)
```

From a `git bisect`, it seems like this issue was introduced in an automatic dependency upgrade in https://github.com/prometheus/prometheus/pull/14834#issuecomment-2334789149

### System information

Linux 6.10.7-arch1-1 x86_64

### Prometheus version

```text
prometheus, version 2.54.1 (branch: tarball, revision: 2.54.1)
  build user:       someone@builder
  build date:       20240827-21:37:11
  go version:       go1.23.0
  platform:         linux/amd64
  tags:             unknown
```


### Prometheus configuration file

```yaml
(doesn't matter, happens with any config, even empty ones)
```


### Alertmanager version

_No response_

### Alertmanager configuration file

_No response_

### Logs

```text
See above.
```



Discussion / hints:

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e515bd370a1..7fbdadfa627 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -21,32 +21,40 @@ As is traditional with a beta release, we do **not** recommend users install 3.0
 * [CHANGE] Agent mode has been promoted to stable. The feature flag `agent` has been removed. To run Prometheus in Agent mode, use the new `--agent` cmdline arg instead. #14747
 * [CHANGE] Remove deprecated `remote-write-receiver`,`promql-at-modifier`, and `promql-negative-offset` feature flags. #13456, #14526
 * [CHANGE] Remove deprecated `storage.tsdb.allow-overlapping-blocks`, `alertmanager.timeout`, and `storage.tsdb.retention` flags. #14640, #14643
-* [FEATURE] Promtool: Allow additional labels to be added to blocks created from openmetrics. #14402
-* [FEATURE] OTLP receiver: Add new option `otlp.promote_resource_attributes`, for any OTel resource attributes that should be promoted to metric labels. #14200
-* [FEATURE] Automatic reloading of the Prometheus configuration file at a specified interval #14769
-* [ENHANCEMENT] OTLP receiver: Warn when encountering exponential histograms with zero count and non-zero sum. #14706
+* [ENHANCEMENT] Move AM discovery page from "Monitoring status" to "Server status". #14875
+* [BUGFIX] Scrape: Do not override target parameter labels with config params. #11029
+
+## 2.55.0-rc.0 / 2024-09-20
+
+* [FEATURE] Support UTF-8 characters in label names - feature flag `utf8-names`. #14482, #14880, #14736, #14727
+* [FEATURE] Support config reload automatically - feature flag `auto-reload-config`. #14769
+* [FEATURE] Scraping: Add the ability to set custom `http_headers` in config. #14817
+* [FEATURE] Scraping: Support feature flag `created-timestamp-zero-ingestion` in OpenMetrics. #14356, #14815
+* [FEATURE] Scraping: `scrape_failure_log_file` option to log failures to a file. #14734
+* [FEATURE] OTLP receiver: Optional promotion of resource attributes to series labels. #14200
+* [FEATURE] Remote-Write: Support Google Cloud Monitoring authorization. #14346
+* [FEATURE] Promtool: `tsdb create-blocks` new option to add labels. #14403
+* [FEATURE] Promtool: `promtool test` adds `--junit` flag to format results. #14506
+* [ENHANCEMENT] OTLP receiver: Warn on exponential histograms with zero count and non-zero sum. #14706
 * [ENHANCEMENT] OTLP receiver: Interrupt translation on context cancellation/timeout. #14612
-* [ENHANCEMENT] Scrape: Only parse created timestamp if `created-timestamp-zero-ingestion` feature flag is enabled. This is as a lot of memory is used when parsing the created timestamp in the OM text format. #14815
-* [ENHANCEMENT] Scrape: Add support for logging scrape failures to a specified file. #14734
 * [ENHANCEMENT] Remote Read client: Enable streaming remote read if the server supports it. #11379
+* [ENHANCEMENT] Remote-Write: Don't reshard if we haven't successfully sent a sample since last update. #14450
 * [ENHANCEMENT] PromQL: Delay deletion of `__name__` label to the end of the query evaluation. This is **experimental** and enabled under the feature-flag `promql-delayed-name-removal`. #14477
-* [ENHANCEMENT] Move AM discovery page from "Monitoring status" to "Server status". #14875
-* [ENHANCEMENT] Tracing: Improve PromQL tracing, including showing the operation performed for aggregates, operators, and calls.#14816
-* [ENHANCEMENT] Add support for multiple listening addresses. #14665
-* [ENHANCEMENT] Add the ability to set custom HTTP headers. #14817
-* [BUGFIX] TSDB: Fix shard initialization after WAL repair. #14731
-* [BUGFIX] UTF-8: Ensure correct validation when legacy mode turned on. #14736
-* [BUGFIX] SD: Make discovery manager notify consumers of dropped targets for still defined jobs. #13147
-* [BUGFIX] SD: Prevent the new service discovery manager from storing stale targets. #13622
-* [BUGFIX] Remote Write 2.0: Ensure metadata records are sent from the WAL to remote write during WAL replay. #14766
-* [BUGFIX] Scrape: Do no override target parameter labels with config params. #11029
-* [BUGFIX] Scrape: Reset exemplar position when scraping histograms in protobuf. #14810
-* [BUGFIX] Native Histograms: Do not re-use spans between histograms. #14771
-* [BUGFIX] Scrape: Only parse created timestamp if `created-timestamp-zero-ingestion` feature flag is enabled. This is as a lot of memory is used when parsing the created timestamp in the OM text format. #14815
-* [BUGFIX] TSDB: Fix panic in query during truncation with OOO head. #14831
-* [BUGFIX] TSDB: Fix panic in chunk querier. #14874
-* [BUGFIX] promql.Engine.Close: No-op if nil. #14861
-* [BUGFIX] tsdb/wlog.Watcher.readSegmentForGC: Only count unknown record types against record_decode_failures_total metric. #14042
+* [ENHANCEMENT] PromQL: Experimental `sort_by_label` and `sort_by_label_desc` sort by all labels when label is equal. #14655
+* [ENHANCEMENT] PromQL: Clarify error message logged when Go runtime panic occurs during query evaluation. #14621
+* [ENHANCEMENT] PromQL: Use Kahan summation for better accuracy in `avg` and `avg_over_time`. #14413
+* [ENHANCEMENT] Tracing: Improve PromQL tracing, including showing the operation performed for aggregates, operators, and calls. #14816
+* [ENHANCEMENT] API: Support multiple listening addresses. #14665
+* [ENHANCEMENT] TSDB: Backward compatibility with upcoming index v3. #14934
+* [PERF] TSDB: Query in-order and out-of-order series together. #14354, #14693, #14714, #14831, #14874, #14948
+* [PERF] TSDB: Streamline reading of overlapping out-of-order head chunks. #14729
+* [BUGFIX] SD: Fix dropping targets (with feature flag `new-service-discovery-manager`). #13147
+* [BUGFIX] SD: Stop storing stale targets (with feature flag `new-service-discovery-manager`). #13622
+* [BUGFIX] Scraping: exemplars could be dropped in protobuf scraping. #14810
+* [BUGFIX] Remote-Write: fix metadata sending for experimental Remote-Write V2. #14766
+* [BUGFIX] Remote-Write: Return 4xx not 5xx when timeseries has duplicate label. #14716
+* [BUGFIX] Experimental Native Histograms: many fixes for incorrect results, panics, warnings. #14513, #14575, #14598, #14609, #14611, #14771, #14821
+* [BUGFIX] TSDB: Only count unknown record types in `record_decode_failures_total` metric. #14042
 
 ## 2.54.1 / 2024-08-27
 
diff --git a/RELEASE.md b/RELEASE.md
index 53fdc443378..8e78a6a3ec0 100644
--- a/RELEASE.md
+++ b/RELEASE.md
@@ -59,6 +59,7 @@ Release cadence of first pre-releases being cut is 6 weeks.
 | v2.52          | 2024-04-22                                 | Arthur Silva Sens (GitHub: @ArthurSens)     |
 | v2.53 LTS      | 2024-06-03                                 | George Krajcsovits (GitHub: @krajorama)     |
 | v2.54          | 2024-07-17                                 | Bryan Boreham (GitHub: @bboreham)           |
+| v2.55          | 2024-09-17                                 | Bryan Boreham (GitHub: @bboreham)           |
 
 If you are interested in volunteering please create a pull request against the [prometheus/prometheus](https://github.com/prometheus/prometheus) repository and propose yourself for the release series of your choice.
 
diff --git a/tsdb/index/index.go b/tsdb/index/index.go
index ba262182c82..3cd00729ab1 100644
--- a/tsdb/index/index.go
+++ b/tsdb/index/index.go
@@ -43,10 +43,12 @@ const (
 	// HeaderLen represents number of bytes reserved of index for header.
 	HeaderLen = 5
 
-	// FormatV1 represents 1 version of index.
+	// FormatV1 represents version 1 of index.
 	FormatV1 = 1
-	// FormatV2 represents 2 version of index.
+	// FormatV2 represents version 2 of index.
 	FormatV2 = 2
+	// FormatV3 represents version 3 of index.
+	FormatV3 = 3
 
 	indexFilename = "index"
 
@@ -1193,7 +1195,9 @@ func newReader(b ByteSlice, c io.Closer) (*Reader, error) {
 	}
 	r.version = int(r.b.Range(4, 5)[0])
 
-	if r.version != FormatV1 && r.version != FormatV2 {
+	switch r.version {
+	case FormatV1, FormatV2, FormatV3:
+	default:
 		return nil, fmt.Errorf("unknown index file version %d", r.version)
 	}
 
@@ -1351,7 +1355,9 @@ func (s Symbols) Lookup(o uint32) (string, error) {
 		B: s.bs.Range(0, s.bs.Len()),
 	}
 
-	if s.version == FormatV2 {
+	if s.version == FormatV1 {
+		d.Skip(int(o))
+	} else {
 		if int(o) >= s.seen {
 			return "", fmt.Errorf("unknown symbol offset %d", o)
 		}
@@ -1360,8 +1366,6 @@ func (s Symbols) Lookup(o uint32) (string, error) {
 		for i := o - (o / symbolFactor * symbolFactor); i > 0; i-- {
 			d.UvarintBytes()
 		}
-	} else {
-		d.Skip(int(o))
 	}
 	sym := d.UvarintStr()
 	if d.Err() != nil {
@@ -1407,10 +1411,10 @@ func (s Symbols) ReverseLookup(sym string) (uint32, error) {
 	if lastSymbol != sym {
 		return 0, fmt.Errorf("unknown symbol %q", sym)
 	}
-	if s.version == FormatV2 {
-		return uint32(res), nil
+	if s.version == FormatV1 {
+		return uint32(s.bs.Len() - lastLen), nil
 	}
-	return uint32(s.bs.Len() - lastLen), nil
+	return uint32(res), nil
 }
 
 func (s Symbols) Size() int {
@@ -1569,7 +1573,7 @@ func (r *Reader) LabelNamesFor(ctx context.Context, postings Postings) ([]string
 		offset := id
 		// In version 2 series IDs are no longer exact references but series are 16-byte padded
 		// and the ID is the multiple of 16 of the actual position.
-		if r.version == FormatV2 {
+		if r.version != FormatV1 {
 			offset = id * seriesByteAlign
 		}
 
@@ -1608,7 +1612,7 @@ func (r *Reader) LabelValueFor(ctx context.Context, id storage.SeriesRef, label
 	offset := id
 	// In version 2 series IDs are no longer exact references but series are 16-byte padded
 	// and the ID is the multiple of 16 of the actual position.
-	if r.version == FormatV2 {
+	if r.version != FormatV1 {
 		offset = id * seriesByteAlign
 	}
 	d := encoding.NewDecbufUvarintAt(r.b, int(offset), castagnoliTable)
@@ -1634,7 +1638,7 @@ func (r *Reader) Series(id storage.SeriesRef, builder *labels.ScratchBuilder, ch
 	offset := id
 	// In version 2 series IDs are no longer exact references but series are 16-byte padded
 	// and the ID is the multiple of 16 of the actual position.
-	if r.version == FormatV2 {
+	if r.version != FormatV1 {
 		offset = id * seriesByteAlign
 	}
 	d := encoding.NewDecbufUvarintAt(r.b, int(offset), castagnoliTable)
diff --git a/web/ui/react-app/package-lock.json b/web/ui/react-app/package-lock.json
index d456ca1f091..667eb0b375d 100644
--- a/web/ui/react-app/package-lock.json
+++ b/web/ui/react-app/package-lock.json
@@ -1,12 +1,12 @@
 {
   "name": "@prometheus-io/app",
-  "version": "0.54.1",
+  "version": "0.55.0-rc.0",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
     "": {
       "name": "@prometheus-io/app",
-      "version": "0.54.1",
+      "version": "0.55.0-rc.0",
       "dependencies": {
         "@codemirror/autocomplete": "^6.17.0",
         "@codemirror/commands": "^6.6.0",
@@ -24,7 +24,7 @@
         "@lezer/lr": "^1.4.2",
         "@nexucis/fuzzy": "^0.4.1",
         "@nexucis/kvsearch": "^0.8.1",
-        "@prometheus-io/codemirror-promql": "0.54.1",
+        "@prometheus-io/codemirror-promql": "0.55.0-rc.0",
         "bootstrap": "^4.6.2",
         "css.escape": "^1.5.1",
         "downshift": "^9.0.6",
@@ -4341,12 +4341,12 @@
       }
     },
     "node_modules/@prometheus-io/codemirror-promql": {
-      "version": "0.54.1",
-      "resolved": "https://registry.npmjs.org/@prometheus-io/codemirror-promql/-/codemirror-promql-0.54.1.tgz",
-      "integrity": "sha512-CkU5d+Nhbj+VjTYSlicIcFeL3KUYyEco/VHK+qM4TXgPQJxP04MCi642UVgLeuy9exThkCObj5oDJcApSNmxBw==",
+      "version": "0.55.0-rc.0",
+      "resolved": "https://registry.npmjs.org/@prometheus-io/codemirror-promql/-/codemirror-promql-0.55.0-rc.0.tgz",
+      "integrity": "sha512-BlDKH2eB8Sd9bQmQjvJvncvZ+VTtrtReSO6qWZXULyrXp+FEjONybOH3Ejq/0a2hat0GpZzcEfwKqPbdy4WdCQ==",
       "license": "Apache-2.0",
       "dependencies": {
-        "@prometheus-io/lezer-promql": "0.54.1",
+        "@prometheus-io/lezer-promql": "0.55.0-rc.0",
         "lru-cache": "^7.18.3"
       },
       "engines": {
@@ -4362,9 +4362,9 @@
       }
     },
     "node_modules/@prometheus-io/lezer-promql": {
-      "version": "0.54.1",
-      "resolved": "https://registry.npmjs.org/@prometheus-io/lezer-promql/-/lezer-promql-0.54.1.tgz",
-      "integrity": "sha512-+QdeoN/PttM1iBeRtwSQWoaDIwnIgT9oIueTbAlvL01WM2eluD8j9vNiD0oJFzbcZ5clxwhvMP54InIt3vJaMg==",
+      "version": "0.55.0-rc.0",
+      "resolved": "https://registry.npmjs.org/@prometheus-io/lezer-promql/-/lezer-promql-0.55.0-rc.0.tgz",
+      "integrity": "sha512-Ikaabw8gfu0HI2D2rKykLBWio+ytTEE03bdZDMpILYULoeGVPdKgbeGLLI9Kafyv48Qiis55o60EfDoywiRHqA==",
       "license": "Apache-2.0",
       "peerDependencies": {
         "@lezer/highlight": "^1.1.2",
diff --git a/web/ui/react-app/package.json b/web/ui/react-app/package.json
index c194e833587..c3236caa40c 100644
--- a/web/ui/react-app/package.json
+++ b/web/ui/react-app/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@prometheus-io/app",
-  "version": "0.54.1",
+  "version": "0.55.0-rc.0",
   "private": true,
   "dependencies": {
     "@codemirror/autocomplete": "^6.17.0",
@@ -19,7 +19,7 @@
     "@lezer/lr": "^1.4.2",
     "@nexucis/fuzzy": "^0.4.1",
     "@nexucis/kvsearch": "^0.8.1",
-    "@prometheus-io/codemirror-promql": "0.54.1",
+    "@prometheus-io/codemirror-promql": "0.55.0-rc.0",
     "bootstrap": "^4.6.2",
     "css.escape": "^1.5.1",
     "downshift": "^9.0.6",


Test patch: