Skip to content

Conversation

@dstandish
Copy link
Contributor

@dstandish dstandish commented Oct 5, 2023

Depends on #34790

Previously, when there were no logs, we would just use [] or {} and continue to process them through functions such as "group by host" and such. But if no logs are found, it's odd to go down those paths.

One example of the confusion is the return type in es_read was list | ElasticSearchResponse. This makes it look like it would either be a list (presumably of logs?) or an ElasticSearchResponse object (presumably also containing logs?). But in reality, the only time list was returned, was when there were no logs at all! This was just to adhere to the contract that we handle "no logs" the same as "logs". (And it turns out that ElasticSearchResponse magically also behaves like at iterable which is also confusing but that's a separate issue.)

@eladkal
Copy link
Contributor

eladkal commented Oct 13, 2023

@dstandish can you please rebase?

Previously, when there were no logs, we would just use [] or {} and continue to process them through functions such as "group by host" and such.  But if no logs are found, it's odd to go down those paths.

One example of the confusion is the return type in `es_read` was `list | ElasticSearchResponse`.  This makes it look like it would either be a list (presumably of logs?) or an ElasticSearchResponse object (presumably also containing logs?).  But in reality, the only time list was returned, was when there _were no logs at all!_  This was just to adhere to the contract that we handle "no logs" the same as "logs".  _(And it turns out that ElasticSearchResponse magically also behaves like at iterable which is also confusing but that's a separate issue.)_
@dstandish dstandish force-pushed the use-none-instead-of-empty-object branch from 64a88dd to 61ca0b3 Compare November 7, 2023 20:22
@eladkal eladkal merged commit b3be18b into apache:main Nov 8, 2023
romsharon98 pushed a commit to romsharon98/airflow that referenced this pull request Nov 10, 2023
…pache#34793)

* Use None instead of empty data structures when no ElasticSearch logs

Previously, when there were no logs, we would just use [] or {} and continue to process them through functions such as "group by host" and such.  But if no logs are found, it's odd to go down those paths.

One example of the confusion is the return type in `es_read` was `list | ElasticSearchResponse`.  This makes it look like it would either be a list (presumably of logs?) or an ElasticSearchResponse object (presumably also containing logs?).  But in reality, the only time list was returned, was when there _were no logs at all!_  This was just to adhere to the contract that we handle "no logs" the same as "logs".  _(And it turns out that ElasticSearchResponse magically also behaves like at iterable which is also confusing but that's a separate issue.)_

* use more accurate variable names

* more accurate naming

* fix when no hits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants