Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenTelemetry Tracing #26

Open
wants to merge 76 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
806d206
initial commit
aMahanna Nov 23, 2023
d0d66b7
fix `pip install`
aMahanna Nov 23, 2023
b2100a5
fix pip install
aMahanna Nov 23, 2023
f173fc6
fix pip install
aMahanna Nov 23, 2023
5734076
parameterize otlp endpoint
aMahanna Nov 23, 2023
e778392
fix: `otlp_endpoint` param
aMahanna Nov 23, 2023
82e0e3d
fix: `span_exporters` param
aMahanna Nov 23, 2023
123e6d6
cleanup
aMahanna Nov 23, 2023
4e2b3f0
Update README.md
aMahanna Nov 23, 2023
9ca93bd
new: `TracingManager.set_attributes()`
aMahanna Nov 30, 2023
d549251
early exit for `with_tracing`
aMahanna Dec 3, 2023
eeb9a7a
cleanup tracer import
aMahanna Dec 3, 2023
bba46cd
new: `benchmark` dir
aMahanna Dec 5, 2023
68e68a3
cleanup `tests`
aMahanna Dec 5, 2023
c374534
Create benchmark.yml
aMahanna Dec 5, 2023
cde8808
Update .gitignore
aMahanna Dec 5, 2023
2f5c23a
Update benchmark.yml
aMahanna Dec 5, 2023
bc89200
Update benchmark.yml
aMahanna Dec 5, 2023
f0352c4
Update benchmark.yml
aMahanna Dec 5, 2023
19dd073
fix lint
aMahanna Dec 5, 2023
261d224
cleanup
aMahanna Dec 5, 2023
10b1d6c
Update benchmark.yml
aMahanna Dec 5, 2023
e08b111
Update benchmark.yml
aMahanna Dec 5, 2023
aff682e
Update benchmark.yml
aMahanna Dec 5, 2023
eee8128
Merge branch 'master' into tracing
aMahanna Dec 16, 2023
83672c5
cleanup tracing, new spans, new attributes
aMahanna Dec 16, 2023
9e2fa4c
cleanup: `benchmark`
aMahanna Dec 16, 2023
2e9151d
add `retry` dev dependency
aMahanna Dec 16, 2023
3260723
fix: `__set_adb_data`
aMahanna Dec 16, 2023
bca1b1d
fix: `improvement`
aMahanna Dec 16, 2023
c5cb4c0
update benchmark.yml
aMahanna Dec 16, 2023
8382e8b
cleanup: `benchmark`
aMahanna Dec 16, 2023
0ed2071
install `tracing` dependencies in `build.yml`
aMahanna Dec 16, 2023
de4a1a7
pragma no cover
aMahanna Dec 16, 2023
78a88de
update `master` traces
aMahanna Dec 23, 2023
f3e268a
update `benchmark/write.py`
aMahanna Dec 23, 2023
38dd8ef
cleanup compare.py
aMahanna Dec 23, 2023
a685637
tracing cleanup
aMahanna Dec 23, 2023
63ee345
cleanup tracing (again)
aMahanna Dec 23, 2023
c81fbc5
fix `compare.py`
aMahanna Dec 23, 2023
cf95b8a
new master traces
aMahanna Dec 23, 2023
b3eeb86
pragma no cover
aMahanna Dec 23, 2023
265c3b2
Update benchmark.yml
aMahanna Dec 23, 2023
a856796
Update benchmark.yml
aMahanna Dec 23, 2023
ae3b12a
jq
aMahanna Dec 23, 2023
2399b85
Update benchmark.yml
aMahanna Dec 23, 2023
85a0865
Update benchmark.yml
aMahanna Dec 23, 2023
cbb6392
Update benchmark.yml
aMahanna Dec 23, 2023
fc6b149
Update benchmark.yml
aMahanna Dec 23, 2023
d2a46c3
fix typo
aMahanna Dec 23, 2023
42976c4
Update benchmark.yml
aMahanna Dec 23, 2023
ef6a746
jq
aMahanna Dec 23, 2023
12adb6e
Update benchmark.yml
aMahanna Dec 23, 2023
ced88ab
Update benchmark.yml
aMahanna Dec 23, 2023
a9d9249
Update benchmark.yml
aMahanna Dec 23, 2023
28629ef
fix double quotes
aMahanna Dec 23, 2023
dc0e031
Update write.py
aMahanna Dec 23, 2023
17c4995
cleanup
aMahanna Dec 23, 2023
62efe15
cleanup `compare.py`
aMahanna Dec 23, 2023
bc50b6f
update benchmark readme files
aMahanna Dec 23, 2023
3d0e3de
new: `continue-on-error`
aMahanna Jan 18, 2024
ddbd331
fix: custom span names for `@with_tracing` decorator
aMahanna Jan 18, 2024
704cbba
cleanup: `__fetch_adb_docs`
aMahanna Jan 19, 2024
bd3e06c
fix private method span names
aMahanna Jan 19, 2024
0744148
regenerate "master" traces
aMahanna Jan 19, 2024
16ace5c
add README
aMahanna Jan 19, 2024
3f35755
fix benchmark assertions
aMahanna Jan 19, 2024
de16e8d
fix `start_as_current_span`
aMahanna Jan 26, 2024
77b7a81
fix: `operationName`
aMahanna Jan 26, 2024
67378e8
fix: edge_index
aMahanna Feb 9, 2024
d325fd4
Merge branch 'master' into tracing
aMahanna Feb 9, 2024
36e33e5
empty commit to rerun benchmark
aMahanna Feb 9, 2024
91aed84
attempt: insert_many instead of import_bulk
aMahanna Feb 27, 2024
b8a19b3
temp: fix parameters for `insert_many`, skip test
aMahanna Feb 27, 2024
7fb9f67
switch back to `import_bulk`
aMahanna Feb 27, 2024
7c67b70
Merge branch 'master' into tracing
aMahanna Feb 27, 2024
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
fix: custom span names for @with_tracing decorator
(private methods only)
  • Loading branch information
aMahanna committed Jan 18, 2024
commit ddbd3318e5efb8ee4e643608f0f3ca69f2230c33
48 changes: 24 additions & 24 deletions adbpyg_adapter/adapter.py
Original file line number Diff line number Diff line change
@@ -126,7 +126,7 @@ def set_tracer(self, tracer: Optional["Tracer"]) -> None:
# Public: ArangoDB -> PyG #
###########################

@with_tracing
@with_tracing()
def arangodb_to_pyg(
self,
name: str,
@@ -363,7 +363,7 @@ def udf_v1_x(v1_df):
logger.info(f"Created PyG '{name}' Graph")
return data

@with_tracing
@with_tracing()
def arangodb_collections_to_pyg(
self,
name: str,
@@ -417,7 +417,7 @@ def arangodb_collections_to_pyg(
name, metagraph, preserve_adb_keys, strict, **adb_export_kwargs
)

@with_tracing
@with_tracing()
def arangodb_graph_to_pyg(
self,
name: str,
@@ -469,7 +469,7 @@ def arangodb_graph_to_pyg(
# Public: PyG -> ArangoDB #
###########################

@with_tracing
@with_tracing()
def pyg_to_arangodb(
self,
name: str,
@@ -696,7 +696,7 @@ def y_tensor_to_2_column_dataframe(pyg_tensor, adb_df):
# Private: ArangoDB -> PyG #
############################

@with_tracing
@with_tracing("__process_adb_v_col")
def __process_adb_v_col(
self,
v_col: str,
@@ -742,7 +742,7 @@ def __process_adb_v_col(
node_data=node_data,
)

@with_tracing
@with_tracing("__process_adb_e_col")
def __process_adb_e_col(
self,
e_col: str,
@@ -801,7 +801,7 @@ def __process_adb_e_col(
is_homogeneous=is_homogeneous,
)

@with_tracing
@with_tracing("__fetch_adb_docs")
def __fetch_adb_docs(
self,
col: str,
@@ -865,7 +865,7 @@ def get_aql_return_value(

return cursor, col_size

@with_tracing
@with_tracing("__process_adb_cursor")
def __process_adb_cursor(
self,
progress_color: str,
@@ -916,7 +916,7 @@ def __process_adb_cursor(
if cursor.has_more():
cursor.fetch()

@with_tracing
@with_tracing("__process_adb_vertex_df")
def __process_adb_vertex_df(
self,
i: int,
@@ -963,7 +963,7 @@ def __process_adb_vertex_df(

return i

@with_tracing
@with_tracing("__process_adb_edge_df")
def __process_adb_edge_df(
self,
_: int,
@@ -1067,7 +1067,7 @@ def __process_adb_edge_df(

return 1 # Useless return value, but needed for type hinting

@with_tracing
@with_tracing("__split_adb_ids")
def __split_adb_ids(self, s: Series) -> Series:
"""AranogDB -> PyG: Helper method to split the ArangoDB IDs
within a Series into two columns
@@ -1080,7 +1080,7 @@ def __split_adb_ids(self, s: Series) -> Series:
"""
return s.str.split(pat="/", n=1, expand=True)

@with_tracing
@with_tracing("__set_pyg_data")
def __set_pyg_data(
self,
meta: Union[Set[str], Dict[str, ADBMetagraphValues]],
@@ -1116,7 +1116,7 @@ def __set_pyg_data(
m = f"'{k}' key in PyG Data must point to a Tensor"
raise TypeError(m)

@with_tracing
@with_tracing("__build_tensor_from_dataframe")
def __build_tensor_from_dataframe(
self,
adb_df: DataFrame,
@@ -1173,7 +1173,7 @@ def __build_tensor_from_dataframe(
# Private: PyG -> ArangoDB #
############################

@with_tracing
@with_tracing("__get_node_and_edge_types")
def __get_node_and_edge_types(
self,
name: str,
@@ -1217,7 +1217,7 @@ def __get_node_and_edge_types(

return node_types, edge_types

@with_tracing
@with_tracing("__etypes_to_edefinitions")
def __etypes_to_edefinitions(self, edge_types: List[EdgeType]) -> List[Json]:
"""PyG -> ArangoDB: Converts PyG edge_types to ArangoDB edge_definitions

@@ -1262,7 +1262,7 @@ def __etypes_to_edefinitions(self, edge_types: List[EdgeType]) -> List[Json]:

return edge_definitions

@with_tracing
@with_tracing("__ntypes_to_ocollections")
def __ntypes_to_ocollections(
self, node_types: List[str], edge_types: List[EdgeType]
) -> List[str]:
@@ -1286,7 +1286,7 @@ def __ntypes_to_ocollections(
orphan_collections = set(node_types) ^ non_orphan_collections
return list(orphan_collections)

@with_tracing
@with_tracing("__create_adb_graph")
def __create_adb_graph(
self,
name: str,
@@ -1325,7 +1325,7 @@ def __create_adb_graph(
orphan_collections,
)

@with_tracing
@with_tracing("__process_pyg_node_batch")
def __process_pyg_node_batch(
self,
n_type: str,
@@ -1385,7 +1385,7 @@ def __process_pyg_node_batch(

return df

@with_tracing
@with_tracing("__process_pyg_edge_batch")
def __process_pyg_edge_batch(
self,
e_type: EdgeType,
@@ -1461,7 +1461,7 @@ def __process_pyg_edge_batch(

return df

@with_tracing
@with_tracing("__process_pyg_n_type")
def __process_pyg_n_type(
self,
n_type: str,
@@ -1513,7 +1513,7 @@ def __process_pyg_n_type(
adb_import_kwargs,
)

@with_tracing
@with_tracing("__process_pyg_e_type")
def __process_pyg_e_type(
self,
e_type: EdgeType,
@@ -1619,7 +1619,7 @@ def __process_batches(
start_index = end_index
end_index = min(end_index + batch_size, total_size)

@with_tracing
@with_tracing("__set_adb_data")
def __set_adb_data(
self,
df: DataFrame,
@@ -1705,7 +1705,7 @@ def __set_adb_data(

return df

@with_tracing
@with_tracing("__build_dataframe_from_tensor")
def __build_dataframe_from_tensor(
self,
pyg_tensor: Tensor,
@@ -1782,7 +1782,7 @@ def __build_dataframe_from_tensor(

raise PyGMetagraphError(f"Invalid {meta_val} type") # pragma: no cover

@with_tracing
@with_tracing("__insert_adb_docs")
def __insert_adb_docs(
self,
spinner_progress: Progress,
23 changes: 13 additions & 10 deletions adbpyg_adapter/tracing.py
Original file line number Diff line number Diff line change
@@ -50,19 +50,22 @@ def set_attributes(self, **attributes: Any) -> None: # pragma: no cover
T = TypeVar("T", bound=Callable[..., Any])


def with_tracing(method: T) -> T:
if not TRACING_ENABLED:
return method # pragma: no cover
def with_tracing(span_name: Optional[str] = None) -> Callable[[T], T]:
def decorator(method: T) -> T:
if not TRACING_ENABLED:
return method # pragma: no cover

@wraps(method)
def decorator(*args: Any, **kwargs: Any) -> Any:
if tracer := TracingManager.get_tracer():
with tracer.start_as_current_span(method.__name__):
return method(*args, **kwargs)
@wraps(method)
def wrapper(*args: Any, **kwargs: Any) -> Any:
if tracer := TracingManager.get_tracer():
with tracer.start_as_current_span(span_name or method.__name__):
return method(*args, **kwargs)

return method(*args, **kwargs)
return method(*args, **kwargs)

return cast(T, decorator)
return cast(T, wrapper)

return decorator


@contextmanager
Loading