mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-03-17 20:57:51 +02:00
bugfix: fix prometheus attributes other than string (#3190)
This commit is contained in:
parent
798b423dfd
commit
fae4b90d69
@ -42,6 +42,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||
- The `"go.opentelemetry.io/otel/sdk/metric".NewAccumulator` function was removed, see `NewMeterProvider`in the new metric SDK. (#3175)
|
||||
- The deprecated `"go.opentelemetry.io/otel/sdk/metric".AtomicFieldOffsets` function was removed. (#3175)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix attributes other than string in the Prometheus exporter. (#3190)
|
||||
|
||||
## [1.10.0] - 2022-09-09
|
||||
|
||||
### Added
|
||||
@ -225,7 +229,7 @@ Code instrumented with the `go.opentelemetry.io/otel/metric` will need to be mod
|
||||
- `OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT`
|
||||
- `OTEL_SPAN_LINK_COUNT_LIMIT`
|
||||
- `OTEL_LINK_ATTRIBUTE_COUNT_LIMIT`
|
||||
|
||||
|
||||
If the provided environment variables are invalid (negative), the default values would be used.
|
||||
- Rename the `gc` runtime name to `go` (#2560)
|
||||
- Add resource container ID detection. (#2418)
|
||||
|
@ -208,10 +208,10 @@ func getAttrs(attrs attribute.Set) ([]string, []string) {
|
||||
kv := itr.Attribute()
|
||||
key := strings.Map(sanitizeRune, string(kv.Key))
|
||||
if _, ok := keysMap[key]; !ok {
|
||||
keysMap[key] = []string{kv.Value.AsString()}
|
||||
keysMap[key] = []string{kv.Value.Emit()}
|
||||
} else {
|
||||
// if the sanitized key is a duplicate, append to the list of keys
|
||||
keysMap[key] = append(keysMap[key], kv.Value.AsString())
|
||||
keysMap[key] = append(keysMap[key], kv.Value.Emit())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,8 @@ func TestPrometheusExporter(t *testing.T) {
|
||||
attrs := []attribute.KeyValue{
|
||||
attribute.Key("A").String("B"),
|
||||
attribute.Key("C").String("D"),
|
||||
attribute.Key("E").Bool(true),
|
||||
attribute.Key("F").Int(42),
|
||||
}
|
||||
counter, err := meter.SyncFloat64().Counter("foo", instrument.WithDescription("a simple counter"))
|
||||
require.NoError(t, err)
|
||||
|
2
exporters/prometheus/testdata/counter.txt
vendored
2
exporters/prometheus/testdata/counter.txt
vendored
@ -1,3 +1,3 @@
|
||||
# HELP foo a simple counter
|
||||
# TYPE foo counter
|
||||
foo{A="B",C="D"} 24.3
|
||||
foo{A="B",C="D",E="true",F="42"} 24.3
|
||||
|
Loading…
x
Reference in New Issue
Block a user