-
Notifications
You must be signed in to change notification settings - Fork 487
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
otelcolconvert: support converting servicegraph connector (#6681)
* otelcolconvert: support converting servicegraph connector Signed-off-by: Paschalis Tsilias <[email protected]> * fix for otel convert connectors Signed-off-by: erikbaranowski <[email protected]> --------- Signed-off-by: Paschalis Tsilias <[email protected]> Signed-off-by: erikbaranowski <[email protected]> Co-authored-by: Erik Baranowski <[email protected]>
- Loading branch information
1 parent
e908a2f
commit ef2f5f3
Showing
7 changed files
with
162 additions
and
4 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
internal/converter/internal/otelcolconvert/converter_servicegraphconnector.go
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,67 @@ | ||
package otelcolconvert | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/grafana/agent/internal/component/otelcol" | ||
"github.com/grafana/agent/internal/component/otelcol/connector/servicegraph" | ||
"github.com/grafana/agent/internal/converter/diag" | ||
"github.com/grafana/agent/internal/converter/internal/common" | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/connector/servicegraphconnector" | ||
"go.opentelemetry.io/collector/component" | ||
) | ||
|
||
func init() { | ||
converters = append(converters, servicegraphConnectorConverter{}) | ||
} | ||
|
||
type servicegraphConnectorConverter struct{} | ||
|
||
func (servicegraphConnectorConverter) Factory() component.Factory { | ||
return servicegraphconnector.NewFactory() | ||
} | ||
|
||
func (servicegraphConnectorConverter) InputComponentName() string { | ||
return "otelcol.connector.servicegraph" | ||
} | ||
|
||
func (servicegraphConnectorConverter) ConvertAndAppend(state *State, id component.InstanceID, cfg component.Config) diag.Diagnostics { | ||
var diags diag.Diagnostics | ||
|
||
label := state.FlowComponentLabel() | ||
|
||
args := toServicegraphConnector(state, id, cfg.(*servicegraphconnector.Config)) | ||
block := common.NewBlockWithOverride([]string{"otelcol", "connector", "servicegraph"}, label, args) | ||
|
||
diags.Add( | ||
diag.SeverityLevelInfo, | ||
fmt.Sprintf("Converted %s into %s", StringifyInstanceID(id), StringifyBlock(block)), | ||
) | ||
|
||
state.Body().AppendBlock(block) | ||
return diags | ||
} | ||
|
||
func toServicegraphConnector(state *State, id component.InstanceID, cfg *servicegraphconnector.Config) *servicegraph.Arguments { | ||
if cfg == nil { | ||
return nil | ||
} | ||
var ( | ||
nextMetrics = state.Next(id, component.DataTypeMetrics) | ||
) | ||
|
||
return &servicegraph.Arguments{ | ||
LatencyHistogramBuckets: cfg.LatencyHistogramBuckets, | ||
Dimensions: cfg.Dimensions, | ||
Store: servicegraph.StoreConfig{ | ||
MaxItems: cfg.Store.MaxItems, | ||
TTL: cfg.Store.TTL, | ||
}, | ||
CacheLoop: cfg.CacheLoop, | ||
StoreExpirationLoop: cfg.StoreExpirationLoop, | ||
MetricsFlushInterval: cfg.MetricsFlushInterval, | ||
Output: &otelcol.ConsumerArguments{ | ||
Metrics: ToTokenizedConsumers(nextMetrics), | ||
}, | ||
} | ||
} |
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
37 changes: 37 additions & 0 deletions
37
internal/converter/internal/otelcolconvert/testdata/servicegraph.river
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,37 @@ | ||
otelcol.receiver.otlp "default" { | ||
grpc { } | ||
|
||
http { } | ||
|
||
output { | ||
metrics = [] | ||
logs = [] | ||
traces = [otelcol.connector.servicegraph.default.input] | ||
} | ||
} | ||
|
||
otelcol.exporter.otlp "default" { | ||
sending_queue { | ||
queue_size = 5000 | ||
} | ||
|
||
client { | ||
endpoint = "database:4317" | ||
} | ||
} | ||
|
||
otelcol.connector.servicegraph "default" { | ||
latency_histogram_buckets = ["100ms", "250ms", "1s", "5s", "10s"] | ||
dimensions = ["dimension-1", "dimension-2"] | ||
|
||
store { | ||
max_items = 10 | ||
ttl = "1s" | ||
} | ||
cache_loop = "2m0s" | ||
store_expiration_loop = "5s" | ||
|
||
output { | ||
metrics = [otelcol.exporter.otlp.default.input] | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
internal/converter/internal/otelcolconvert/testdata/servicegraph.yaml
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,35 @@ | ||
receivers: | ||
otlp: | ||
protocols: | ||
grpc: | ||
http: | ||
|
||
connectors: | ||
servicegraph: | ||
latency_histogram_buckets: [100ms, 250ms, 1s, 5s, 10s] | ||
dimensions: | ||
- dimension-1 | ||
- dimension-2 | ||
store: | ||
ttl: 1s | ||
max_items: 10 | ||
cache_loop: 2m | ||
store_expiration_loop: 5s | ||
|
||
exporters: | ||
otlp: | ||
# Our defaults have drifted from upstream, so we explicitly set our | ||
# defaults below (balancer_name and queue_size). | ||
endpoint: database:4317 | ||
balancer_name: pick_first | ||
sending_queue: | ||
queue_size: 5000 | ||
|
||
service: | ||
pipelines: | ||
traces: | ||
receivers: [otlp] | ||
exporters: [servicegraph] | ||
metrics: | ||
receivers: [servicegraph] | ||
exporters: [otlp] |
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