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

Create getAllEvents probe #6

Closed
russmiles opened this issue Apr 3, 2019 · 4 comments
Closed

Create getAllEvents probe #6

russmiles opened this issue Apr 3, 2019 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@russmiles
Copy link
Contributor

The probe's signature will likely look like:

getAllEvents: string

And simply return the full json in a string to be used to enrich an experiment's journal. This probe is unlikely to be useful to steady-state hypothesis work.

The underlying API call will implement:

> curl --request GET \
  --url '.../api/events?from=1554143400000&to=1554237055206' \
  --header 'authorization: apiToken ********' 
@russmiles russmiles added the enhancement New feature or request label Apr 3, 2019
@russmiles
Copy link
Contributor Author

The work will include updating the usage in the README, and also providing a short sample experiment with its usage incorporated in a samples directory.

@russmiles
Copy link
Contributor Author

Parameters would be a window of time (start, end) and an optional delay parameter, defaulted to 5 seconds, as Instana's model can be up to 5 seconds behind the feeds from the target system.

@russmiles
Copy link
Contributor Author

I'd like to refine this method so that it is called get_all_events_in_window as typically a window of time needs to be passed to retrieve a subset of all the events available. The signature would look like the following:

get_all_events_in_window(from, to)

I'd also like to propose that the from and to parameters could be defaulted to None, allowing for a default window of "last 5 minutes from time probe was called" to be employed.

Finally it would also be possible to support only from being specified, to defaulting to None, so that a window "from X ago to time probe was called" could be employed.

As tyo on its own doesn't seem too useful, it is suggested the above be achieved without default values and instead with function overloading?

@Lawouach
Copy link
Contributor

Lawouach commented Apr 5, 2019

Python doesn't really have the concept of overloading functions. You do use default values indeed.

You could achieve this with singledispatch but I'm afraid this will make the code harder to read in this case.

I would stick with keeping a single function with default values.

Note also, from is a keyword in Python, you won't be able to call your variable that way.

Finally, might be worth using dateparser to allow users to say "2 minutes ago" which reads more fluently.

start_dt = dateparser.parse(start, settings={'TO_TIMEZONE': 'UTC'})

start is a string such as "2 minutes ago" or "now" that is translated into a datetime instance in UTC timezone. If you need to serialize it back to an ISO string:

isostr = start_dt.isoformat()

gtfisher added a commit that referenced this issue Apr 8, 2019
Signed-off-by: Grant Tarrant-Fisher <grant@chaosiq.io>

Closes #6
gtfisher added a commit that referenced this issue Apr 8, 2019
Signed-off-by: gtfisher <grant@tarrant-fisher.co.uk>

Closes #6
gtfisher added a commit that referenced this issue Apr 12, 2019
Closes #6

Signed-off-by: gtfisher <grant@tarrant-fisher.co.uk>
gtfisher added a commit that referenced this issue Apr 15, 2019
Closes #6

Signed-off-by: gtfisher <grant@tarrant-fisher.co.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants