|
3 | 3 |
|
4 | 4 | package pprofiletest // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest/pprofiletest"
|
5 | 5 | import (
|
| 6 | + "fmt" |
| 7 | + |
6 | 8 | "go.opentelemetry.io/collector/pdata/pcommon"
|
7 | 9 | "go.opentelemetry.io/collector/pdata/pprofile"
|
8 | 10 | )
|
@@ -30,7 +32,10 @@ func (rp ResourceProfile) Transform(pp pprofile.Profiles) pprofile.ResourceProfi
|
30 | 32 | sp.Transform(prp)
|
31 | 33 | }
|
32 | 34 | for _, a := range rp.Resource.Attributes {
|
33 |
| - prp.Resource().Attributes().PutStr(a.Key, a.Value) |
| 35 | + if prp.Resource().Attributes().PutEmpty(a.Key).FromRaw(a.Value) != nil { |
| 36 | + panic(fmt.Sprintf("unsupported resource attribute value: {%s: %v (type %T)}", |
| 37 | + a.Key, a.Value, a.Value)) |
| 38 | + } |
34 | 39 | }
|
35 | 40 | return prp
|
36 | 41 | }
|
@@ -66,7 +71,10 @@ type Scope struct {
|
66 | 71 | func (sc Scope) Transform(psp pprofile.ScopeProfiles) pcommon.InstrumentationScope {
|
67 | 72 | psc := psp.Scope()
|
68 | 73 | for _, a := range sc.Attributes {
|
69 |
| - psc.Attributes().PutStr(a.Key, a.Value) |
| 74 | + if psc.Attributes().PutEmpty(a.Key).FromRaw(a.Value) != nil { |
| 75 | + panic(fmt.Sprintf("unsupported scope attribute value: {%s: %v (type %T)}", |
| 76 | + a.Key, a.Value, a.Value)) |
| 77 | + } |
70 | 78 | }
|
71 | 79 | psc.SetName(sc.Name)
|
72 | 80 | psc.SetVersion(sc.Version)
|
@@ -274,13 +282,16 @@ func (m *Mapping) Transform(pp pprofile.Profile) {
|
274 | 282 |
|
275 | 283 | type Attribute struct {
|
276 | 284 | Key string
|
277 |
| - Value string |
| 285 | + Value any |
278 | 286 | }
|
279 | 287 |
|
280 | 288 | func (a *Attribute) Transform(pp pprofile.Profile) int32 {
|
281 | 289 | pa := pp.AttributeTable().AppendEmpty()
|
282 | 290 | pa.SetKey(a.Key)
|
283 |
| - pa.Value().SetStr(a.Value) |
| 291 | + if pa.Value().FromRaw(a.Value) != nil { |
| 292 | + panic(fmt.Sprintf("unsupported attribute value: {%s: %v (type %T)}", |
| 293 | + a.Key, a.Value, a.Value)) |
| 294 | + } |
284 | 295 | return int32(pp.AttributeTable().Len() - 1)
|
285 | 296 | }
|
286 | 297 |
|
|
0 commit comments