Skip to content

Commit

Permalink
tweak pyo3-tracing-subscriber features
Browse files Browse the repository at this point in the history
  • Loading branch information
BatmanAoD committed Oct 9, 2024
1 parent 2aeb5a0 commit 5c5473d
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ quil-rs = { version = "0.28.1", git = "https://github.com/rigetti/quil-rs", tag
# and need to be updated together.
ndarray = { version = "0.15.6", features = ["serde"] }
numpy = "0.20.0"
pyo3 = { version = "0.20.0", features = ["extension-module"] }
pyo3 = { version = "0.20.0", default-features = false}
pyo3-asyncio = { version = "0.20", features = ["tokio-runtime"] }
pyo3-log = { version = "0.8.2" }
pyo3-opentelemetry = { version = "0.3" }
pyo3-tracing-subscriber = { version = "0.1.4", default-features = true }
pyo3-tracing-subscriber = { version = "0.1.4", default-features = false }

pyo3-build-config = "0.20.0"
rigetti-pyo3 = { version = "0.4.1", default-features = false, features = ["complex", "time"] }
Expand Down
6 changes: 3 additions & 3 deletions crates/python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ qcs = { path = "../lib", features = ["tracing-opentelemetry"] }
qcs-api-client-common = { workspace = true, features = ["python"] }
qcs-api-client-grpc.workspace = true
qcs-api-client-openapi.workspace = true
pyo3.workspace = true
pyo3 = { workspace = true, features = ["extension-module", "multiple-pymethods"] }
pyo3-asyncio.workspace = true
pyo3-opentelemetry.workspace = true
pyo3-tracing-subscriber = { workspace = true, features = ["layer-otel-otlp-file", "layer-otel-otlp"] }
pyo3-tracing-subscriber = { workspace = true, features = ["pyo3", "layer-otel-otlp-file", "layer-otel-otlp"] }
quil-rs.workspace = true
serde_json.workspace = true
tokio.workspace = true
Expand All @@ -44,7 +44,7 @@ prost = "0.13.3"
[build-dependencies]
pyo3 = { workspace = true, features = ["multiple-pymethods"] }
pyo3-build-config.workspace = true
pyo3-tracing-subscriber = { workspace = true, features = ["layer-otel-otlp-file", "layer-otel-otlp", "stubs"], default-features = false }
pyo3-tracing-subscriber = { workspace = true, features = ["layer-otel-otlp-file", "layer-otel-otlp", "stubs"] }

[lints.clippy]
too_many_arguments = "allow"
Expand Down
1 change: 1 addition & 0 deletions crates/python/qcs_sdk/_tracing_subscriber/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ from __future__ import annotations
from types import TracebackType
from typing import TYPE_CHECKING, Optional, Type, final

from . import common as common
from . import layers as layers
from . import subscriber as subscriber

Expand Down
18 changes: 18 additions & 0 deletions crates/python/qcs_sdk/_tracing_subscriber/common/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# *****************************************************************************
# * AUTO-GENERATED CODE *
# * *
# * This code was generated by the `pyo3-tracing-subscriber` crate. Any *
# * modifications to this file should be made to the script or the generation *
# * process that produced this code. Specifically, see: *
# * `pyo3_tracing_subscriber::stubs::write_stub_files` *
# * *
# * Do not manually edit this file, as your changes may be overwritten the *
# * next time the code is generated. *
# *****************************************************************************

from qcs_sdk._tracing_subscriber import common


__doc__ = common.__doc__
__all__ = getattr(common, "__all__", [])

45 changes: 45 additions & 0 deletions crates/python/qcs_sdk/_tracing_subscriber/common/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# *****************************************************************************
# * AUTO-GENERATED CODE *
# * *
# * This code was generated by the `pyo3-tracing-subscriber` crate. Any *
# * modifications to this file should be made to the script or the generation *
# * process that produced this code. Specifically, see: *
# * `pyo3_tracing_subscriber::stubs::write_stub_files` *
# * *
# * Do not manually edit this file, as your changes may be overwritten the *
# * next time the code is generated. *
# *****************************************************************************

from typing import Dict, Optional, final


@final
class InstrumentationLibrary:
"""
Information about a library or crate providing instrumentation.
An instrumentation library should be named to follow any naming conventions
of the instrumented library (e.g. 'middleware' for a web framework).
See the `instrumentation libraries <https://github.com/open-telemetry/opentelemetry-specification/blob/v1.9.0/specification/overview.md#instrumentation-libraries>`_
spec for more information.
"""

def __new__(
cls,
name: str,
version: Optional[str] = None,
schema_url: Optional[str] = None,
attributes: Optional[Dict[str, str]] = None,
) -> "InstrumentationLibrary":
"""
Initializes a new instance of `InstrumentationLibrary`.
:param name: The name of the instrumentation library.
:param version: The version of the instrumentation library.
:param schema_url: The `schema URL <https://opentelemetry.io/docs/specs/otel/schemas/>`_ of
the instrumentation library.
:param attributes: The attributes of the instrumentation library.
"""
...

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from __future__ import annotations
from typing import Dict, Optional, TYPE_CHECKING, final
from qcs_sdk._tracing_subscriber.common import InstrumentationLibrary

@final
class SpanLimits:
Expand Down Expand Up @@ -70,6 +71,7 @@ class Config:
timeout_millis: Optional[int] = None,
pre_shutdown_timeout_millis: Optional[int] = 2000,
filter: Optional[str] = None,
instrumentation_library: Optional[InstrumentationLibrary] = None,
) -> "Config":
"""
Initializes a new `Config`.
Expand All @@ -94,6 +96,7 @@ class Config:
If not specified, this will first check the `PYO3_TRACING_SUBSCRIBER_ENV_FILTER` environment variable
and then `RUST_LOG` environment variable. If all of these values are empty, no spans will be exported.
:param instrumentation_library: Information about the library providing the tracing instrumentation.
"""
...

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# *****************************************************************************

from typing import Optional, final
from qcs_sdk._tracing_subscriber.common import InstrumentationLibrary


@final
class Config:
Expand All @@ -19,7 +21,7 @@ class Config:
layer.
"""

def __new__(cls, *, file_path: Optional[str] = None, filter: Optional[str] = None) -> "Config":
def __new__(cls, *, file_path: Optional[str] = None, filter: Optional[str] = None, instrumentation_library: Optional[InstrumentationLibrary] = None) -> "Config":
"""
:param file_path: The path to the file to write to. If not specified, defaults to stdout.
:param filter: A filter string to use for this layer. This uses the same format as the
Expand All @@ -30,6 +32,7 @@ class Config:
If not specified, this will first check the `PYO3_TRACING_SUBSCRIBER_ENV_FILTER` environment variable
and then `RUST_LOG` environment variable. If all of these values are empty, no spans will be exported.
:param instrumentation_library: Information about the library providing the tracing instrumentation.
"""
...

0 comments on commit 5c5473d

Please sign in to comment.