Skip to content

Commit ec0f6a6

Browse files
feat(component/otelcol/connector): add support for logs to metrics connectors (#4550)
Signed-off-by: Yann Soubeyrand <[email protected]>
1 parent 7c53dd1 commit ec0f6a6

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

internal/component/otelcol/connector/connector.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,26 @@ func (p *Connector) Update(args component.Arguments) error {
216216
components = append(components, tracesConnector)
217217
}
218218
}
219+
case ConnectorLogsToMetrics:
220+
if len(next.Traces) > 0 || len(next.Logs) > 0 {
221+
return errors.New("this connector can only output metrics")
222+
}
223+
224+
if len(next.Metrics) > 0 {
225+
fanout := fanoutconsumer.Metrics(next.Metrics)
226+
metricsInterceptor := interceptconsumer.Metrics(fanout,
227+
func(ctx context.Context, md pmetric.Metrics) error {
228+
livedebuggingpublisher.PublishMetricsIfActive(p.debugDataPublisher, p.opts.ID, md, otelcol.GetComponentMetadata(next.Metrics))
229+
return fanout.ConsumeMetrics(ctx, md)
230+
},
231+
)
232+
logsConnector, err = p.factory.CreateLogsToMetrics(p.ctx, settings, connectorConfig, metricsInterceptor)
233+
if err != nil && !errors.Is(err, pipeline.ErrSignalNotSupported) {
234+
return err
235+
} else if logsConnector != nil {
236+
components = append(components, logsConnector)
237+
}
238+
}
219239
default:
220240
return errors.New("unsupported connector type")
221241
}

0 commit comments

Comments
 (0)