-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[connector/servicegraph] Simplify servicegraph connector config arguments #45399
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -20,9 +20,6 @@ import ( | |
| "go.opentelemetry.io/collector/pdata/pmetric" | ||
| "go.opentelemetry.io/collector/pdata/ptrace" | ||
| "go.opentelemetry.io/collector/processor" | ||
| conventionsv125 "go.opentelemetry.io/otel/semconv/v1.25.0" | ||
| conventionsv128 "go.opentelemetry.io/otel/semconv/v1.28.0" | ||
| conventions "go.opentelemetry.io/otel/semconv/v1.38.0" | ||
| "go.uber.org/zap" | ||
|
|
||
| "github.com/open-telemetry/opentelemetry-collector-contrib/connector/servicegraphconnector/internal/metadata" | ||
|
|
@@ -41,19 +38,12 @@ const ( | |
|
|
||
| var ( | ||
| legacyDefaultLatencyHistogramBuckets = []float64{ | ||
| 2, 4, 6, 8, 10, 50, 100, 200, 400, 800, 1000, 1400, 2000, 5000, 10_000, 15_000, | ||
| 2, 4, 6, 8, 10, 50, 100, 200, 400, 800, 1000, 1400, 2000, 5000, 10000, 15000, | ||
| } | ||
|
|
||
| defaultLatencyHistogramBuckets = []float64{ | ||
| 0.002, 0.004, 0.006, 0.008, 0.01, 0.05, 0.1, 0.2, 0.4, 0.8, 1, 1.4, 2, 5, 10, 15, | ||
| } | ||
|
|
||
| defaultPeerAttributes = []string{ | ||
| string(conventions.PeerServiceKey), string(conventionsv125.DBNameKey), string(conventionsv128.DBSystemKey), | ||
| } | ||
|
|
||
| defaultDatabaseNameAttributes = []string{string(conventionsv125.DBNameKey)} | ||
|
Comment on lines
-50
to
-54
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI in factory.go this has been changed to only use semconv v1.25.0 and the keys remain the same, so this is backwards compatible. |
||
|
|
||
| defaultMetricsFlushInterval = 60 * time.Second // 1 DPM | ||
| ) | ||
|
|
||
| type metricSeries struct { | ||
|
|
@@ -96,6 +86,16 @@ type serviceGraphConnector struct { | |
| func newConnector(set component.TelemetrySettings, config component.Config, next consumer.Metrics) (*serviceGraphConnector, error) { | ||
| pConfig := config.(*Config) | ||
|
|
||
| if pConfig.MetricsFlushInterval.Nanoseconds() <= 0 { | ||
| set.Logger.Warn("MetricsFlushInterval is set to 0, metrics will be flushed on every received batch of traces") | ||
| } | ||
|
|
||
| telemetryBuilder, err := metadata.NewTelemetryBuilder(set) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| // Compute histogram bounds based on configuration | ||
| var bounds []float64 | ||
| if pConfig.ExponentialHistogramMaxSize == 0 { | ||
| bounds = defaultLatencyHistogramBuckets | ||
|
|
@@ -107,33 +107,6 @@ func newConnector(set component.TelemetrySettings, config component.Config, next | |
| } | ||
| } | ||
|
|
||
| if pConfig.CacheLoop <= 0 { | ||
| pConfig.CacheLoop = time.Minute | ||
| } | ||
|
|
||
| if pConfig.StoreExpirationLoop <= 0 { | ||
| pConfig.StoreExpirationLoop = 2 * time.Second | ||
| } | ||
|
|
||
| if pConfig.VirtualNodePeerAttributes == nil { | ||
| pConfig.VirtualNodePeerAttributes = defaultPeerAttributes | ||
| } | ||
|
|
||
| if len(pConfig.DatabaseNameAttributes) == 0 { | ||
| pConfig.DatabaseNameAttributes = defaultDatabaseNameAttributes | ||
| } | ||
|
|
||
| if pConfig.MetricsFlushInterval == nil { | ||
| pConfig.MetricsFlushInterval = &defaultMetricsFlushInterval | ||
| } else if pConfig.MetricsFlushInterval.Nanoseconds() <= 0 { | ||
| set.Logger.Warn("MetricsFlushInterval is set to 0, metrics will be flushed on every received batch of traces") | ||
| } | ||
|
|
||
| telemetryBuilder, err := metadata.NewTelemetryBuilder(set) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| return &serviceGraphConnector{ | ||
| config: pConfig, | ||
| logger: set.Logger, | ||
|
|
@@ -160,7 +133,7 @@ func newConnector(set component.TelemetrySettings, config component.Config, next | |
| func (p *serviceGraphConnector) Start(context.Context, component.Host) error { | ||
| p.store = store.NewStore(p.config.Store.TTL, p.config.Store.MaxItems, p.onComplete, p.onExpire) | ||
|
|
||
| go p.metricFlushLoop(*p.config.MetricsFlushInterval) | ||
| go p.metricFlushLoop(p.config.MetricsFlushInterval) | ||
|
|
||
| go p.cacheLoop(p.config.CacheLoop) | ||
|
|
||
|
|
@@ -221,7 +194,7 @@ func (p *serviceGraphConnector) ConsumeTraces(ctx context.Context, td ptrace.Tra | |
| } | ||
|
|
||
| // If metricsFlushInterval is not set, flush metrics immediately. | ||
| if *p.config.MetricsFlushInterval <= 0 { | ||
| if p.config.MetricsFlushInterval <= 0 { | ||
| if err := p.flushMetrics(ctx); err != nil { | ||
| // Not return error here to avoid impacting traces. | ||
| p.logger.Error("failed to flush metrics", zap.Error(err)) | ||
|
|
@@ -792,6 +765,9 @@ func durationToFloat(d time.Duration) float64 { | |
| } | ||
|
|
||
| func mapDurationsToFloat(vs []time.Duration) []float64 { | ||
| if vs == nil { | ||
| return nil | ||
| } | ||
| vsm := make([]float64, len(vs)) | ||
| for i, v := range vs { | ||
| vsm[i] = durationToFloat(v) | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not backwards compatible. Should we log a warning instead?