open-telemetry / opentelemetry-collector

OpenTelemetry Collector
https://opentelemetry.io
Apache License 2.0
4.5k stars 1.48k forks source link

exporter's Shutdown is block always ? #11243

Open XMingG99 opened 2 months ago

XMingG99 commented 2 months ago

I write an exporter , and it was work fine, but when I send signal terminal to collector, my exporter's Shutdown is not work, and noting to print in console, which just blocked.

my exporter's Shutdown func :

func (l *logsExporter) Shutdown(_ context.Context) error {
    l.logger.Info("start shutdown remote write exporter --logsExporter")
    var run int
    run = logGPool.Running()
    for run != 0 {
        run = logGPool.Running()
        l.logger.Debug("run worker size ", zap.Int("", run))
    }
    if client, ok := clientURLMap[l.config.RemoteURL]; ok {
        client.CloseIdleConnections()
    }
    l.logger.Info("remote write exporter -- logsExporter shutdown")
    return nil
}

and consol output:

2024-09-20T15:27:04.342+0800    info    otelcol@v0.108.1/collector.go:328       Received signal from OS {"signal": "terminated"}

2024-09-20T15:27:04.342+0800    info    service@v0.108.1/service.go:326 Starting shutdown...

2024-09-20T15:27:04.551+0800    info    kafkareceiver@v0.109.0/kafka_receiver.go:448    Consumer stopped        {"kind": "receiver", "name": "kafka", "data_type": "logs", "error": "context canceled"}

which just block here

Pipeline: kafkareceiver -> my exporter

bogdandrutu commented 1 month ago

Can you print your config? This to me from the logs seem to be a bug in the kafkareceiver shutdown which blocks forever