in pkg/rules/mcp/common_otel_instrumenter.go [43:82]
func (l LExperimentalAttributeExtractor) OnStart(attributes []attribute.KeyValue, parentContext context.Context, request mcpRequest) ([]attribute.KeyValue, context.Context) {
attributes, parentContext = l.Base.OnStart(attributes, parentContext, request)
var val attribute.Value
if request.methodType == string(mcp.MethodToolsCall) {
attributes = append(attributes, attribute.KeyValue{
Key: "gen_ai.tool.name",
Value: attribute.StringValue(request.methodName),
}, attribute.KeyValue{
Key: "gen_ai.tool.call.id",
Value: attribute.StringValue(request.CallId),
})
}
if request.input != nil {
for k, v := range request.input {
switch v.(type) {
case string:
val = attribute.StringValue(v.(string))
case int:
val = attribute.IntValue(v.(int))
case int64:
val = attribute.Int64Value(v.(int64))
case float64:
val = attribute.Float64Value(v.(float64))
case bool:
val = attribute.BoolValue(v.(bool))
default:
val = attribute.StringValue(fmt.Sprintf("%#v", v))
}
if val.Type() > 0 {
attributes = append(attributes, attribute.KeyValue{
Key: attribute.Key("gen_ai.other_input." + k),
Value: val,
})
}
val = attribute.Value{}
}
}
return attributes, parentContext
}