@@ -93,10 +93,10 @@ def create_span_attributes(
9393 level : Optional [SpanLevel ] = None ,
9494 status_message : Optional [str ] = None ,
9595 version : Optional [str ] = None ,
96- observation_type : Optional [str ] = None ,
96+ observation_type : Optional [Literal [ "span" , "guardrail" ]] = "span" ,
9797) -> dict :
9898 attributes = {
99- LangfuseOtelSpanAttributes .OBSERVATION_TYPE : observation_type or "span" ,
99+ LangfuseOtelSpanAttributes .OBSERVATION_TYPE : observation_type ,
100100 LangfuseOtelSpanAttributes .OBSERVATION_LEVEL : level ,
101101 LangfuseOtelSpanAttributes .OBSERVATION_STATUS_MESSAGE : status_message ,
102102 LangfuseOtelSpanAttributes .VERSION : version ,
@@ -123,9 +123,20 @@ def create_generation_attributes(
123123 usage_details : Optional [Dict [str , int ]] = None ,
124124 cost_details : Optional [Dict [str , float ]] = None ,
125125 prompt : Optional [PromptClient ] = None ,
126+ observation_type : Optional [
127+ Literal [
128+ "generation" ,
129+ "agent" ,
130+ "tool" ,
131+ "chain" ,
132+ "retriever" ,
133+ "evaluator" ,
134+ "embedding" ,
135+ ]
136+ ] = "generation" ,
126137) -> dict :
127138 attributes = {
128- LangfuseOtelSpanAttributes .OBSERVATION_TYPE : "generation" ,
139+ LangfuseOtelSpanAttributes .OBSERVATION_TYPE : observation_type ,
129140 LangfuseOtelSpanAttributes .OBSERVATION_LEVEL : level ,
130141 LangfuseOtelSpanAttributes .OBSERVATION_STATUS_MESSAGE : status_message ,
131142 LangfuseOtelSpanAttributes .VERSION : version ,
0 commit comments