Setting Span Type and Dashboard Visibility in OpenTelemetry
How can I set the the span type. What should appear on the dashboard "kind" Here is my code:
from openinference.semconv.resource import ResourceAttributes
from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
# from phoenix.config import get_env_host, get_env_port
resource = Resource(attributes={
ResourceAttributes.PROJECT_NAME: "manual-instrumentation",
})
tracer_provider = TracerProvider(resource=resource)
trace.set_tracer_provider(tracer_provider=tracer_provider)
tracer = trace.get_tracer(__name__)
collector_endpoint = endpoint
span_exporter = OTLPSpanExporter(endpoint=collector_endpoint)
simple_span_processor = SimpleSpanProcessor(span_exporter=span_exporter)
trace.get_tracer_provider().add_span_processor(simple_span_processor)
from opentelemetry import trace
from openinference.semconv.trace import SpanAttributes
from opentelemetry.trace import Status, StatusCode, SpanKind
def inner_work():
with tracer.start_as_current_span("inner_work"):
print("Inner work")
def outer_work():
with tracer.start_as_current_span("outer_work", kind = SpanKind.SERVER) as span:
span.set_attribute(SpanAttributes.INPUT_MIME_TYPE, "this is not type")
inner_work()
print("Outer work")
outer_work()