Skip to content

Commit c26d312

Browse files
author
Arthur Silva Sens
committed
Optinally print OM created lines
Signed-off-by: Arthur Silva Sens <[email protected]>
1 parent e96fb18 commit c26d312

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

go.mod

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ require (
2222
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
2323
github.com/modern-go/reflect2 v1.0.2 // indirect
2424
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
25-
golang.org/x/net v0.17.0 // indirect
26-
golang.org/x/oauth2 v0.12.0 // indirect
27-
golang.org/x/text v0.13.0 // indirect
25+
golang.org/x/net v0.18.0 // indirect
26+
golang.org/x/oauth2 v0.14.0 // indirect
27+
golang.org/x/text v0.14.0 // indirect
2828
google.golang.org/appengine v1.6.7 // indirect
2929
gopkg.in/yaml.v2 v2.4.0 // indirect
3030
)
3131

3232
exclude github.com/prometheus/client_golang v1.12.1
33+
34+
replace github.com/prometheus/common => github.com/ArthurSens/common v0.0.0-20231212222524-bdac7de11835

go.sum

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
github.com/ArthurSens/common v0.0.0-20231212222524-bdac7de11835 h1:oFcbTONmIpHJC0hDcjzjqxJ+/jgrGeHqkj/2AWIlauo=
2+
github.com/ArthurSens/common v0.0.0-20231212222524-bdac7de11835/go.mod h1:9P9GU36VBY/+HXmQP9V0buLIxsGtTDdILukiLzH3cd0=
13
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
24
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
35
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
@@ -35,8 +37,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
3537
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
3638
github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw=
3739
github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI=
38-
github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM=
39-
github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY=
4040
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
4141
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
4242
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
@@ -46,17 +46,17 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0
4646
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
4747
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
4848
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
49-
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
50-
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
51-
golang.org/x/oauth2 v0.12.0 h1:smVPGxink+n1ZI5pkQa8y6fZT0RW0MgCO5bFpepy4B4=
52-
golang.org/x/oauth2 v0.12.0/go.mod h1:A74bZ3aGXgCY0qaIC9Ahg6Lglin4AMAco8cIv9baba4=
49+
golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg=
50+
golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ=
51+
golang.org/x/oauth2 v0.14.0 h1:P0Vrf/2538nmC0H+pEQ3MNFRRnVR7RlqyVw+bvm26z0=
52+
golang.org/x/oauth2 v0.14.0/go.mod h1:lAtNWgaWfL4cm7j2OV8TxGi9Qb7ECORx8DktCY74OwM=
5353
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
5454
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
5555
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
5656
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
5757
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
58-
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
59-
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
58+
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
59+
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
6060
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
6161
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
6262
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=

prometheus/promhttp/http.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,12 @@ func HandlerForTransactional(reg prometheus.TransactionalGatherer, opts HandlerO
180180
w = gz
181181
}
182182

183-
enc := expfmt.NewEncoder(w, contentType)
183+
var enc expfmt.Encoder
184+
if opts.EnableOpenMetricsCreatedLines {
185+
enc = expfmt.NewEncoder(w, contentType, expfmt.WithCreatedLines())
186+
} else {
187+
enc = expfmt.NewEncoder(w, contentType)
188+
}
184189

185190
// handleError handles the error according to opts.ErrorHandling
186191
// and returns true if we have to abort after the handling.
@@ -371,6 +376,8 @@ type HandlerOpts struct {
371376
// (which changes the identity of the resulting series on the Prometheus
372377
// server).
373378
EnableOpenMetrics bool
379+
// TODO: document this properly
380+
EnableOpenMetricsCreatedLines bool
374381
// ProcessStartTime allows setting process start timevalue that will be exposed
375382
// with "Process-Start-Time-Unix" response header along with the metrics
376383
// payload. This allow callers to have efficient transformations to cumulative

0 commit comments

Comments
 (0)