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

Replace deprecated use of host.ReportFatalError #30693

Closed
wants to merge 2 commits into from
Closed
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
27 changes: 27 additions & 0 deletions .chloggen/fix_deprecated_reportfatalerror.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: signalfxreceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Fixed an issue in the SignalFx receiver where the context parameter was not utilized properly.
Copy link
Contributor

Choose a reason for hiding this comment

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

That's not correct, the changes to signalfxreceiver do not include changing the context parameter.

Given that this change has no impact on user or API changelog, please delete this changelog entry and instead prefix the commit message with [chore] or add the label Skip Changelog to the PR.


# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [30598]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
5 changes: 3 additions & 2 deletions receiver/awsfirehosereceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ var _ http.Handler = (*firehoseReceiver)(nil)

// Start spins up the receiver's HTTP server and makes the receiver start
// its processing.
func (fmr *firehoseReceiver) Start(_ context.Context, host component.Host) error {
func (fmr *firehoseReceiver) Start(ctx context.Context, host component.Host) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this file changed? I thought the PR was only touching signalfxreceiver.

if host == nil {
return errMissingHost
}
Expand All @@ -126,13 +126,14 @@ func (fmr *firehoseReceiver) Start(_ context.Context, host component.Host) error
defer fmr.shutdownWG.Done()

if errHTTP := fmr.server.Serve(listener); errHTTP != nil && !errors.Is(errHTTP, http.ErrServerClosed) {
host.ReportFatalError(errHTTP)
fmr.settings.TelemetrySettings.ReportStatus(component.NewFatalErrorEvent(errHTTP))
}
}()

return nil
}


Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

// Shutdown tells the receiver that should stop reception,
// giving it a chance to perform any necessary clean-up and
// shutting down its HTTP server.
Expand Down
58 changes: 29 additions & 29 deletions receiver/datadogreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,35 +47,35 @@ func newDataDogReceiver(config *Config, nextConsumer consumer.Traces, params rec
}

func (ddr *datadogReceiver) Start(_ context.Context, host component.Host) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

This file should not be part of this PR

ddmux := http.NewServeMux()
ddmux.HandleFunc("/v0.3/traces", ddr.handleTraces)
ddmux.HandleFunc("/v0.4/traces", ddr.handleTraces)
ddmux.HandleFunc("/v0.5/traces", ddr.handleTraces)
ddmux.HandleFunc("/v0.7/traces", ddr.handleTraces)
ddmux.HandleFunc("/api/v0.2/traces", ddr.handleTraces)

var err error
ddr.server, err = ddr.config.HTTPServerSettings.ToServer(
host,
ddr.params.TelemetrySettings,
ddmux,
)
if err != nil {
return fmt.Errorf("failed to create server definition: %w", err)
}
hln, err := ddr.config.HTTPServerSettings.ToListener()
if err != nil {
return fmt.Errorf("failed to create datadog listener: %w", err)
}

ddr.address = hln.Addr().String()

go func() {
if err := ddr.server.Serve(hln); err != nil && !errors.Is(err, http.ErrServerClosed) {
host.ReportFatalError(fmt.Errorf("error starting datadog receiver: %w", err))
}
}()
return nil
ddmux := http.NewServeMux()
ddmux.HandleFunc("/v0.3/traces", ddr.handleTraces)
ddmux.HandleFunc("/v0.4/traces", ddr.handleTraces)
ddmux.HandleFunc("/v0.5/traces", ddr.handleTraces)
ddmux.HandleFunc("/v0.7/traces", ddr.handleTraces)
ddmux.HandleFunc("/api/v0.2/traces", ddr.handleTraces)

var err error
ddr.server, err = ddr.config.HTTPServerSettings.ToServer(
host,
ddr.params.TelemetrySettings,
ddmux,
)
if err != nil {
return fmt.Errorf("failed to create server definition: %w", err)
}
hln, err := ddr.config.HTTPServerSettings.ToListener()
if err != nil {
return fmt.Errorf("failed to create datadog listener: %w", err)
}

ddr.address = hln.Addr().String()

go func() {
if err := ddr.server.Serve(hln); err != nil && !errors.Is(err, http.ErrServerClosed) {
ddr.params.TelemetrySettings.ReportStatus(component.NewFatalErrorEvent(err))
}
}()
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert whitespace changes

}

func (ddr *datadogReceiver) Shutdown(ctx context.Context) (err error) {
Expand Down
2 changes: 1 addition & 1 deletion receiver/signalfxreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (r *sfxReceiver) Start(_ context.Context, host component.Host) error {
go func() {
defer r.shutdownWG.Done()
if errHTTP := r.server.Serve(ln); !errors.Is(errHTTP, http.ErrServerClosed) && errHTTP != nil {
host.ReportFatalError(errHTTP)
r.settings.TelemetrySettings.ReportStatus(component.NewFatalErrorEvent(errHTTP))
}
}()
return nil
Expand Down