Debian Codegraph @

exporter/debugexporter/internal/normal/common.go

raw symbols SCIP
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package normal // import "go.opentelemetry.io/collector/exporter/debugexporter/internal/normal"
5
6 import (
7 "fmt"
8 "strings"
9
10 "go.opentelemetry.io/collector/pdata/pcommon"
11 )
12
13 // writeAttributes returns a slice of strings in the form "attrKey=attrValue"
14 func writeAttributes(attributes pcommon.Map) (attributeStrings []string) {
15 for k, v := range attributes.All() {
16 attribute := fmt.Sprintf("%s=%s", k, v.AsString())
17 attributeStrings = append(attributeStrings, attribute)
18 }
19 return attributeStrings
20 }
21
22 // writeAttributesString returns a string in the form " attrKey=attrValue attr2=value2"
23 func writeAttributesString(attributesMap pcommon.Map) (attributesString string) {
24 attributes := writeAttributes(attributesMap)
25 if len(attributes) > 0 {
26 attributesString = " " + strings.Join(attributes, " ")
27 }
28 return attributesString
29 }
30
31 func writeResourceDetails(schemaURL string) (resourceDetails string) {
32 if schemaURL != "" {
33 resourceDetails = " [" + schemaURL + "]"
34 }
35 return resourceDetails
36 }
37
38 func writeScopeDetails(name, version, schemaURL string) (scopeDetails string) {
39 if name != "" {
40 scopeDetails += name
41 }
42 if version != "" {
43 scopeDetails += "@" + version
44 }
45 if schemaURL != "" {
46 if scopeDetails != "" {
47 scopeDetails += " "
48 }
49 scopeDetails += "[" + schemaURL + "]"
50 }
51 if scopeDetails != "" {
52 scopeDetails = " " + scopeDetails
53 }
54 return scopeDetails
55 }