Skip to content

Commit

Permalink
WIP need to fix the handling of multiple batch/simple processors
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl committed Nov 16, 2023
1 parent 907bf8a commit 02ee176
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 29 deletions.
12 changes: 7 additions & 5 deletions prototypes/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ classifiers = [
]
dependencies = [
"opentelemetry-api",
]

[project.optional-dependencies]
test = [
"pytest"
"opentelemetry-sdk",
"opentelemetry-exporter-otlp",
"opentelemetry-exporter-jaeger",
"opentelemetry-exporter-zipkin",
"jsonschema",
"pyyaml",
"jsonref"
]

[project.urls]
Expand Down
9 changes: 0 additions & 9 deletions prototypes/python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
jsonschema
pyyaml
opentelemetry-api
opentelemetry-sdk
opentelemetry-exporter-otlp
opentelemetry-exporter-jaeger
opentelemetry-exporter-zipkin
pytest
pdbpp
ipdb
referencing
jsonref
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
from ipdb import set_trace
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import (
OTLPSpanExporter as GRPCOTLPSpanExporter
)
from opentelemetry.exporter.otlp.proto.http.trace_exporter import (
OTLPSpanExporter as HTTPOTLPSpanExporter
)
from urllib.parse import urlparse

# flake8: noqa: E501


Expand All @@ -17,6 +28,7 @@ def logger_provider(


def logger_provider_processors(
# FIXME this should be able to handle multiple batch and simple processors
batch: object = None,
simple: object = None,
**kwargs
Expand Down Expand Up @@ -302,15 +314,26 @@ def tracer_provider(
processors: list = None,
sampler: object = None,
):
pass
set_trace()


def tracer_provider_processors(
batch: object = None,
simple: object = None,
**kwargs
):
pass

set_trace()

processors = []

if batch is not None:
processors.append(batch)

if simple is not None:
processors.append(simple)

return processors


def tracer_provider_processors_batch(
Expand All @@ -320,7 +343,13 @@ def tracer_provider_processors_batch(
max_queue_size: int = None,
schedule_delay: int = None,
):
pass
return BatchSpanProcessor(
exporter,
max_queue_size=max_queue_size,
schedule_delay_millis=schedule_delay,
max_export_batch_size=max_export_batch_size,
export_timeout_millis=export_timeout
)


def tracer_provider_processors_batch_exporter(
Expand All @@ -329,7 +358,7 @@ def tracer_provider_processors_batch_exporter(
zipkin: object = None,
**kwargs
):
pass
return console or otlp or zipkin


def tracer_provider_processors_batch_exporter_otlp(
Expand All @@ -342,32 +371,51 @@ def tracer_provider_processors_batch_exporter_otlp(
headers: object = None,
timeout: int = None,
):
pass

protocol = urlparse(protocol).scheme

if protocol.startswith("http"):
exporter_class = HTTPOTLPSpanExporter

else:
exporter_class = GRPCOTLPSpanExporter

return exporter_class(
endpoint=endpoint,
# insecure=None,
# FIXME somehow create credentials here
# from grpc.credentials import create_credentials
# credentials=create_credentials()
headers=headers,
timeout=timeout,
# compression=compression
)


def tracer_provider_processors_batch_exporter_otlp_headers(
**kwargs
):
pass
return kwargs


def tracer_provider_processors_batch_exporter_console(

):
pass
set_trace()


def tracer_provider_processors_batch_exporter_zipkin(
endpoint: str,
timeout: int = None,
):
pass
set_trace()


def tracer_provider_processors_simple(
exporter: object,
):
pass
set_trace()
return "simple"


def tracer_provider_processors_simple_exporter(
Expand All @@ -376,7 +424,7 @@ def tracer_provider_processors_simple_exporter(
zipkin: object = None,
**kwargs
):
pass
set_trace()


def tracer_provider_processors_simple_exporter_otlp(
Expand All @@ -389,26 +437,26 @@ def tracer_provider_processors_simple_exporter_otlp(
headers: object = None,
timeout: int = None,
):
pass
set_trace()


def tracer_provider_processors_simple_exporter_otlp_headers(
**kwargs
):
pass
set_trace()


def tracer_provider_processors_simple_exporter_console(

):
pass
set_trace()


def tracer_provider_processors_simple_exporter_zipkin(
endpoint: str,
timeout: int = None,
):
pass
set_trace()


def tracer_provider_limits(
Expand All @@ -419,7 +467,7 @@ def tracer_provider_limits(
link_attribute_count_limit: int = None,
link_count_limit: int = None,
):
pass
set_trace()


def resource(
Expand Down

0 comments on commit 02ee176

Please sign in to comment.