Skip to content

Commit 0a9e178

Browse files
authored
[connector/exception] remove duplicated function. (open-telemetry#43426)
following up open-telemetry#34908 open-telemetry#34627 <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description <!-- Issue number (e.g. #1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes <!--Describe what testing was performed and which tests were added.--> #### Testing <!--Describe the documentation added.--> #### Documentation <!--Please delete paragraphs that you did not use before submitting.--> Signed-off-by: Jared Tan <[email protected]>
1 parent 054cb71 commit 0a9e178

File tree

2 files changed

+1
-27
lines changed

2 files changed

+1
-27
lines changed

connector/exceptionsconnector/connector.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,3 @@ func newDimensions(cfgDims []Dimension) []pdatautil.Dimension {
3636
}
3737
return dims
3838
}
39-
40-
// getDimensionValue gets the dimension value for the given configured dimension.
41-
// It searches through the span's attributes first, being the more specific;
42-
// falling back to searching in resource attributes if it can't be found in the span.
43-
// Finally, falls back to the configured default value if provided.
44-
//
45-
// The ok flag indicates if a dimension value was fetched in order to differentiate
46-
// an empty string value from a state where no value was found.
47-
func getDimensionValue(d pdatautil.Dimension, spanAttrs, eventAttrs, resourceAttr pcommon.Map) (v pcommon.Value, ok bool) {
48-
// The more specific span attribute should take precedence.
49-
if attr, exists := spanAttrs.Get(d.Name); exists {
50-
return attr, true
51-
}
52-
if attr, exists := eventAttrs.Get(d.Name); exists {
53-
return attr, true
54-
}
55-
// falling back to searching in resource attributes
56-
if attr, exists := resourceAttr.Get(d.Name); exists {
57-
return attr, true
58-
}
59-
// Set the default if configured, otherwise this metric will have no value set for the dimension.
60-
if d.Value != nil {
61-
return *d.Value, true
62-
}
63-
return v, ok
64-
}

connector/exceptionsconnector/connector_metrics.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ func buildKey(dest *bytes.Buffer, serviceName string, span ptrace.Span, optional
203203
concatDimensionValue(dest, traceutil.StatusCodeStr(span.Status().Code()), true)
204204

205205
for _, d := range optionalDims {
206-
if v, ok := getDimensionValue(d, span.Attributes(), eventAttrs, resourceAttrs); ok {
206+
if v, ok := pdatautil.GetDimensionValue(d, span.Attributes(), eventAttrs, resourceAttrs); ok {
207207
concatDimensionValue(dest, v.AsString(), true)
208208
}
209209
}

0 commit comments

Comments
 (0)