Skip to content

Commit ff079f9

Browse files
authored
Merge pull request #2349 from gofr-dev/fix-total-suffix-in-metrics
2 parents 0845d19 + 7c50de0 commit ff079f9

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

pkg/gofr/metrics/exporters/exporter.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package exporters
22

33
import (
4+
"github.com/prometheus/otlptranslator"
45
"go.opentelemetry.io/otel/attribute"
56
"go.opentelemetry.io/otel/exporters/prometheus"
67
"go.opentelemetry.io/otel/metric"
@@ -12,7 +13,9 @@ import (
1213
)
1314

1415
func Prometheus(appName, appVersion string) metric.Meter {
15-
exporter, err := prometheus.New(prometheus.WithoutTargetInfo())
16+
exporter, err := prometheus.New(
17+
prometheus.WithoutTargetInfo(),
18+
prometheus.WithTranslationStrategy(otlptranslator.NoTranslation))
1619
if err != nil {
1720
return nil
1821
}

pkg/gofr/metrics/register_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ func Test_NewMetricsManagerSuccess(t *testing.T) {
4040
assert.Contains(t, stringBody, `otel_scope_name="testing-app",otel_scope_schema_url="",otel_scope_version="v1.0.0"`,
4141
"TEST Failed. service name and version not coming in metrics")
4242

43-
assert.Contains(t, stringBody, `counter_test_total this is metric to test counter`,
43+
assert.Contains(t, stringBody, `counter_test this is metric to test counter`,
4444
"TEST Failed. counter-test metrics registration failed")
4545

46-
assert.Contains(t, stringBody, `counter_test_total{otel_scope_name="testing-app",otel_scope_schema_url="",otel_scope_version="v1.0.0"} 1`,
46+
assert.Contains(t, stringBody, `counter_test{otel_scope_name="testing-app",otel_scope_schema_url="",otel_scope_version="v1.0.0"} 1`,
4747
"TEST Failed. counter-test metrics registration failed")
4848

4949
assert.Contains(t, stringBody, `gauge_test this is metric to test gauge`,

0 commit comments

Comments
 (0)