Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
VihasMakwana committed Nov 14, 2024
1 parent c06be6d commit b3aa4e8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
24 changes: 24 additions & 0 deletions .chloggen/signalfx-contract.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Use this changelog template to create an entry for release notes.

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

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Follow receiver contract based on type of error
# One or more tracking issues or pull requests related to the change
issues: [5909]

# (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:

# 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: []
6 changes: 5 additions & 1 deletion internal/coreinternal/errorutil/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ func HTTPError(w http.ResponseWriter, err error) {
if err == nil {
return
}
http.Error(w, err.Error(), GetHTTPStatusCodeFromError(err))
}

func GetHTTPStatusCodeFromError(err error) int {
// non-retryable status
status := http.StatusBadRequest
if !consumererror.IsPermanent(err) {
// retryable status
status = http.StatusServiceUnavailable
}
http.Error(w, err.Error(), status)
return status
}
3 changes: 2 additions & 1 deletion receiver/signalfxreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"go.opentelemetry.io/collector/receiver/receiverhelper"
"go.uber.org/zap"

"github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/errorutil"
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/splunk"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/signalfx"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/signalfxreceiver/internal/metadata"
Expand Down Expand Up @@ -195,7 +196,7 @@ func (r *sfxReceiver) readBody(ctx context.Context, resp http.ResponseWriter, re

func (r *sfxReceiver) writeResponse(ctx context.Context, resp http.ResponseWriter, err error) {
if err != nil {
r.failRequest(ctx, resp, http.StatusInternalServerError, errNextConsumerRespBody, err)
r.failRequest(ctx, resp, errorutil.GetHTTPStatusCodeFromError(err), errNextConsumerRespBody, err)
return
}

Expand Down

0 comments on commit b3aa4e8

Please sign in to comment.