@@ -59,7 +59,7 @@ setup_metrics(Registry) ->
5959 {labels , [" registry" , " content_type" ]},
6060 {registry , Registry }],
6161 ScrapeEncodedSize = [{name , ? SCRAPE_ENCODED_SIZE },
62- {help , " Scrape size, encoded" },
62+ {help , " Scrape size, encoded (deprecated) " },
6363 {labels , [" registry" , " content_type" , " encoding" ]},
6464 {registry , Registry }],
6565
@@ -103,47 +103,24 @@ format_metrics(Request, Registry) ->
103103 % % Formatting registries produces large binaries. Fullsweep eagerly to
104104 % % evict the large binaries faster and make GC cheaper.
105105 process_flag (fullsweep_after , 0 ),
106- AcceptEncoding = cowboy_req :header (<<" accept-encoding" >>, Request , undefined ),
107106 ContentType = prometheus_text_format :content_type (),
108- Encoding = accept_encoding_header :negotiate (AcceptEncoding , [<<" identity" >>,
109- <<" gzip" >>]),
110- Headers = #{<<" content-type" >> => ContentType ,
111- <<" content-encoding" >> => Encoding },
112- case Encoding of
113- <<" gzip" >> ->
114- Scrape = prometheus_summary :observe_duration (
115- Registry ,
116- ? SCRAPE_DURATION ,
117- [Registry , ContentType ],
118- fun () -> prometheus_text_format :format (Registry ) end ),
119- prometheus_summary :observe (Registry ,
120- ? SCRAPE_SIZE ,
121- [Registry , ContentType ],
122- iolist_size (Scrape )),
123- Encoded = zlib :gzip (Scrape ),
124- prometheus_summary :observe (telemetry_registry (),
125- ? SCRAPE_ENCODED_SIZE ,
126- [Registry , ContentType , Encoding ],
127- iolist_size (Encoded )),
128- cowboy_req :reply (200 , Headers , Encoded , Request );
129- <<" identity" >> ->
130- Req = cowboy_req :stream_reply (200 , Headers , Request ),
131- Fmt = fun (Data , Size ) ->
132- cowboy_req :stream_body (Data , nofin , Req ),
133- Size + iolist_size (Data )
134- end ,
135- Size = prometheus_summary :observe_duration (
136- Registry ,
137- ? SCRAPE_DURATION ,
138- [Registry , ContentType ],
139- fun () -> prometheus_text_format :format_into (Registry , 0 , Fmt ) end ),
140- cowboy_req :stream_body (<<>>, fin , Req ),
141- prometheus_summary :observe (Registry ,
142- ? SCRAPE_SIZE ,
143- [Registry , ContentType ],
144- Size ),
145- Req
146- end .
107+ Headers = #{<<" content-type" >> => ContentType },
108+ Req = cowboy_req :stream_reply (200 , Headers , Request ),
109+ Fmt = fun (Data , Size ) ->
110+ cowboy_req :stream_body (Data , nofin , Req ),
111+ Size + iolist_size (Data )
112+ end ,
113+ Size = prometheus_summary :observe_duration (
114+ Registry ,
115+ ? SCRAPE_DURATION ,
116+ [Registry , ContentType ],
117+ fun () -> prometheus_text_format :format_into (Registry , 0 , Fmt ) end ),
118+ cowboy_req :stream_body (<<>>, fin , Req ),
119+ prometheus_summary :observe (Registry ,
120+ ? SCRAPE_SIZE ,
121+ [Registry , ContentType ],
122+ Size ),
123+ Req .
147124
148125validate_registry (undefined , auto ) ->
149126 {true , default };
0 commit comments