Skip to content

Commit

Permalink
Merge pull request #7 from odigos-io/adding-publish-workflow
Browse files Browse the repository at this point in the history
Adding publish workflow
  • Loading branch information
tamirdavid1 authored Aug 19, 2024
2 parents 632eaac + 021fe1f commit 395f4ee
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 21 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -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/*
37 changes: 18 additions & 19 deletions initializer/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 395f4ee

Please sign in to comment.