prometheus exporter convert instrumentation scope to otel_scope_info metric#3357
Conversation
4ae23e1 to
6310a13
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3357 +/- ##
=====================================
Coverage 77.7% 77.8%
=====================================
Files 164 164
Lines 11457 11488 +31
=====================================
+ Hits 8913 8942 +29
- Misses 2342 2343 +1
- Partials 202 203 +1
🚀 New features to boost your workflow:
|
6310a13 to
653b28b
Compare
e856489 to
1de3ce2
Compare
dashpole
left a comment
There was a problem hiding this comment.
Note that this does not fully fix #3161. I believe you also need to implement open-telemetry/opentelemetry-specification#2890
768cdae to
2abb67e
Compare
You are right, I mock a test as following. If use two different meter to create two metric with same name and enable scope info, no errors happen func TestMetricWithSameName(t *testing.T) {
exporter, err := New()
assert.NoError(t, err)
provider := metric.NewMeterProvider(
metric.WithReader(exporter),
)
httpCounter, err := provider.Meter("http").SyncInt64().Counter("error_count", instrument.WithUnit(unit.Dimensionless))
assert.NoError(t, err)
httpCounter.Add(context.TODO(), 1)
sqlCounter, err := provider.Meter("sql").SyncInt64().Counter("error_count", instrument.WithUnit(unit.Dimensionless))
assert.NoError(t, err)
sqlCounter.Add(context.TODO(), 1)
t.Logf("serving metrics at localhost:2223/metrics")
http.Handle("/metrics", promhttp.Handler())
err = http.ListenAndServe(":2223", nil)
if err != nil {
t.Fatalf("error serving http: %v", err)
return
}
}curl metric port will produce following metric But if I disable scope info like this func TestMetricWithSameName(t *testing.T) {
exporter, err := New(WithoutScopeInfo())
... // following codes keep unchanged
}the error happned I think I can solve this problem in another pr? Is that ok ? @dashpole @MrAlias |
Can you try with a different description on each? I think that is why you aren't reproducing the issue. Can you also try with different Counter vs UpDownCounter? |
For two code ...
httpCounter, err := provider.Meter("http").
SyncInt64().Counter(
"error_count",
instrument.WithUnit(unit.Dimensionless),
instrument.WithDescription("http error count"))
httpCounter.Add(context.TODO(), 1)
sqlCounter, err := provider.Meter("sql").
SyncInt64().Counter(
"error_count",
instrument.WithUnit(unit.Dimensionless),
instrument.WithDescription("sql error count"))
sqlCounter.Add(context.TODO(), 1)
...error |
For one code httpCounter, err := provider.Meter("http").
SyncInt64().Counter(
"error_count",
instrument.WithUnit(unit.Dimensionless))
httpCounter.Add(context.TODO(), 1)
sqlCounter, err := provider.Meter("sql").
SyncInt64().UpDownCounter(
"error_count",
instrument.WithUnit(unit.Dimensionless))
sqlCounter.Add(context.TODO(), 1)result |
@dashpole what's the expected behavior here? Just drop the second attempt to collect the second instrument and log an error? |
c5e22cf to
c698aaf
Compare
…metric Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>
Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>
f20f64e to
dbeea34
Compare
Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>
From open-telemetry/opentelemetry-specification#2890
Basically, we need the description of all metrics with the same name to match. |
👍 @dashpole are you good with merging this and then adding that tracking in another PR? That seems to make sense to me. |
Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>
Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>
Yes. |
fix #3273
related to #3161
Since #3285 already made an implementation for add target_info metric to prometheus exporter. I think I can wait for this pr merged and add otel_scope_info metric on the basic of his work.