Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
b13ad47
testing first trace export
aravinsiva Aug 1, 2020
cacea7c
instrumention client.py
aravinsiva Aug 3, 2020
63e9581
instrumenting job.py and adding documentation
aravinsiva Aug 4, 2020
719ed83
reconfiguring imports
aravinsiva Aug 4, 2020
72f22b6
quick cleanup of unused variable
aravinsiva Aug 5, 2020
ff8171f
adding more attributes in module and limiting complexity of instrumen…
aravinsiva Aug 7, 2020
456b445
adding tests, nox and correct attribute additions in client & job
aravinsiva Aug 9, 2020
f4aba6d
adding tests, nox and correct attribute additions in client & job (le…
aravinsiva Aug 9, 2020
e223657
linting
aravinsiva Aug 9, 2020
78b8298
reformatting noxfile.[y
aravinsiva Aug 9, 2020
88b1a57
Merge branch 'master' into opentelemetry-tracing
aravinsiva Aug 9, 2020
e0895c9
Merge branch 'master' into opentelemetry-tracing
aravinsiva Aug 10, 2020
95a35ad
addressing suggested changes
aravinsiva Aug 11, 2020
3bf4574
Merge branch 'opentelemetry-tracing' of https://github.com/aravinsiva…
aravinsiva Aug 11, 2020
4dbb692
adding suggested changes
aravinsiva Aug 12, 2020
406f61a
removing print statements
aravinsiva Aug 12, 2020
c2b9add
setting same version across all OT [ackages and other reccommended ch…
aravinsiva Aug 12, 2020
d425909
suggested changes
aravinsiva Aug 12, 2020
64ec5fd
fixing packages issue in nox and updating documentation
aravinsiva Aug 13, 2020
73230dc
fixing module install issue
aravinsiva Aug 13, 2020
ae04fc6
restructuring design for testing adding first layer of tests (some st…
aravinsiva Aug 14, 2020
ac56488
adding reamining client tests and all job tests
aravinsiva Aug 15, 2020
d4de926
fixing linting issues
aravinsiva Aug 15, 2020
2d8aeb3
Merge branch 'master' into opentelemetry-tracing
tswast Aug 17, 2020
cd8e303
fixing trace not defined issue
aravinsiva Aug 17, 2020
d8c601d
fixing lint issues
aravinsiva Aug 17, 2020
2bcd106
fixing documentation issues and python2 testing issue
aravinsiva Aug 17, 2020
f1de589
linting and fixing coverage issues
aravinsiva Aug 18, 2020
72a77d1
Merge branch 'master' into opentelemetry-tracing
tswast Aug 18, 2020
0c7b354
adding suggested changes
aravinsiva Aug 18, 2020
51045f1
Merge branch 'opentelemetry-tracing' of https://github.com/aravinsiva…
aravinsiva Aug 18, 2020
ec96f5c
linting
aravinsiva Aug 18, 2020
35afadf
Merge branch 'master' into opentelemetry-tracing
aravinsiva Aug 18, 2020
5a32ad4
adding Shawn's suggested changes
aravinsiva Aug 19, 2020
1d7155c
Merge branch 'opentelemetry-tracing' of https://github.com/aravinsiva…
aravinsiva Aug 19, 2020
54c133a
fixing _default_span_attribute_bug
aravinsiva Aug 19, 2020
3aff14d
reverting uneccesxsary changes
aravinsiva Aug 19, 2020
59477ff
adding more tests for all job_ref parameters
aravinsiva Aug 19, 2020
0d15998
removing dependecny, ordering imports and other changes
aravinsiva Aug 20, 2020
d997175
addressing Shawn concerns
aravinsiva Aug 20, 2020
61b5b85
adding test and suggested changes
aravinsiva Aug 20, 2020
4d1dec1
adding opentelemetry to setup.py and other suggested changes
aravinsiva Aug 20, 2020
7704975
adding reasoning for not adding to [all]
aravinsiva Aug 20, 2020
839cd92
linting
aravinsiva Aug 20, 2020
55c322e
adding nested functions
aravinsiva Aug 21, 2020
4f66ffb
adding test
aravinsiva Aug 21, 2020
dd1e246
adding Tim suggested changes
aravinsiva Aug 21, 2020
5b3a202
adding full tests
aravinsiva Aug 22, 2020
9757812
Merge branch 'opentelemetry-tracing' of https://github.com/aravinsiva…
aravinsiva Aug 22, 2020
b0ac6eb
Merge pull request #1 from aravinsiva/adding_telemetry_to_non_api_calls
aravinsiva Aug 22, 2020
c75f827
Merge branch 'opentelemetry-tracing' of https://github.com/aravinsiva…
aravinsiva Aug 22, 2020
745775e
Merge branch 'master' of https://github.com/aravinsiva/python-bigquer…
aravinsiva Aug 24, 2020
9e087ff
linting and fixing missing test
aravinsiva Aug 24, 2020
d858ef5
Merge branch 'master' into adding_telemetry_to_non_api_calls
aravinsiva Aug 24, 2020
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
Prev Previous commit
Next Next commit
linting and fixing coverage issues
  • Loading branch information
aravinsiva committed Aug 18, 2020
commit f1de589c99f0bd6c2f3c3335b5c486df4fabe5b1
38 changes: 25 additions & 13 deletions tests/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,9 @@ def test__get_query_results_miss_w_explicit_project_and_timeout(self):
timeout_ms=500,
timeout=42,
)
final_attributes.assert_called_once_with({"path": path}, client, None)
final_attributes.assert_called_once_with(
{"path": path}, client, None
) # pragma: NO COVER

conn.api_request.assert_called_once_with(
method="GET",
Expand Down Expand Up @@ -673,7 +675,7 @@ def test_get_dataset(self):
"google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
) as final_attributes:
client.get_dataset(dataset_ref)
final_attributes.assert_called_once_with(
final_attributes.assert_called_once_with( # pragma: NO COVER
{"path": "/%s" % path}, client, None
)

Expand All @@ -684,7 +686,7 @@ def test_get_dataset(self):
"google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
) as final_attributes:
client.get_dataset(dataset_ref)
final_attributes.assert_called_once_with(
final_attributes.assert_called_once_with( # pragma: NO COVER
{"path": "/%s" % path}, client, None
)

Expand All @@ -698,7 +700,9 @@ def test_get_dataset(self):
) as final_attributes:
client.get_dataset(dataset_ref)

final_attributes.assert_called_once_with({"path": path}, client, None)
final_attributes.assert_called_once_with(
{"path": path}, client, None
) # pragma: NO COVER

# Retryable reason, but retry is disabled.
client._connection = make_connection(
Expand All @@ -710,7 +714,7 @@ def test_get_dataset(self):
) as final_attributes:
client.get_dataset(dataset_ref, retry=None)

final_attributes.assert_called_once_with(
final_attributes.assert_called_once_with( # pragma: NO COVER
{"path": "/%s" % path}, client, None
)

Expand Down Expand Up @@ -1157,7 +1161,9 @@ def test_create_dataset_alreadyexists_w_exists_ok_false(self):
) as final_attributes:
client.create_dataset(self.DS_ID)

final_attributes.assert_called_once_with({"path": "path"}, client, None)
final_attributes.assert_called_once_with(
{"path": "path"}, client, None
) # pragma: NO COVER

def test_create_dataset_alreadyexists_w_exists_ok_true(self):
post_path = "/projects/{}/datasets".format(self.PROJECT)
Expand Down Expand Up @@ -1257,7 +1263,7 @@ def test_create_routine_w_conflict(self):
) as final_attributes:
client.create_routine(routine)

final_attributes.assert_called_once_with(
final_attributes.assert_called_once_with( # pragma: NO COVER
{"path": path, "exists_okay": False}, client, None
)

Expand Down Expand Up @@ -1721,7 +1727,7 @@ def test_create_table_alreadyexists_w_exists_ok_false(self):
) as final_attributes:
client.create_table("{}.{}".format(self.DS_ID, self.TABLE_ID))

final_attributes.assert_called_with(
final_attributes.assert_called_with( # pragma: NO COVER
{"path": post_path, "dataset_id": self.TABLE_REF.dataset_id},
client,
None,
Expand Down Expand Up @@ -2137,7 +2143,7 @@ def test_set_iam_policy_invalid_policy(self):
) as final_attributes:
client.set_iam_policy(self.TABLE_REF, invalid_policy_repr)

final_attributes.assert_called_once_with(
final_attributes.assert_called_once_with( # pragma: NO COVER
{"path": "{}:setIamPolicy".format(self.TABLE_REF.path)}, client, None
)

Expand All @@ -2162,7 +2168,7 @@ def test_set_iam_policy_w_invalid_table(self):
) as final_attributes:
client.set_iam_policy(table_resource_string, policy)

final_attributes.assert_called_once_with(
final_attributes.assert_called_once_with( # pragma: NO COVER
{"path": table_resource_string}, client, None
)

Expand Down Expand Up @@ -3246,7 +3252,9 @@ def test_delete_dataset_w_not_found_ok_false(self):
) as final_attributes:
client.delete_dataset(self.DS_ID)

final_attributes.assert_called_once_with({"path": path}, client, None)
final_attributes.assert_called_once_with(
{"path": path}, client, None
) # pragma: NO COVER

conn.api_request.assert_called_with(
method="DELETE", path=path, query_params={}, timeout=None
Expand Down Expand Up @@ -3397,7 +3405,9 @@ def test_delete_routine_w_not_found_ok_false(self):
) as final_attributes:
client.delete_routine("routines-project.test_routines.test_routine")

final_attributes.assert_called_once_with({"path": path}, client, None)
final_attributes.assert_called_once_with(
{"path": path}, client, None
) # pragma: NO COVER

conn.api_request.assert_called_with(
method="DELETE", path=path, timeout=None,
Expand Down Expand Up @@ -3483,7 +3493,9 @@ def test_delete_table_w_not_found_ok_false(self):
) as final_attributes:
client.delete_table("{}.{}".format(self.DS_ID, self.TABLE_ID))

final_attributes.assert_called_once_with({"path": path}, client, None)
final_attributes.assert_called_once_with(
{"path": path}, client, None
) # pragma: NO COVER

conn.api_request.assert_called_with(method="DELETE", path=path, timeout=None)

Expand Down
30 changes: 15 additions & 15 deletions tests/unit/test_opentelemetry_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@

import mock

from google.cloud.bigquery import opentelemetry_tracing, client
from google.cloud.bigquery import opentelemetry_tracing

try:
import opentelemetry
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleExportSpanProcessor
from opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporter
from opentelemetry.sdk.trace.export.in_memory_span_exporter import (
InMemorySpanExporter,
)
except ImportError:
opentelemetry = None

Expand Down Expand Up @@ -47,7 +49,7 @@ def test_opentelemetry_success(setup):
expected_attributes = {"foo": "baz", "db.system": "BigQuery"}

with opentelemetry_tracing.create_span(
TEST_SPAN_NAME, attributes=TEST_SPAN_ATTRIBUTES, client=None, job_ref=None
TEST_SPAN_NAME, attributes=TEST_SPAN_ATTRIBUTES, client=None, job_ref=None
) as span:
assert span is not None
assert span.name == TEST_SPAN_NAME
Expand All @@ -63,11 +65,11 @@ def test_default_client_attributes(setup):
"db.name": "test_project",
"location": "test_location",
}
with mock.patch('google.cloud.bigquery.client.Client') as test_client:
test_client.project = 'test_project'
test_client.location = 'test_location'
with mock.patch("google.cloud.bigquery.client.Client") as test_client:
test_client.project = "test_project"
test_client.location = "test_location"
with opentelemetry_tracing.create_span(
TEST_SPAN_NAME, attributes=TEST_SPAN_ATTRIBUTES, client=test_client
TEST_SPAN_NAME, attributes=TEST_SPAN_ATTRIBUTES, client=test_client
) as span:
assert span is not None
assert span.name == TEST_SPAN_NAME
Expand All @@ -85,17 +87,15 @@ def test_default_job_attributes(setup):
"job_id": "test_job_id",
"foo": "baz",
}
with mock.patch('google.cloud.bigquery.job._AsyncJob') as test_job_ref:
test_job_ref.job_id = 'test_job_id'
test_job_ref.location = 'test_location'
test_job_ref.project = 'test_project_id'
test_job_ref.num_child_jobs = '0'
with mock.patch("google.cloud.bigquery.job._AsyncJob") as test_job_ref:
test_job_ref.job_id = "test_job_id"
test_job_ref.location = "test_location"
test_job_ref.project = "test_project_id"
test_job_ref.num_child_jobs = "0"

with opentelemetry_tracing.create_span(
TEST_SPAN_NAME, attributes=TEST_SPAN_ATTRIBUTES, job_ref=test_job_ref
TEST_SPAN_NAME, attributes=TEST_SPAN_ATTRIBUTES, job_ref=test_job_ref
) as span:
assert span is not None
assert span.name == TEST_SPAN_NAME
assert span.attributes == expected_attributes