OTEL Python SDK extension supporting partial spans
Project description
partial-span-processor
OTEL Python SDK extension supporting partial spans
build
python -m build
pip install dist/partial_span_processor-0.0.x-py3-none-any.whl to install locally
publishing
requirement:
twine
python3 -m twine upload --repository pypi dist/*
usage
import time
from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import \
OTLPSpanExporter
from opentelemetry.exporter.otlp.proto.http._log_exporter import OTLPLogExporter
from opentelemetry.sdk._logs._internal.export import SimpleLogRecordProcessor
from opentelemetry.sdk.trace import TracerProvider
from partial_span_processor import PartialSpanProcessor
# Create a TracerProvider
provider = TracerProvider()
# Configure OTLP exporters
span_exporter = OTLPSpanExporter(endpoint="localhost:4317",
insecure=True) # grpc
log_exporter = OTLPLogExporter(endpoint="http://localhost:4318/v1/logs") # http
span_processor = PartialSpanProcessor(span_exporter,
SimpleLogRecordProcessor(log_exporter))
provider.add_span_processor(span_processor)
# Set the global TracerProvider
trace.set_tracer_provider(provider)
tracer = trace.get_tracer(__name__)
# Start a span (logs heartbeat and stop events)
with tracer.start_as_current_span("partial_span_1"):
print("partial_span_1 is running")
with tracer.start_as_current_span("partial_span_2"):
print("partial_span_2 is running")
with tracer.start_as_current_span("partial_span_3"):
print("partial_span_3 is running")
time.sleep(150)
provider.shutdown()
usage config
- install python version 3.13.1
- create a working dir
test - create venv
python3 -m venv venv - copy above example script and name it
test.py - create
requirements.txtwith content
opentelemetry-api
opentelemetry-sdk
opentelemetry-exporter-otlp
opentelemetry-instrumentation-logging
partial-span-processor
- install requirements
pip install -r requirements.txt - run script
python test.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file partial_span_processor-0.0.2.tar.gz.
File metadata
- Download URL: partial_span_processor-0.0.2.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e92015ea34573765b1cf923419555a5f2ac884293e0a0a62b2f7222dc6e39712
|
|
| MD5 |
f0594de93541cda3a9cf606de6014af1
|
|
| BLAKE2b-256 |
0c9eacd46220c05c67e6a8fdd99f7e1f2aa31838183086d1070d95630522fb90
|
File details
Details for the file partial_span_processor-0.0.2-py3-none-any.whl.
File metadata
- Download URL: partial_span_processor-0.0.2-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f451661c687694e47d335577056c4d141007d949fa5b3d0d44e3581f0e1081f1
|
|
| MD5 |
c2d2f597daf5a7539262e90234a374b3
|
|
| BLAKE2b-256 |
2e498d21b2e67901b5a5367b5f289151bec15e4e717fe430ae769676bab5fea5
|