Skip to main content

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.txt with 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

partial_span_processor-0.0.2.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

partial_span_processor-0.0.2-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

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

Hashes for partial_span_processor-0.0.2.tar.gz
Algorithm Hash digest
SHA256 e92015ea34573765b1cf923419555a5f2ac884293e0a0a62b2f7222dc6e39712
MD5 f0594de93541cda3a9cf606de6014af1
BLAKE2b-256 0c9eacd46220c05c67e6a8fdd99f7e1f2aa31838183086d1070d95630522fb90

See more details on using hashes here.

File details

Details for the file partial_span_processor-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for partial_span_processor-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f451661c687694e47d335577056c4d141007d949fa5b3d0d44e3581f0e1081f1
MD5 c2d2f597daf5a7539262e90234a374b3
BLAKE2b-256 2e498d21b2e67901b5a5367b5f289151bec15e4e717fe430ae769676bab5fea5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page