Skip to content

Commit

Permalink
Implement tracer provider methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl committed Nov 17, 2023
1 parent 44effe9 commit 00df552
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -442,11 +442,9 @@ def create_object(configuration_dictionary, path, schema_paths) -> object:

for element in configuration_dictionary_value:

# FIXME can we remove this if?
if isinstance(element, dict):
object_.append(
create_object(element, path, schema_paths)
)
object_.append(
create_object(element, path, schema_paths)
)

path.pop()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
from ipdb import set_trace
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import (
TracerProvider, SynchronousMultiSpanProcessor
TracerProvider, SynchronousMultiSpanProcessor, SpanLimits
)
from opentelemetry.sdk.trace.export import (
BatchSpanProcessor, ConsoleSpanExporter, SimpleSpanProcessor
)
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 opentelemetry.exporter.zipkin.proto.http import ZipkinExporter
from urllib.parse import urlparse

# flake8: noqa: E501
Expand Down Expand Up @@ -327,8 +330,6 @@ def tracer_provider(
# FIXME how to define id_generator?
# FIXME how to define if the span processors should be synchronous or not?

set_trace()

synchronous_multi_span_processor = SynchronousMultiSpanProcessor()

if processors is not None:
Expand All @@ -348,9 +349,6 @@ def tracer_provider_processors(
simple: object = None,
**kwargs
):

set_trace()

return batch or simple


Expand All @@ -361,7 +359,6 @@ def tracer_provider_processors_batch(
max_queue_size: int = None,
schedule_delay: int = None,
):
set_trace()
return BatchSpanProcessor(
exporter,
max_queue_size=max_queue_size,
Expand All @@ -377,7 +374,6 @@ def tracer_provider_processors_batch_exporter(
zipkin: object = None,
**kwargs
):
set_trace()
return console or otlp or zipkin


Expand All @@ -391,7 +387,6 @@ def tracer_provider_processors_batch_exporter_otlp(
headers: object = None,
timeout: int = None,
):
set_trace()

protocol = urlparse(protocol).scheme

Expand All @@ -416,28 +411,24 @@ def tracer_provider_processors_batch_exporter_otlp(
def tracer_provider_processors_batch_exporter_otlp_headers(
**kwargs
):
set_trace()
return kwargs


def tracer_provider_processors_batch_exporter_console(

):
set_trace()
def tracer_provider_processors_batch_exporter_console():
return ConsoleSpanExporter


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


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


def tracer_provider_processors_simple_exporter(
Expand All @@ -446,7 +437,7 @@ def tracer_provider_processors_simple_exporter(
zipkin: object = None,
**kwargs
):
set_trace()
return console or otlp or zipkin


def tracer_provider_processors_simple_exporter_otlp(
Expand All @@ -459,26 +450,39 @@ def tracer_provider_processors_simple_exporter_otlp(
headers: object = None,
timeout: int = None,
):
set_trace()
protocol = urlparse(protocol).scheme

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

def tracer_provider_processors_simple_exporter_otlp_headers(
**kwargs
):
set_trace()
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_simple_exporter_console(

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


def tracer_provider_processors_simple_exporter_console():
return ConsoleSpanExporter()


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


def tracer_provider_limits(
Expand All @@ -489,7 +493,14 @@ def tracer_provider_limits(
link_attribute_count_limit: int = None,
link_count_limit: int = None,
):
set_trace()
return SpanLimits(
max_span_attributes=attribute_count_limit,
max_span_attribute_length=attribute_value_length_limit,
max_event_attributes=event_count_limit,
max_events=event_count_limit,
max_link_attributes=link_attribute_count_limit,
max_links=link_count_limit,
)


def resource(
Expand Down

0 comments on commit 00df552

Please sign in to comment.