Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 26 additions & 16 deletions libs/community/google/ads/garf/community/google/ads/api_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from google.ads.googleads import client as googleads_client
from google.api_core import exceptions as google_exceptions
from opentelemetry import trace
from opentelemetry.context import attach, detach, set_value
from typing_extensions import override

GOOGLE_ADS_API_VERSION: Final = googleads_client._DEFAULT_VERSION
Expand Down Expand Up @@ -94,13 +95,17 @@ def get_response(
request = search_ads_360_client.SearchSearchAds360StreamRequest(
query=request.text, customer_id=account
)
response = self.search_ads_360_service.search_stream(request)
results = []
query_resource_consumption = 0
for batch in response:
query_resource_consumption += batch.query_resource_consumption
for result in batch.results:
results.append(result)
suppress_token = attach(set_value('suppress_instrumentation', True))
try:
response = self.search_ads_360_service.search_stream(request)
results = []
query_resource_consumption = 0
for batch in response:
query_resource_consumption += batch.query_resource_consumption
for result in batch.results:
results.append(result)
finally:
detach(suppress_token)
span.set_attributes(
{
'sa360.query_resource_consumption': query_resource_consumption,
Expand Down Expand Up @@ -343,15 +348,20 @@ def get_response(
"""Executes a single API request for a given customer_id and GAQL query."""
span = trace.get_current_span()
gaql_query = _create_gaql_query(request)
response = self.ads_service.search_stream(
customer_id=account, query=gaql_query
)
results = []
query_resource_consumption = 0
for batch in response:
query_resource_consumption += batch.query_resource_consumption
for result in batch.results:
results.append(result)
suppress_token = attach(set_value('suppress_instrumentation', True))
try:
response = self.ads_service.search_stream(
customer_id=account, query=gaql_query
)
results = []
query_resource_consumption = 0
for batch in response:
query_resource_consumption += batch.query_resource_consumption
for result in batch.results:
results.append(result)
finally:
detach(suppress_token)

span.set_attributes(
{
'google.ads.query_resource_consumption': query_resource_consumption,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
__version__ = '1.2.0'
__version__ = '1.2.1'
Loading