DataDog / datadog-api-client-python

Python client for the Datadog API

Home Page:https://datadoghq.dev/datadog-api-client-python/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Discrepancy/Improper Documentation Around Synthetic Tests

jacob-kinzer opened this issue · comments

Describe the bug
When using the example python code from here: https://docs.datadoghq.com/api/latest/synthetics/#create-a-browser-test There seems to be multiple issues in the current documentation that will not give you a successful example.

After some tinkering i was able to get this to work but found multiple things in the example that seemed wrong or just poorly documented.

  1. It seems like the SyntheticsAssertion class is expecting a configuration object passed in but that doesn't seem to be documented anywhere.

Creating an SyntheticsAssertion object such as
SyntheticsAssertion(operator='lessThan', type='responseTime', target=3000)

Produces an error

    SyntheticsAssertion(),
  File "/Users/u6030582/virtualenvs/python3env/lib/python3.9/site-packages/datadog_api_client/v1/model_utils.py", line 1482, in wrapped_init
    return fn(self, *args, **kwargs)
  File "/Users/u6030582/virtualenvs/python3env/lib/python3.9/site-packages/datadog_api_client/v1/model/synthetics_assertion.py", line 198, in __init__
    composed_info = validate_get_composed_info(constant_args, model_args, self)
  File "/Users/u6030582/virtualenvs/python3env/lib/python3.9/site-packages/datadog_api_client/v1/model_utils.py", line 1759, in validate_get_composed_info
    oneof_instance = get_oneof_instance(self.__class__, model_args, constant_args)
  File "/Users/u6030582/virtualenvs/python3env/lib/python3.9/site-packages/datadog_api_client/v1/model_utils.py", line 1559, in get_oneof_instance
    discard_configuration.discard_unknown_keys = False
AttributeError: 'NoneType' object has no attribute 'discard_unknown_keys'

Passing in the API Configuration as the _configuration value fixes this.
SyntheticsAssertion(operator='lessThan', type='responseTime', target=3000, _configuration=configuration),

I am not sure if this is a bug or just not documented correctly.

  1. Smaller issues that are I'm assuming incorrect documentation:
    SyntheticsTestRequest.number_of_packets and SyntheticsTestRequest.should_track_hops is listed in the example, API complains about both properties:

HTTP response body: {"errors": ["properties.config.properties.request.additionalProperties: Additional properties are not allowed (u'numberOfPackets', u'shouldTrackHops' were unexpected

SyntheticsTestRequest.timeout and SyntheticsTestOptionsRetry.interval both need to be floats

tick_every should be an SyntheticsTickInterval object

Label the issue properly.

  • Severity: Low
  • Documentation issue

To Reproduce
Steps to reproduce the behavior:

  1. Use the python example code at https://docs.datadoghq.com/api/latest/synthetics/#create-a-browser-test
  2. Running the code without any changes will produce the discard_unknown_keys error
  3. After passing in the configuration you can see the other errors as the API rejects your request.

Expected behavior
I would expect the documentation examples to work out of the box with minor-ish changes.

Environment and Versions (please complete the following information):
A clear and precise description of your setup:

  • Latest datadog-api-client version Name: datadog-api-client Version: 1.1.0 Summary: Collection of all Datadog Public endpoints Home-page: https://github.com/DataDog/datadog-api-client-python Author: Datadog, Inc. Author-email: packages@datadoghq.com License: BSD Location: /Users/u6030582/virtualenvs/python3env/lib/python3.9/site-packages Requires: python-dateutil, six, certifi, urllib3 Required-by:

Additional context
N/A

Thanks for your contribution!

This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.

If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of this project.

  2. Comment that the issue is still reproducible and include updated details requested in the issue template.

Issues with examples and the configuration errors have been fixed. Feel free to reopen if you're still seeing issues. Thanks.