Skip to content

Conversation

@rakshith91
Copy link
Contributor

@rakshith91 rakshith91 commented Jun 24, 2021

Fixes #19250

@rakshith91
Copy link
Contributor Author

/azp run python - monitor - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@rakshith91 rakshith91 changed the title Duration must be a datetime instead of string Duration must be a timedelta instead of string Jun 24, 2021
@rakshith91
Copy link
Contributor Author

/azp run python - monitor - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@rakshith91
Copy link
Contributor Author

/azp run python - monitor - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).


def construct_iso8601(start=None, end=None, duration=None):
try:
duration = 'PT{}S'.format(duration.total_seconds())
Copy link
Member

Choose a reason for hiding this comment

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

Should we use isinstance?

If user uses a class that has total_seconds property, is it valid?

Copy link
Member

@xiangyan99 xiangyan99 Jun 24, 2021

Choose a reason for hiding this comment

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

What if duration is None in line 69 & 71?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to if duration is not None

  • for the second question - it's okay to be None

Copy link
Member

Choose a reason for hiding this comment

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

Just to confirm, you mean

end = Serializer.serialize_iso(end)
iso_str = None + '/' + end

is valid?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops - line 69-71 got changed when i made the changes :)
nope = iso_str = None + '/' + end is not a valid format - although end must be provided with a duration

  • it's worth improving the message :)


def query(self, workspace_id, query, duration=None, **kwargs):
# type: (str, str, str, Any) -> LogsQueryResults
# type: (str, str, timedelta, Any) -> LogsQueryResults
Copy link
Member

@xiangyan99 xiangyan99 Jun 24, 2021

Choose a reason for hiding this comment

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

Suggested change
# type: (str, str, timedelta, Any) -> LogsQueryResults
# type: (str, str, Optional[timedelta], Any) -> LogsQueryResults

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i'll update all these :)

@rakshith91
Copy link
Contributor Author

/azp run python - monitor - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@rakshith91
Copy link
Contributor Author

/azp run python - monitor - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@rakshith91
Copy link
Contributor Author

/azp run python - monitor - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

metric_names=["PublishSuccessCount"],
start_time=datetime(2021, 5, 25),
duration='P1D'
duration=timedelta(days=1),
Copy link
Member

Choose a reason for hiding this comment

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

indent?

if end is not None:
end = Serializer.serialize_iso(end)
iso_str = start + '/' + end
elif duration is not None:
Copy link
Member

Choose a reason for hiding this comment

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

What's the behavior if user provides start, end and duration?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we would take the start and end time - we have documented that all three should not be provided - on retrospect, let me warn here too

Copy link
Member

Choose a reason for hiding this comment

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

In fact my question is if three are provided, we would silently ignore duration (current behavior) or give error? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we now give error :)

@rakshith91
Copy link
Contributor Author

/azp run python - monitor - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@rakshith91 rakshith91 enabled auto-merge (squash) June 28, 2021 16:54
@rakshith91 rakshith91 merged commit 2df4324 into Azure:main Jun 28, 2021
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.

duration should be a timedelta, not a string

2 participants