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
45 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
dd1e246
adding Tim suggested changes
aravinsiva Aug 21, 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
adding tests, nox and correct attribute additions in client & job (le…
…ft out of last commit)
  • Loading branch information
aravinsiva committed Aug 9, 2020
commit f4aba6dac584f84a026c9e95c9c98a197c056a93
8 changes: 4 additions & 4 deletions google/cloud/bigquery/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1675,9 +1675,9 @@ def cancel_job(
span_creator = SpanCreator()

attributes = {"path": path,
"job_id": job_id,
"location": location
}
"job_id": job_id,
"location": location
}

with span_creator.create(name='BigQuery.CancelJob', attributes=attributes, client=self):
resource = self._call_api(
Expand Down Expand Up @@ -2870,7 +2870,7 @@ def insert_rows_json(
span_creator = SpanCreator()
attributes = {"path": path}
with span_creator.create(name='BigQuery.insertRowsJson', attributes=attributes, client=self):
response = self._call_api(
response = self._call_api(
retry,
method="POST",
path=path,
Expand Down
9 changes: 3 additions & 6 deletions google/cloud/bigquery/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,7 @@ def exists(self, client=None, retry=DEFAULT_RETRY, timeout=None):

try:
span_creator = SpanCreator()
attributes = extra_params
#attributes['path'] = self.path
attributes = {'path': self.path}
with span_creator.create(name='BigQuery.job.exists', attributes=attributes, job_ref=self):
client._call_api(
retry,
Expand Down Expand Up @@ -708,8 +707,7 @@ def reload(self, client=None, retry=DEFAULT_RETRY, timeout=None):
if self.location:
extra_params["location"] = self.location
span_creator = SpanCreator()
attributes = extra_params
#attributes['path'] = self.path
attributes = {'path': self.path}
with span_creator.create(name='BigQuery.job.reload', attributes=attributes, job_ref=self):
api_response = client._call_api(
retry,
Expand Down Expand Up @@ -746,8 +744,7 @@ def cancel(self, client=None, retry=DEFAULT_RETRY, timeout=None):

path = "{}/cancel".format(self.path)
span_creator = SpanCreator()
attributes = extra_params
#attributes['path'] = path
attributes = {'path': path}
with span_creator.create(name='BigQuery.job.cancel', attributes=attributes, job_ref=self):
api_response = client._call_api(
retry,
Expand Down
20 changes: 3 additions & 17 deletions google/cloud/bigquery/opentelemetry_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,12 @@

import logging
from contextlib import contextmanager

from google.api_core.exceptions import GoogleAPICallError
import pdb
from google.api_core.exceptions import GoogleAPICallError

Logger = logging.getLogger(__name__)
Comment thread
aravinsiva marked this conversation as resolved.
Outdated

try:
from opentelemetry import trace
from opentelemetry import propagators
from opentelemetry.trace import SpanContext
from opentelemetry.trace import get_current_span
from opentelemetry.trace import set_span_in_context
from opentelemetry.trace.status import Status
from opentelemetry.instrumentation.utils import http_status_to_canonical_code

Expand All @@ -44,15 +38,12 @@

class SpanCreator:
def __init__(self):
'''
Constructs a span creator with all default attributes
'''
# Constructs a span creator with all default attributes
self.opentelemetry_enbled = HAS_OPENTELEMETRY
Comment thread
aravinsiva marked this conversation as resolved.
Outdated
Comment thread
aravinsiva marked this conversation as resolved.
Outdated
self.attributes = {
'db.system': 'bigquery',
}


@contextmanager
def create(self, name, attributes=None, client=None, job_ref=None):
Comment thread
aravinsiva marked this conversation as resolved.
Outdated
if not self.opentelemetry_enbled:
Expand All @@ -69,7 +60,6 @@ def create(self, name, attributes=None, client=None, job_ref=None):

if attributes:
self.attributes.update(attributes)

# yield new span value
with tracer.start_as_current_span(name=name, attributes=self.attributes) as span:
try:
Expand All @@ -89,14 +79,10 @@ def set_job_attributes(self, job_ref):
self.attributes['num_child_jobs'] = str(job_ref.num_child_jobs)
self.attributes['job_id'] = job_ref.job_id
self.attributes['parent_job_id'] = job_ref.parent_job_id
#self.attributes['job_type'] = job_ref.job_type
# self.attributes['job_type'] = job_ref.job_type
self.attributes['timeCreated'] = job_ref.created
self.attributes['timeStarted'] = job_ref.started
self.attributes['timeEnded'] = job_ref.ended
self.attributes['errors'] = job_ref.errors
self.attributes['errorResult'] = job_ref.error_result
self.attributes['state'] = job_ref.state




9 changes: 8 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@ def default(session):
"""
# Install all test dependencies, then install local packages in-place.
session.install(
"mock", "pytest", "google-cloud-testutils", "pytest-cov", "freezegun"
"mock",
"pytest",
"google-cloud-testutils",
"pytest-cov",
"freezegun",
"opentelemetry-api",
Comment thread
aravinsiva marked this conversation as resolved.
Outdated
"opentelemetry-sdk",
"opentelemetry-instrumentation"
)
session.install("grpcio")

Expand Down