Repository: prometheus/prometheus (language: go)

Issue:
exemplar storage doesn't work for v2.40.0-rc.0
### What did you do?

I test native histograms with [v2.40.0-rc.0](https://hub.docker.com/layers/prom/prometheus/v2.40.0-rc.0/images/sha256-3fe0d56a6707a36b44a2558c7ec59c36e0ac66fb49a33a65ae777a2b3df6c769?context=explore)  docker image,  scrape [client_golang random app](https://github.com/prometheus/client_golang/blob/main/examples/random/main.go) with `main` branch and `5f202eefdb5dcb9b5b26d4d7c3351d1e5a0d9bc7 `  hash.

I run two Prometheus instances, one start with native histograms enabled, another disabled. all of them scrape the random app's metrics.

The docker compose yaml like:

```
 prometheus:
    image: prom/prometheus:v2.40.0-rc.0
    command:
      - --config.file=/etc/prometheus/prometheus.yml
      - --log.level=error
      - --storage.tsdb.path=/prometheus
      - --web.console.libraries=/usr/share/prometheus/console_libraries
      - --web.console.templates=/usr/share/prometheus/consoles
      - --enable-feature=native-histograms
      - --enable-feature=exemplar-storage
    volumes:
      - ./config/prometheus.yml:/etc/prometheus/prometheus.yml
      - prometheus-1-data:/prometheus
    ports:
      - 9090:9090
  prometheus2:
    image: prom/prometheus:v2.40.0-rc.0
    command:
      - --config.file=/etc/prometheus/prometheus.yml
      - --log.level=error
      - --storage.tsdb.path=/prometheus
      - --web.console.libraries=/usr/share/prometheus/console_libraries
      - --web.console.templates=/usr/share/prometheus/consoles
      - --enable-feature=exemplar-storage
    volumes:
      - ./config/prometheus.yml:/etc/prometheus/prometheus.yml
      - prometheus-2-data:/prometheus
    ports:
      - 9091:9090
  native-demo:
    image: client_golang:v0.1
    ports:
      - 8080:8080
``` 

When run some times, check the two Prometheus's histograms  and exemplar data, I find only the native histograms enabled instance works well with exemplar.


### What did you expect to see?

Exemplar storage works well with prometheus:v2.40.0-rc.0 even if disabled native histograms, the Graph dashbord will show exempalr data when click `Show Exemplars` button.

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

The Graph dashbord doesn't show  any exempalr data when click `Show Exemplars` button.

### System information

docker image prometheus:v2.40.0-rc.0 

### Prometheus version

_No response_

### Prometheus configuration file

_No response_

### Alertmanager version

_No response_

### Alertmanager configuration file

_No response_

### Logs

_No response_


Discussion / hints:

Fix patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index f635db74697..c49b0c6014d 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -16,6 +16,7 @@ jobs:
       - uses: ./.github/actions/setup_environment
       - run: make GO_ONLY=1 SKIP_GOLANGCI_LINT=1
       - run: go test ./tsdb/ -test.tsdb-isolation=false
+      - run: GOARCH=386 go test ./cmd/prometheus
       - run: make -C documentation/examples/remote_storage
       - run: make -C documentation/examples
       - uses: ./.github/actions/check_proto
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bb99ef410ee..0ecbc91e36e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,27 @@
 # Changelog
 
+## 2.40.1 / 2022-11-09
+
+* [BUGFIX] TSDB: Fix alignment for atomic int64 for 32 bit architecture. #11547
+* [BUGFIX] Scrape: Fix accept headers. #11552
+
+## 2.40.0 / 2022-11-08
+
+This release introduces an experimental, native way of representing and storing histograms.
+
+It can be enabled in Prometheus via `--enable-feature=native-histograms` to accept native histograms.
+Enabling native histograms will also switch the preferred exposition format to protobuf.
+
+To instrument your application with native histograms, use the `main` branch of `client_golang` (this will change for the final release when v1.14.0 of client_golang will be out), and set the `NativeHistogramBucketFactor` in your `HistogramOpts` (`1.1` is a good starting point).
+Your existing histograms won't switch to native histograms until `NativeHistogramBucketFactor` is set.
+
+* [FEATURE] Add **experimental** support for native histograms. Enable with the flag `--enable-feature=native-histograms`. #11447
+* [FEATURE] SD: Add service discovery for OVHcloud. #10802
+* [ENHANCEMENT] Kubernetes SD: Use protobuf encoding. #11353
+* [ENHANCEMENT] TSDB: Use golang.org/x/exp/slices for improved sorting speed. #11054 #11318 #11380
+* [ENHANCEMENT] Consul SD: Add enterprise admin partitions. Adds `__meta_consul_partition` label. Adds `partition` config in `consul_sd_config`. #11482
+* [BUGFIX] API: Fix API error codes for `/api/v1/labels` and `/api/v1/series`. #11356 
+
 ## 2.39.1 / 2022-10-07
 
 * [BUGFIX] Rules: Fix notifier relabel changing the labels on active alerts. #11427
diff --git a/VERSION b/VERSION
index ec128225527..0e1a032a492 100644
--- a/VERSION
+++ b/VERSION
@@ -1,1 +1,1 @@
-2.39.1
+2.40.1
diff --git a/scrape/scrape.go b/scrape/scrape.go
index 8a664bf7347..04375ab564b 100644
--- a/scrape/scrape.go
+++ b/scrape/scrape.go
@@ -773,8 +773,8 @@ type targetScraper struct {
 var errBodySizeLimit = errors.New("body size limit exceeded")
 
 const (
-	scrapeAcceptHeader             = `encoding=delimited,application/openmetrics-text;version=1.0.0;q=0.75,text/plain;version=0.0.4;q=0.5,*/*;q=0.1`
-	scrapeAcceptHeaderWithProtobuf = `application/vnd.google.protobuf; proto=io.prometheus.client.MetricFamily; encoding=delimited,application/openmetrics-text;version=1.0.0;q=0.75,text/plain;version=0.0.4;q=0.5,*/*;q=0.1`
+	scrapeAcceptHeader             = `application/openmetrics-text;version=1.0.0,application/openmetrics-text;version=0.0.1;q=0.75,text/plain;version=0.0.4;q=0.5,*/*;q=0.1`
+	scrapeAcceptHeaderWithProtobuf = `application/vnd.google.protobuf;proto=io.prometheus.client.MetricFamily;encoding=delimited,application/openmetrics-text;version=1.0.0;q=0.8,application/openmetrics-text;version=0.0.1;q=0.75,text/plain;version=0.0.4;q=0.5,*/*;q=0.1`
 )
 
 var UserAgent = fmt.Sprintf("Prometheus/%s", version.Version)
diff --git a/tsdb/head.go b/tsdb/head.go
index 85baad680d5..be4b3b6a95f 100644
--- a/tsdb/head.go
+++ b/tsdb/head.go
@@ -132,6 +132,9 @@ type HeadOptions struct {
 	// https://pkg.go.dev/sync/atomic#pkg-note-BUG
 	MaxExemplars atomic.Int64
 
+	OutOfOrderTimeWindow atomic.Int64
+	OutOfOrderCapMax     atomic.Int64
+
 	// EnableNativeHistograms enables the ingestion of native histograms.
 	EnableNativeHistograms atomic.Bool
 
@@ -141,8 +144,6 @@ type HeadOptions struct {
 	ChunkPool            chunkenc.Pool
 	ChunkWriteBufferSize int
 	ChunkWriteQueueSize  int
-	OutOfOrderTimeWindow atomic.Int64
-	OutOfOrderCapMax     atomic.Int64
 
 	// StripeSize sets the number of entries in the hash map, it must be a power of 2.
 	// A larger StripeSize will allocate more memory up-front, but will increase performance when handling a large number of series.
diff --git a/web/ui/module/codemirror-promql/package.json b/web/ui/module/codemirror-promql/package.json
index 544a10698b5..558471b5ebe 100644
--- a/web/ui/module/codemirror-promql/package.json
+++ b/web/ui/module/codemirror-promql/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@prometheus-io/codemirror-promql",
-  "version": "0.39.1",
+  "version": "0.40.1",
   "description": "a CodeMirror mode for the PromQL language",
   "types": "dist/esm/index.d.ts",
   "module": "dist/esm/index.js",
@@ -29,7 +29,7 @@
   },
   "homepage": "https://github.com/prometheus/prometheus/blob/main/web/ui/module/codemirror-promql/README.md",
   "dependencies": {
-    "@prometheus-io/lezer-promql": "^0.39.1",
+    "@prometheus-io/lezer-promql": "^0.40.1",
     "lru-cache": "^6.0.0"
   },
   "devDependencies": {
diff --git a/web/ui/module/lezer-promql/package.json b/web/ui/module/lezer-promql/package.json
index 8d0bdea453a..226999dc3b0 100644
--- a/web/ui/module/lezer-promql/package.json
+++ b/web/ui/module/lezer-promql/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@prometheus-io/lezer-promql",
-  "version": "0.39.1",
+  "version": "0.40.1",
   "description": "lezer-based PromQL grammar",
   "main": "index.cjs",
   "type": "module",
diff --git a/web/ui/package-lock.json b/web/ui/package-lock.json
index e75ca42cfa4..a7834d5f377 100644
--- a/web/ui/package-lock.json
+++ b/web/ui/package-lock.json
@@ -28,10 +28,10 @@
     },
     "module/codemirror-promql": {
       "name": "@prometheus-io/codemirror-promql",
-      "version": "0.39.1",
+      "version": "0.40.1",
       "license": "Apache-2.0",
       "dependencies": {
-        "@prometheus-io/lezer-promql": "^0.39.1",
+        "@prometheus-io/lezer-promql": "^0.40.1",
         "lru-cache": "^6.0.0"
       },
       "devDependencies": {
@@ -61,7 +61,7 @@
     },
     "module/lezer-promql": {
       "name": "@prometheus-io/lezer-promql",
-      "version": "0.39.1",
+      "version": "0.40.1",
       "license": "Apache-2.0",
       "devDependencies": {
         "@lezer/generator": "^1.1.1",
@@ -17625,7 +17625,7 @@
     },
     "react-app": {
       "name": "@prometheus-io/app",
-      "version": "0.39.1",
+      "version": "0.40.1",
       "dependencies": {
         "@codemirror/autocomplete": "^6.2.0",
         "@codemirror/commands": "^6.1.0",
@@ -17643,7 +17643,7 @@
         "@lezer/lr": "^1.2.3",
         "@nexucis/fuzzy": "^0.4.1",
         "@nexucis/kvsearch": "^0.8.1",
-        "@prometheus-io/codemirror-promql": "^0.39.1",
+        "@prometheus-io/codemirror-promql": "^0.40.1",
         "bootstrap": "^4.6.2",
         "css.escape": "^1.5.1",
         "downshift": "^6.1.11",
@@ -19883,7 +19883,7 @@
         "@lezer/lr": "^1.2.3",
         "@nexucis/fuzzy": "^0.4.1",
         "@nexucis/kvsearch": "^0.8.1",
-        "@prometheus-io/codemirror-promql": "^0.39.1",
+        "@prometheus-io/codemirror-promql": "^0.40.1",
         "@testing-library/react-hooks": "^7.0.2",
         "@types/enzyme": "^3.10.12",
         "@types/flot": "0.0.32",
@@ -19935,7 +19935,7 @@
         "@lezer/common": "^1.0.1",
         "@lezer/highlight": "^1.1.0",
         "@lezer/lr": "^1.2.3",
-        "@prometheus-io/lezer-promql": "^0.39.1",
+        "@prometheus-io/lezer-promql": "^0.40.1",
         "@types/lru-cache": "^5.1.1",
         "isomorphic-fetch": "^3.0.0",
         "lru-cache": "^6.0.0",
diff --git a/web/ui/react-app/package.json b/web/ui/react-app/package.json
index 8e7b103a08b..7358899307b 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.39.1",
+  "version": "0.40.1",
   "private": true,
   "dependencies": {
     "@codemirror/autocomplete": "^6.2.0",
@@ -19,7 +19,7 @@
     "@lezer/common": "^1.0.1",
     "@nexucis/fuzzy": "^0.4.1",
     "@nexucis/kvsearch": "^0.8.1",
-    "@prometheus-io/codemirror-promql": "^0.39.1",
+    "@prometheus-io/codemirror-promql": "^0.40.1",
     "bootstrap": "^4.6.2",
     "css.escape": "^1.5.1",
     "downshift": "^6.1.11",


Test patch: