RunLLM how do I use a tracer provider to add a custom span to an auto-instrumented trace?
To add a custom span to an auto-instrumented trace, use your tracer provider to create a span within the context of the auto-instrumented operation. This ensures your custom span is a child of the active auto-instrumented span. For Python, use tracer.start_as_current_span("custom-span-name") inside the code path where the auto-instrumented span is active, and set any desired attributes on the span. The custom span will be properly nested in the trace hierarchy if created within the active context of the auto-instrumented span (custom-spans.md, manual instrumentation guide).Example: LBKSfrom opentelemetry import traceLBKStracer = trace.get_tracer(__name__)LBKSwith tracer.start_as_current_span("custom-span") as span: span.set_attribute("my_attribute", "value") # Your custom logic hereLBKSThis should be placed where the auto-instrumented span is active to ensure correct parent-child relationships. Would you like more detail or a framework-specific example?Sources:
- custom-spans.md
馃挕聽Hint: Mention RunLLM in the thread for followups.
This usually happens if the custom span is created outside the context of the auto-instrumented span, so it doesn't inherit the parent trace context. To ensure your custom span is a child, you must create it within the active context of the auto-instrumented span鈥攐therwise, it will start a new trace (custom-spans.md, manual instrumentation guide).If you need to explicitly set the parent, use the current context when starting your span. For example, in Python: LBKSfrom opentelemetry import trace from opentelemetry.trace import set_span_in_contextLBKSparent_span = trace.get_current_span() parent_context = set_span_in_context(parent_span) with tracer.start_as_current_span("custom-span", context=parent_context) as span: # custom logic passLBKSWould you like more detail or troubleshooting steps?Sources:
- custom-spans.md
馃挕聽Hint: Mention RunLLM in the thread for followups.
that last message worked 馃檪
