Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolás Pazos <npazosmendez@gmail.com>
  • Loading branch information
npazosmendez committed Feb 1, 2024
1 parent fd373b7 commit f7aea22
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ var dropSanitizationGate = featuregate.GlobalRegistry().MustRegister(
//
// Exception is made for double-underscores which are allowed
func NormalizeLabel(label string) string {

// Trivial case
if len(label) == 0 {
return label
Expand Down
2 changes: 0 additions & 2 deletions storage/remote/otlptranslator/prometheus/normalize_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
// Prometheus best practices for units: https://prometheus.io/docs/practices/naming/#base-units
// OpenMetrics specification for units: https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#units-and-base-units
var unitMap = map[string]string{

// Time
"d": "days",
"h": "hours",
Expand Down Expand Up @@ -108,7 +107,6 @@ func BuildCompliantName(metric pmetric.Metric, namespace string, addMetricSuffix

// Build a normalized name for the specified metric
func normalizeName(metric pmetric.Metric, namespace string) string {

// Split metric name in "tokens" (remove all non-alphanumeric)
nameTokens := strings.FieldsFunc(
metric.Name(),
Expand Down
1 change: 0 additions & 1 deletion storage/remote/otlptranslator/prometheus/unit_to_ucum.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package prometheus // import "github.com/open-telemetry/opentelemetry-collector-
import "strings"

var wordToUCUM = map[string]string{

// Time
"days": "d",
"hours": "h",
Expand Down
9 changes: 5 additions & 4 deletions storage/remote/otlptranslator/prometheusremotewrite/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ func (a ByLabelName) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
// creates a new TimeSeries in the map if not found and returns the time series signature.
// tsMap will be unmodified if either labels or sample is nil, but can still be modified if the exemplar is nil.
func addSample(tsMap map[string]*prompb.TimeSeries, sample *prompb.Sample, labels []prompb.Label,
datatype string) string {

datatype string,
) string {
if sample == nil || labels == nil || tsMap == nil {
return ""
}
Expand Down Expand Up @@ -185,7 +185,7 @@ func createAttributes(resource pcommon.Resource, attributes pcommon.Map, externa
sort.Stable(ByLabelName(labels))

for _, label := range labels {
var finalKey = prometheustranslator.NormalizeLabel(label.Name)
finalKey := prometheustranslator.NormalizeLabel(label.Name)
if existingLabel, alreadyExists := l[finalKey]; alreadyExists {
l[finalKey] = existingLabel + ";" + label.Value
} else {
Expand Down Expand Up @@ -457,7 +457,8 @@ func maxTimestamp(a, b pcommon.Timestamp) pcommon.Timestamp {

// addSingleSummaryDataPoint converts pt to len(QuantileValues) + 2 samples.
func addSingleSummaryDataPoint(pt pmetric.SummaryDataPoint, resource pcommon.Resource, metric pmetric.Metric, settings Settings,
tsMap map[string]*prompb.TimeSeries) {
tsMap map[string]*prompb.TimeSeries,
) {
timestamp := convertTimeStamp(pt.Timestamp())
// sum and count of the summary should append suffix to baseName
baseName := prometheustranslator.BuildCompliantName(metric, settings.Namespace, settings.AddMetricSuffixes)
Expand Down
1 change: 1 addition & 0 deletions storage/remote/queue_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ func isTimeSeriesOldFilter(metrics *queueManagerMetrics, baseTime time.Time, sam
return false
}
}

func isV2TimeSeriesOldFilter(metrics *queueManagerMetrics, baseTime time.Time, sampleAgeLimit time.Duration) func(ts writev2.TimeSeries) bool {
return func(ts writev2.TimeSeries) bool {
if sampleAgeLimit == 0 {
Expand Down

0 comments on commit f7aea22

Please sign in to comment.