I am having trouble seeing the tags for any span_kind other than llm . For example in the following code-snippet, the tags are appearing for all spans having span-kind = llm, but not for other span-kinds (for example, RETRIEVER, CHAIN. Is that a feature or a bug? I am referring to https://docs.arize.com/arize/llm-tracing/how-to-tracing-manual/hybrid-instrumentation#using_tags
with using_tags(['chat-api']):
.... The issue you're experiencing with tags not appearing for span kinds other than llm might be related to how the tags are being set or propagated in your code. According to the Phoenix documentation, tags should be applicable to any span, not just those of kind llm. This suggests that the behavior you're observing could be a bug or a misconfiguration in your setup.Would you like more detailed guidance on how to troubleshoot this issue or ensure that tags are correctly applied to all span kinds? Sources:
- Phoenix documentation
馃挕聽Hint: Mention RunLLM in the thread for followups.
Hey Sagar D. - you are totally right on this one. We just haven't plumbed it through to the UI quite yet. http://github.com/Arize-ai/phoenix/issues/6772 In the meantime metadata is the best alternative to tags. It serves a very similar functionality
sorry about that.
Unfortunately, it seems to be the same issue for using metadata too. It is appearing only for span-kind = llm and not for other span kinds. This is the code I am using.
with using_tags(['chat-api']), using_metadata({"tag-1": "tag1"}):
....Ah it depends on the tracer you are using to start the span actually. Let me see if Xander S. can give you a concrete example here. Those context managers work with our decorators and tracers but not necessarily with raw otel tracers. Any chance you can show how your child span is being constructed?
Disregard the above example please. Here is a cleaner code. The span is being set with the right span-kind and input value. But neither the tag nor the metadata are appearing.
from openinference import semconv
from openinference.semconv import resource
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry import trace
from opentelemetry.trace import Tracer
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
resource = Resource(
attributes={semconv.resource.ResourceAttributes.PROJECT_NAME: 'phoenix'}
)
tracer_provider = TracerProvider(resource=resource)
trace.set_tracer_provider(tracer_provider)
span_exporter = OTLPSpanExporter(
endpoint='http://localhost:6006/v1/traces',
)
simple_span_processor = SimpleSpanProcessor(span_exporter=span_exporter)
trace.get_tracer_provider().add_span_processor(simple_span_processor)
tracer = trace.get_tracer(__name__)
meta_px = {"tag_1": "ingestion", "tag_2": "tag2"}
with tracer.start_as_current_span("process_document_ingestion") as span, using_tags(list(meta_px.values())), using_metadata(meta_px):
span.set_attribute(SpanAttributes.OPENINFERENCE_SPAN_KIND, "CHAIN")
span.set_attribute(SpanAttributes.INPUT_VALUE, "document_name")
Oh I see Sagar D. - so the inheriting of attributes only works with our TracerProvider so you will have to switch from opentelemetry.sdk.trace import TracerProvider to from openinference.instrumentation import TracerProvider This TracerProvider is just an extension of the otel tracer provider that supports things like metadata, tags, and AI related attributes. So something like:
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor
from openinference.instrumentation import TracerProvider
from openinference.semconv.resource import ResourceAttributes
endpoint = "http://127.0.0.1:6006/v1/traces"
resource = Resource(attributes={ResourceAttributes.PROJECT_NAME: "openinference-tracer"})
tracer_provider = TracerProvider(resource=resource)
tracer_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter(endpoint)))
tracer_provider.add_span_processor(SimpleSpanProcessor(ConsoleSpanExporter()))
tracer = tracer_provider.get_tracer(__name__)
Sorry if the docs were confusing. Will get that fixed.
That worked, thanks! But an interesting observation: The tags and metadata are not showing for the parent span process_document_ingestion, but it is showing for the child span autotag_document Here is the pseudo code. Am I missing something?
meta_px = {"tag_1": "ingestion", "tag_2": ingestion_job.id}
with tracer.start_as_current_span("process_document_ingestion") as span, using_tags(list(meta_px.values())), using_metadata(meta_px):
span.set_attribute(SpanAttributes.OPENINFERENCE_SPAN_KIND, "CHAIN")
span.set_attribute(SpanAttributes.INPUT_VALUE, ingestion_job.prodigy_document.name)
await autotag_document(ingestion_job.prodigy_document, ingestion_job.case_context)
async def autotag_document(prodigy_document: ProdigyDocument):
with tracer.start_as_current_span("autotag_document") as span:
span.set_attribute(SpanAttributes.OPENINFERENCE_SPAN_KIND, "AGENT")
span.set_attribute(SpanAttributes.INPUT_VALUE, prodigy_document.name)