Skip to content

Commit

Permalink
Fix lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
Achooo committed Apr 25, 2023
1 parent e52502f commit 063024f
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions agent/hcp/telemetry/otlp_transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func transformOTLP(rm *metricdata.ResourceMetrics) (*mpb.ResourceMetrics, error)

// scopeMetrics returns a slice of OTLP ScopeMetrics.
func scopeMetrics(scopeMetrics []metricdata.ScopeMetrics) ([]*mpb.ScopeMetrics, error) {
var merr *multierror.Error
var merr error
out := make([]*mpb.ScopeMetrics, 0, len(scopeMetrics))
for _, sm := range scopeMetrics {
ms, err := metrics(sm.Metrics)
Expand All @@ -47,7 +47,7 @@ func scopeMetrics(scopeMetrics []metricdata.ScopeMetrics) ([]*mpb.ScopeMetrics,

// metrics returns a slice of OTLP Metric generated from OTEL metrics sdk ones.
func metrics(metrics []metricdata.Metrics) ([]*mpb.Metric, error) {
var merr *multierror.Error
var merr error
out := make([]*mpb.Metric, 0, len(metrics))
for _, m := range metrics {
o, err := metricType(m)
Expand All @@ -63,11 +63,10 @@ func metrics(metrics []metricdata.Metrics) ([]*mpb.Metric, error) {
// metricType identifies the instrument type and converts it to OTLP format.
// only float64 values are accepted since the go metrics sink only receives float64 values.
func metricType(m metricdata.Metrics) (*mpb.Metric, error) {
var err error
out := &mpb.Metric{
Name: m.Name,
Description: m.Description,
Unit: string(m.Unit),
Unit: m.Unit,
}
switch a := m.Data.(type) {
case metricdata.Gauge[float64]:
Expand Down Expand Up @@ -100,7 +99,7 @@ func metricType(m metricdata.Metrics) (*mpb.Metric, error) {
default:
return out, fmt.Errorf("%s: %T", "unknown aggregation", a)
}
return out, err
return out, nil
}

// DataPoints returns a slice of OTLP NumberDataPoint generated from OTEL metrics sdk ones.
Expand Down

0 comments on commit 063024f

Please sign in to comment.