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

Close the span writer on main #2096

Merged
merged 2 commits into from
Feb 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 0 additions & 11 deletions cmd/collector/app/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package app

import (
"context"
"io"
"net/http"
"time"

Expand Down Expand Up @@ -178,15 +177,5 @@ func (c *Collector) Close() error {
c.logger.Error("failed to close span processor.", zap.Error(err))
}

// the span processor is closed
if c.spanWriter != nil {
if closer, ok := c.spanWriter.(io.Closer); ok {
err := closer.Close() // SpanWriter
if err != nil {
c.logger.Error("failed to close span writer", zap.Error(err))
}
}
}

return nil
}
7 changes: 7 additions & 0 deletions cmd/collector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package main

import (
"fmt"
"io"
"log"
"os"

Expand Down Expand Up @@ -95,6 +96,12 @@ func main() {
c.Start(collectorOpts)

svc.RunAndThen(func() {
if closer, ok := spanWriter.(io.Closer); ok {
err := closer.Close()
if err != nil {
logger.Error("failed to close span writer", zap.Error(err))
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about all-in-one, should it have similar code?

Copy link
Contributor Author

@jpkrohling jpkrohling Feb 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does already, which is the cause for the double-close:

if closer, ok := spanWriter.(io.Closer); ok {
err := closer.Close()
if err != nil {
logger.Error("Failed to close span writer", zap.Error(err))
}
}

c.Close()
})
return nil
Expand Down