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

Ingest API to return response of POST calls #120

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

leandropadua
Copy link

@leandropadua leandropadua commented Jul 20, 2021

Return response code to the user when posting data using ingestion sdk.
Currently the response is not available to the user to make decisions based on the http response code.
For example, the current code will not raise an exception if the API_TOKEN is invalid and will give an impression that it was a successful execution.
The status code is only visible as a debug message (DEBUG: Sending to SignalFx failed (401 Unauthorized)), which is not accessible in code.

with signalfx.SignalFx(ingest_endpoint=SFX_INGESTION_ENDPOINT).ingest(SFX_API_TOKEN) as sfx:
    sfx.send_event(event_type='deployments')

With the proposed changes, this would be possible:

with signalfx.SignalFx(ingest_endpoint=SFX_INGESTION_ENDPOINT).ingest(SFX_API_TOKEN) as sfx:
    response = sfx.send_event(event_type='deployments')
    if response.ok:
        ... # deal with success
    else:
       .... # deal with failures

Return response code to the user when posting data using ingestion sdk.
Copy link

@MovieStoreGuy MovieStoreGuy left a comment

Choose a reason for hiding this comment

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

Easiest PR to approve

@jmalin-splunk
Copy link

Please note that the response code is 200 if the request is well-formed but the backend fails to ingest the data point.

See the following:

@leandropadua
Copy link
Author

Hi @jmalin-signalfx
Thanks for looking into this.

As I mentioned in the example, if the token is invalid, the library doesn't return an exception when using send_event method and it simply move on, giving an impression that it worked, but we can clearly see on the debug message that the return code was 401 Unauthorized.

Giving the response back would give some more visibility on the API returned codes, whatever that is.

We are using this library to publish custom events from our pipelines and we would like to fail the pipeline in the event of http error code, like the 401 mentioned before.

@jmalin-splunk
Copy link

Custom events are different from data points. If you're getting a 401, that needs to surface to the user. I'm in favor of returning every response code we actually get back; my comment was a note that the API might not tell you that something went wrong.

I don't know what the next step is, though. I can't approve the PR or merge it myself.

@leandropadua
Copy link
Author

related to #28

@atoulme
Copy link
Contributor

atoulme commented Nov 2, 2022

Folks, that PR sounds reasonable, but it would be good to have a test to back it up, however trivial that may be, to make sure this is working going forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants