-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[chore] move collectdreceiver shared code to an internal package (#28856
- Loading branch information
Showing
20 changed files
with
89 additions
and
110 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include ../../Makefile.Common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/open-telemetry/opentelemetry-collector-contrib/internal/collectd | ||
|
||
go 1.20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package collectd // import "github.com/open-telemetry/opentelemetry-collector-contrib/internal/collectd" | ||
|
||
import ( | ||
"strings" | ||
) | ||
|
||
// LabelsFromName tries to pull out dimensions out of name in the format | ||
// "name[k=v,f=x]-more_name". | ||
// For the example above it would return "name-more_name" and extract dimensions | ||
// (k,v) and (f,x). | ||
// If something unexpected is encountered it returns the original metric name. | ||
// | ||
// The code tries to avoid allocation by using local slices and avoiding calls | ||
// to functions like strings.Slice. | ||
func LabelsFromName(val *string) (metricName string, labels map[string]string) { | ||
metricName = *val | ||
index := strings.Index(*val, "[") | ||
if index > -1 { | ||
left := (*val)[:index] | ||
rest := (*val)[index+1:] | ||
index = strings.Index(rest, "]") | ||
if index > -1 { | ||
working := make(map[string]string) | ||
dimensions := rest[:index] | ||
rest = rest[index+1:] | ||
cindex := strings.Index(dimensions, ",") | ||
prev := 0 | ||
for { | ||
if cindex < prev { | ||
cindex = len(dimensions) | ||
} | ||
piece := dimensions[prev:cindex] | ||
tindex := strings.Index(piece, "=") | ||
if tindex == -1 || strings.Contains(piece[tindex+1:], "=") { | ||
return | ||
} | ||
working[piece[:tindex]] = piece[tindex+1:] | ||
if cindex == len(dimensions) { | ||
break | ||
} | ||
prev = cindex + 1 | ||
cindex = strings.Index(dimensions[prev:], ",") + prev | ||
} | ||
labels = working | ||
metricName = left + rest | ||
} | ||
} | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
status: | ||
codeowners: | ||
active: [atoulme] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.