diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..afe9c91 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,39 @@ +name: Publish Python Package + +on: + push: + tags: + - 'v*' # Trigger on version tags + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Check out the code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.8' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + + - name: Update version based on tag + run: | + VERSION_TAG=${GITHUB_REF#refs/tags/} + sed -i "s/version=.*/version='${VERSION_TAG}',/" setup.py + + - name: Build the package + run: | + python setup.py sdist bdist_wheel + + - name: Publish to PyPI + env: + TWINE_API_KEY: ${{ secrets.PYPI_API_TOKEN }} + run: | + twine upload dist/* \ No newline at end of file diff --git a/initializer/components.py b/initializer/components.py index e5cb006..80eafa1 100644 --- a/initializer/components.py +++ b/initializer/components.py @@ -45,7 +45,7 @@ def _initialize_components(trace_exporters = None, metric_exporters = None, log_ .merge(OTELResourceDetector().detect()) \ .merge(ProcessResourceDetector().detect()) - initialize_traces_if_enabled(trace_exporters, resource) + initialize_traces_if_enabled(trace_exporters, resource, span_processor) initialize_metrics_if_enabled(metric_exporters, resource) initialize_logging_if_enabled(log_exporters, resource) @@ -63,32 +63,31 @@ def _initialize_components(trace_exporters = None, metric_exporters = None, log_ def initialize_traces_if_enabled(trace_exporters, resource, span_processor = None): traces_enabled = os.getenv(sdk_config.OTEL_TRACES_EXPORTER, "none").strip().lower() if traces_enabled != "none": - id_generator_name = sdk_config._get_id_generator() - id_generator = sdk_config._import_id_generator(id_generator_name) + + provider = TracerProvider(resource=resource) # TODO: uncomment once the OdigosSampler is implemented # odigos_sampler = OdigosSampler() # sampler = ParentBased(odigos_sampler) - - provider = TracerProvider( - id_generator=id_generator, - # sampler=sampler, - resource=resource, - ) - set_tracer_provider(provider) - - for _, exporter_class in trace_exporters.items(): - exporter_args = {} - if span_processor is not None: - provider.add_span_processor( - span_processor(exporter_class(**exporter_args)) - ) - else: - # Default to BatchSpanProcessor if no span processor is provided + # Exporting using exporters + if trace_exporters is not None: + id_generator_name = sdk_config._get_id_generator() + id_generator = sdk_config._import_id_generator(id_generator_name) + provider.id_generator = id_generator + + set_tracer_provider(provider) + + for _, exporter_class in trace_exporters.items(): + exporter_args = {} provider.add_span_processor( BatchSpanProcessor(exporter_class(**exporter_args)) ) + + # Exporting using EBPF + else: + if span_processor is not None: + provider.add_span_processor(span_processor) # return sampler diff --git a/setup.py b/setup.py index 98cea3b..7ce51a1 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,8 @@ from setuptools import setup, find_packages setup( - name="odigos-python-initializer", - version="0.1.0", + name="odigos-opentelemetry-python", + version="0.1.1", description="Odigos Initializer for Python OpenTelemetry Components", author="Tamir David", author_email="tamir@odigos.io",