Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

otel col contrib v0.61.0 #2521

Merged
merged 6 commits into from
Sep 30, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added filter to spanmetrics processor (#6)
arun-shopify committed Sep 30, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 98b3b1eb47e5180d51aee9d0704d2997d659ec55
3 changes: 3 additions & 0 deletions processor/spanmetricsprocessor/config.go
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ package spanmetricsprocessor // import "github.com/open-telemetry/opentelemetry-
import (
"time"

"github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/processor/filterconfig"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/featuregate"
"go.opentelemetry.io/collector/pdata/pmetric"
@@ -37,6 +38,8 @@ type Dimension struct {
type Config struct {
config.ProcessorSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct

filterconfig.MatchConfig `mapstructure:",squash"`

// MetricsExporter is the name of the metrics exporter to use to ship metrics.
MetricsExporter string `mapstructure:"metrics_exporter"`

3 changes: 2 additions & 1 deletion processor/spanmetricsprocessor/go.mod
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ require (
github.com/hashicorp/golang-lru v0.5.4
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/jaegerexporter v0.61.0
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusexporter v0.61.0
github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.61.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaegerreceiver v0.61.0
github.com/stretchr/testify v1.8.0
go.opentelemetry.io/collector v0.61.0
@@ -31,6 +32,7 @@ require (
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/gorilla/handlers v1.5.1 // indirect
@@ -50,7 +52,6 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mostynb/go-grpc-compression v1.1.17 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.61.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourcetotelemetry v0.61.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/jaeger v0.61.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus v0.61.0 // indirect
1 change: 1 addition & 0 deletions processor/spanmetricsprocessor/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions processor/spanmetricsprocessor/processor.go
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ import (
"go.uber.org/multierr"
"go.uber.org/zap"

"github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/processor/filterspan"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/spanmetricsprocessor/internal/cache"
)

@@ -87,12 +88,24 @@ type processorImp struct {
// An LRU cache of dimension key-value maps keyed by a unique identifier formed by a concatenation of its values:
// e.g. { "foo/barOK": { "serviceName": "foo", "operation": "/bar", "status_code": "OK" }}
metricKeyToDimensions *cache.Cache

include filterspan.Matcher
exclude filterspan.Matcher
}

func newProcessor(logger *zap.Logger, config config.Processor, nextConsumer consumer.Traces) (*processorImp, error) {
logger.Info("Building spanmetricsprocessor")
pConfig := config.(*Config)

include, err := filterspan.NewMatcher(pConfig.Include)
if err != nil {
return nil, err
}
exclude, err := filterspan.NewMatcher(pConfig.Exclude)
if err != nil {
return nil, err
}

bounds := defaultLatencyHistogramBucketsMs
if pConfig.LatencyHistogramBuckets != nil {
bounds = mapDurationsToMillis(pConfig.LatencyHistogramBuckets)
@@ -126,6 +139,8 @@ func newProcessor(logger *zap.Logger, config config.Processor, nextConsumer cons
nextConsumer: nextConsumer,
dimensions: pConfig.Dimensions,
metricKeyToDimensions: metricKeyToDimensionsCache,
include: include,
exclude: exclude,
}, nil
}

@@ -368,6 +383,9 @@ func (p *processorImp) aggregateMetricsForServiceSpans(rspans ptrace.ResourceSpa
spans := ils.Spans()
for k := 0; k < spans.Len(); k++ {
span := spans.At(k)
if filterspan.SkipSpan(p.include, p.exclude, span, rspans.Resource(), ils.InstrumentationLibrary()) {
continue
}
p.aggregateMetricsForSpan(serviceName, span, rspans.Resource().Attributes())
}
}