datasetexporter_test.go 959 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright The OpenTelemetry Authors
  2. // SPDX-License-Identifier: Apache-2.0
  3. package datasetexporter
  4. import "go.opentelemetry.io/collector/pdata/pcommon"
  5. func fillAttributes(attr pcommon.Map, allTypes bool, valueSuffix string) {
  6. // simple types
  7. attr.PutStr("string", "string"+valueSuffix)
  8. if allTypes {
  9. attr.PutDouble("double", 2.0)
  10. attr.PutBool("bool", true)
  11. attr.PutEmpty("empty")
  12. attr.PutInt("int", 3)
  13. }
  14. // map
  15. attr.PutEmptyMap("empty_map")
  16. mVal := attr.PutEmptyMap("map")
  17. mVal.PutStr("map_string", "map_string"+valueSuffix)
  18. mVal.PutEmpty("map_empty")
  19. mVal2 := mVal.PutEmptyMap("map_map")
  20. mVal2.PutStr("map_map_string", "map_map_string"+valueSuffix)
  21. // slice
  22. attr.PutEmptySlice("empty_slice")
  23. sVal := attr.PutEmptySlice("slice")
  24. sVal.AppendEmpty()
  25. sVal.At(0).SetStr("slice_string" + valueSuffix)
  26. // colliding attributes
  27. attr.PutStr("span_id", "filled_span_id"+valueSuffix)
  28. attr.PutStr("name", "filled_name"+valueSuffix)
  29. }