Open kirill-lokhmatov opened 3 months ago
Could you provide us with actually runnable steps to reproduce? I have tried reproducing with an adaptation from the prometheus example, and I am properly getting metrics.
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package main
import (
"io"
"log"
"net/http"
"github.com/prometheus/client_golang/prometheus/promhttp"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
"go.opentelemetry.io/otel/exporters/prometheus"
"go.opentelemetry.io/otel/sdk/metric"
)
func main() {
exporter, err := prometheus.New()
if err != nil {
log.Fatal(err)
}
provider := metric.NewMeterProvider(metric.WithReader(exporter))
helloHandler := func(w http.ResponseWriter, req *http.Request) {
_, _ = io.WriteString(w, "Hello, world!\n")
}
otelHandler := otelhttp.NewHandler(
http.HandlerFunc(helloHandler),
"Hello",
otelhttp.WithMeterProvider(provider),
)
http.Handle("/metrics", promhttp.Handler())
http.Handle("/hello", otelHandler)
err = http.ListenAndServe(":7777", nil)
if err != nil {
log.Fatal(err)
}
}
Description
Environment
otelhttp
version: v0.52.0Steps To Reproduce
`
No metrics in prom (i am doing the same when working with otelsql and see the metrics)
Expected behavior
Http client metrics are exported to prometheus (like in otelsql)